OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_ | 5 #ifndef COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_ |
6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_ | 6 #define COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "components/gcm_driver/common/gcm_messages.h" |
| 11 #include "components/gcm_driver/gcm_app_handler.h" |
10 #include "components/offline_pages/core/prefetch/prefetch_service.h" | 12 #include "components/offline_pages/core/prefetch/prefetch_service.h" |
11 #include "url/gurl.h" | 13 #include "url/gurl.h" |
12 | 14 |
| 15 namespace gcm { |
| 16 class GCMDriver; |
| 17 } |
| 18 |
13 namespace offline_pages { | 19 namespace offline_pages { |
14 | 20 |
15 class PrefetchServiceImpl : public PrefetchService { | 21 class PrefetchServiceImpl : public PrefetchService { |
16 public: | 22 public: |
| 23 class PrefetchServiceAppHandler : public gcm::GCMAppHandler { |
| 24 public: |
| 25 PrefetchServiceAppHandler() = default; |
| 26 ~PrefetchServiceAppHandler() override = default; |
| 27 // GCMAppHandler implementation: |
| 28 void ShutdownHandler() override; |
| 29 void OnStoreReset() override; |
| 30 void OnMessage(const std::string& app_id, |
| 31 const gcm::IncomingMessage& message) override; |
| 32 void OnMessagesDeleted(const std::string& app_id) override; |
| 33 void OnSendError( |
| 34 const std::string& app_id, |
| 35 const gcm::GCMClient::SendErrorDetails& send_error_details) override; |
| 36 void OnSendAcknowledged(const std::string& app_id, |
| 37 const std::string& message_id) override; |
| 38 |
| 39 private: |
| 40 DISALLOW_COPY_AND_ASSIGN(PrefetchServiceAppHandler); |
| 41 }; |
| 42 |
17 PrefetchServiceImpl(); | 43 PrefetchServiceImpl(); |
18 ~PrefetchServiceImpl() override; | 44 ~PrefetchServiceImpl() override; |
19 | 45 |
20 // PrefetchService implementation: | 46 // PrefetchService implementation: |
21 void AddCandidatePrefetchURLs( | 47 void AddCandidatePrefetchURLs( |
22 const std::vector<PrefetchURL>& suggested_urls) override; | 48 const std::vector<PrefetchURL>& suggested_urls) override; |
23 void RemoveAllUnprocessedPrefetchURLs(const std::string& name_space) override; | 49 void RemoveAllUnprocessedPrefetchURLs(const std::string& name_space) override; |
24 void RemovePrefetchURLsByClientId(const ClientId& client_id) override; | 50 void RemovePrefetchURLsByClientId(const ClientId& client_id) override; |
25 void BeginBackgroundTask(std::unique_ptr<ScopedBackgroundTask> task) override; | 51 void BeginBackgroundTask(std::unique_ptr<ScopedBackgroundTask> task) override; |
26 void StopBackgroundTask(ScopedBackgroundTask* task) override; | 52 void StopBackgroundTask(ScopedBackgroundTask* task) override; |
| 53 void RegisterWithGCMDriver(gcm::GCMDriver* driver) override; |
27 | 54 |
28 // KeyedService implementation: | 55 // KeyedService implementation: |
29 void Shutdown() override; | 56 void Shutdown() override; |
30 | 57 |
31 private: | 58 private: |
| 59 PrefetchServiceAppHandler app_handler_; |
| 60 |
32 DISALLOW_COPY_AND_ASSIGN(PrefetchServiceImpl); | 61 DISALLOW_COPY_AND_ASSIGN(PrefetchServiceImpl); |
33 }; | 62 }; |
34 | 63 |
35 } // namespace offline_pages | 64 } // namespace offline_pages |
36 | 65 |
37 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_ | 66 #endif // COMPONENTS_OFFLINE_PAGES_CORE_PREFETCH_PREFETCH_SERVICE_IMPL_H_ |
OLD | NEW |