Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: chrome/browser/web_resource/promo_resource_service.cc

Issue 10541054: Immediate notification if active promotion arrives (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/web_resource/promo_resource_service.h" 5 #include "chrome/browser/web_resource/promo_resource_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (promo_start > 0 && promo_end > 0) { 146 if (promo_start > 0 && promo_end > 0) {
147 int64 ms_until_start = 147 int64 ms_until_start =
148 static_cast<int64>((base::Time::FromDoubleT( 148 static_cast<int64>((base::Time::FromDoubleT(
149 promo_start) - base::Time::Now()).InMilliseconds()); 149 promo_start) - base::Time::Now()).InMilliseconds());
150 int64 ms_until_end = 150 int64 ms_until_end =
151 static_cast<int64>((base::Time::FromDoubleT( 151 static_cast<int64>((base::Time::FromDoubleT(
152 promo_end) - base::Time::Now()).InMilliseconds()); 152 promo_end) - base::Time::Now()).InMilliseconds());
153 if (ms_until_start > 0) 153 if (ms_until_start > 0)
154 PostNotification(ms_until_start); 154 PostNotification(ms_until_start);
155 if (ms_until_end > 0) { 155 if (ms_until_end > 0) {
156 PostNotification(ms_until_end);
157 if (ms_until_start <= 0) { 156 if (ms_until_start <= 0) {
158 // Notify immediately if time is between start and end. 157 // Notify immediately if time is between start and end.
159 PostNotification(0); 158 PostNotification(0);
160 } 159 }
160 // Schedule notification at the end of promotion
Dan Beam 2012/06/07 18:14:57 nit: . at end of comment.
aruslan 2012/06/07 18:21:35 Done.
161 PostNotification(ms_until_end);
161 } 162 }
162 } 163 }
163 } 164 }
164 165
165 void PromoResourceService::ScheduleNotificationOnInit() { 166 void PromoResourceService::ScheduleNotificationOnInit() {
166 std::string locale = g_browser_process->GetApplicationLocale(); 167 std::string locale = g_browser_process->GetApplicationLocale();
167 if (GetPromoServiceVersion() != kPromoServiceVersion || 168 if (GetPromoServiceVersion() != kPromoServiceVersion ||
168 GetPromoLocale() != locale) { 169 GetPromoLocale() != locale) {
169 // If the promo service has been upgraded or Chrome switched locales, 170 // If the promo service has been upgraded or Chrome switched locales,
170 // refresh the promos. 171 // refresh the promos.
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 !(old_logo_end == logo_end)) { 383 !(old_logo_end == logo_end)) {
383 prefs_->SetDouble(prefs::kNtpCustomLogoStart, logo_start); 384 prefs_->SetDouble(prefs::kNtpCustomLogoStart, logo_start);
384 prefs_->SetDouble(prefs::kNtpCustomLogoEnd, logo_end); 385 prefs_->SetDouble(prefs::kNtpCustomLogoEnd, logo_end);
385 content::NotificationService* service = 386 content::NotificationService* service =
386 content::NotificationService::current(); 387 content::NotificationService::current();
387 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, 388 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
388 content::Source<WebResourceService>(this), 389 content::Source<WebResourceService>(this),
389 content::NotificationService::NoDetails()); 390 content::NotificationService::NoDetails());
390 } 391 }
391 } 392 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698