blob: b5d4f3540d865999c066e3846a5543414b04628b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_QUERY_TILES_TILE_SERVICE_H_
#define COMPONENTS_QUERY_TILES_TILE_SERVICE_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "base/optional.h"
#include "base/supports_user_data.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/query_tiles/logger.h"
#include "components/query_tiles/tile.h"
namespace gfx {
class Image;
} // namespace gfx
namespace query_tiles {
using TileList = std::vector<Tile>;
using GetTilesCallback = base::OnceCallback<void(TileList)>;
using TileCallback = base::OnceCallback<void(base::Optional<Tile>)>;
using VisualsCallback = base::OnceCallback<void(const gfx::Image&)>;
using BackgroundTaskFinishedCallback = base::OnceCallback<void(bool)>;
// The central class on chrome client responsible for fetching, storing,
// managing, and displaying query tiles in chrome.
class TileService : public KeyedService, public base::SupportsUserData {
public:
// Called to retrieve all the tiles.
virtual void GetQueryTiles(GetTilesCallback callback) = 0;
// Called to retrieve the tile associated with |tile_id|.
virtual void GetTile(const std::string& tile_id, TileCallback callback) = 0;
// Start fetch query tiles from server.
virtual void StartFetchForTiles(bool is_from_reduced_mode,
BackgroundTaskFinishedCallback callback) = 0;
// Cancel any existing scheduled task, and reset backoff.
virtual void CancelTask() = 0;
// Used for debugging and testing only. Clear everything in db.
virtual void PurgeDb() = 0;
TileService() = default;
~TileService() override = default;
TileService(const TileService&) = delete;
TileService& operator=(const TileService&) = delete;
};
} // namespace query_tiles
#endif // COMPONENTS_QUERY_TILES_TILE_SERVICE_H_
|