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> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
11 #include "base/callback_list.h" | 13 #include "base/callback_list.h" |
| 14 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
13 #include "components/web_resource/web_resource_service.h" | 16 #include "components/web_resource/web_resource_service.h" |
14 | 17 |
15 class PrefRegistrySimple; | 18 class PrefRegistrySimple; |
16 class PrefService; | 19 class PrefService; |
17 | 20 |
18 namespace base { | 21 namespace base { |
19 class DictionaryValue; | 22 class DictionaryValue; |
20 } | 23 } |
21 | 24 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 67 |
65 // Schedules the initial notification for when the web resource is going | 68 // Schedules the initial notification for when the web resource is going |
66 // to become available or no longer valid. This performs a few additional | 69 // to become available or no longer valid. This performs a few additional |
67 // checks than ScheduleNotification, namely it schedules updates immediately | 70 // checks than ScheduleNotification, namely it schedules updates immediately |
68 // if the promo service or Chrome locale has changed. | 71 // if the promo service or Chrome locale has changed. |
69 void ScheduleNotificationOnInit(); | 72 void ScheduleNotificationOnInit(); |
70 | 73 |
71 // If delay_ms is positive, schedule notification with the delay. | 74 // If delay_ms is positive, schedule notification with the delay. |
72 // If delay_ms is 0, notify immediately by calling WebResourceStateChange(). | 75 // If delay_ms is 0, notify immediately by calling WebResourceStateChange(). |
73 // If delay_ms is negative, do nothing. | 76 // If delay_ms is negative, do nothing. |
74 void PostNotification(int64 delay_ms); | 77 void PostNotification(int64_t delay_ms); |
75 | 78 |
76 // Notify listeners that the state of a web resource has changed. | 79 // Notify listeners that the state of a web resource has changed. |
77 void PromoResourceStateChange(); | 80 void PromoResourceStateChange(); |
78 | 81 |
79 // WebResourceService override to process the parsed information. | 82 // WebResourceService override to process the parsed information. |
80 void Unpack(const base::DictionaryValue& parsed_json) override; | 83 void Unpack(const base::DictionaryValue& parsed_json) override; |
81 | 84 |
82 // List of callbacks called when the state of a web resource has changed. | 85 // List of callbacks called when the state of a web resource has changed. |
83 StateChangedCallbackList callback_list_; | 86 StateChangedCallbackList callback_list_; |
84 | 87 |
85 // Allows the creation of tasks to send a notification. | 88 // Allows the creation of tasks to send a notification. |
86 // This allows the PromoResourceService to notify the New Tab Page immediately | 89 // This allows the PromoResourceService to notify the New Tab Page immediately |
87 // when a new web resource should be shown or removed. | 90 // when a new web resource should be shown or removed. |
88 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; | 91 base::WeakPtrFactory<PromoResourceService> weak_ptr_factory_; |
89 | 92 |
90 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); | 93 DISALLOW_COPY_AND_ASSIGN(PromoResourceService); |
91 }; | 94 }; |
92 | 95 |
93 } // namespace web_resource | 96 } // namespace web_resource |
94 | 97 |
95 #endif // COMPONENTS_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ | 98 #endif // COMPONENTS_WEB_RESOURCE_PROMO_RESOURCE_SERVICE_H_ |
OLD | NEW |