OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "components/web_resource/promo_resource_service.h" | 5 #include "components/web_resource/promo_resource_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 GetCacheUpdateDelay(), | 103 GetCacheUpdateDelay(), |
104 request_context, | 104 request_context, |
105 disable_network_switch, | 105 disable_network_switch, |
106 parse_json_callback), | 106 parse_json_callback), |
107 weak_ptr_factory_(this) { | 107 weak_ptr_factory_(this) { |
108 ScheduleNotificationOnInit(); | 108 ScheduleNotificationOnInit(); |
109 } | 109 } |
110 | 110 |
111 PromoResourceService::~PromoResourceService() {} | 111 PromoResourceService::~PromoResourceService() {} |
112 | 112 |
113 scoped_ptr<PromoResourceService::StateChangedSubscription> | 113 std::unique_ptr<PromoResourceService::StateChangedSubscription> |
114 PromoResourceService::RegisterStateChangedCallback( | 114 PromoResourceService::RegisterStateChangedCallback( |
115 const base::Closure& closure) { | 115 const base::Closure& closure) { |
116 return callback_list_.Add(closure); | 116 return callback_list_.Add(closure); |
117 } | 117 } |
118 | 118 |
119 void PromoResourceService::ScheduleNotification( | 119 void PromoResourceService::ScheduleNotification( |
120 const NotificationPromo& notification_promo) { | 120 const NotificationPromo& notification_promo) { |
121 const double promo_start = notification_promo.StartTimeForGroup(); | 121 const double promo_start = notification_promo.StartTimeForGroup(); |
122 const double promo_end = notification_promo.EndTime(); | 122 const double promo_end = notification_promo.EndTime(); |
123 | 123 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void PromoResourceService::Unpack(const base::DictionaryValue& parsed_json) { | 182 void PromoResourceService::Unpack(const base::DictionaryValue& parsed_json) { |
183 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { | 183 for (size_t i = 0; i < arraysize(kValidPromoTypes); ++i) { |
184 NotificationPromo notification_promo(prefs_); | 184 NotificationPromo notification_promo(prefs_); |
185 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); | 185 notification_promo.InitFromJson(parsed_json, kValidPromoTypes[i]); |
186 if (notification_promo.new_notification()) | 186 if (notification_promo.new_notification()) |
187 ScheduleNotification(notification_promo); | 187 ScheduleNotification(notification_promo); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 } // namespace web_resource | 191 } // namespace web_resource |
OLD | NEW |