OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 5 #ifndef COMPONENTS_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
6 #define COMPONENTS_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 6 #define COMPONENTS_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
13 #include "base/callback_list.h" | 14 #include "base/callback_list.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "components/web_resource/web_resource_service.h" | 17 #include "components/web_resource/web_resource_service.h" |
17 | 18 |
18 class PrefRegistrySimple; | 19 class PrefRegistrySimple; |
19 class PrefService; | 20 class PrefService; |
(...skipping 30 matching lines...) Expand all Loading... |
50 PromoResourceService(PrefService* local_state, | 51 PromoResourceService(PrefService* local_state, |
51 version_info::Channel channel, | 52 version_info::Channel channel, |
52 const std::string& application_locale, | 53 const std::string& application_locale, |
53 net::URLRequestContextGetter* request_context, | 54 net::URLRequestContextGetter* request_context, |
54 const char* disable_network_switch, | 55 const char* disable_network_switch, |
55 const ParseJSONCallback& parse_json_callback); | 56 const ParseJSONCallback& parse_json_callback); |
56 ~PromoResourceService() override; | 57 ~PromoResourceService() override; |
57 | 58 |
58 // Registers a callback called when the state of a web resource has been | 59 // Registers a callback called when the state of a web resource has been |
59 // changed. A resource may have been added, removed, or altered. | 60 // changed. A resource may have been added, removed, or altered. |
60 scoped_ptr<StateChangedSubscription> RegisterStateChangedCallback( | 61 std::unique_ptr<StateChangedSubscription> RegisterStateChangedCallback( |
61 const base::Closure& closure); | 62 const base::Closure& closure); |
62 | 63 |
63 private: | 64 private: |
64 // Schedule a notification that a web resource is either going to become | 65 // Schedule a notification that a web resource is either going to become |
65 // available or be no longer valid. | 66 // available or be no longer valid. |
66 void ScheduleNotification(const NotificationPromo& notification_promo); | 67 void ScheduleNotification(const NotificationPromo& notification_promo); |
67 | 68 |
68 // Schedules the initial notification for when the web resource is going | 69 // Schedules the initial notification for when the web resource is going |
69 // to become available or no longer valid. This performs a few additional | 70 // to become available or no longer valid. This performs a few additional |
70 // checks than ScheduleNotification, namely it schedules updates immediately | 71 // checks than ScheduleNotification, namely it schedules updates immediately |
(...skipping 18 matching lines...) Expand all Loading... |
89 // This allows the PromoResourceService to notify the New Tab Page immediately | 90 // This allows the PromoResourceService to notify the New Tab Page immediately |
90 // when a new web resource should be shown or removed. | 91 // when a new web resource should be shown or removed. |
91 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; | 92 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; |
92 | 93 |
93 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); | 94 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); |
94 }; | 95 }; |
95 | 96 |
96 } // namespace web_resource | 97 } // namespace web_resource |
97 | 98 |
98 #endif // COMPONENTS_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 99 #endif // COMPONENTS_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
OLD | NEW |