| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 210 |
| 211 void PromoResourceService::PostNotification(int64 delay_ms) { | 211 void PromoResourceService::PostNotification(int64 delay_ms) { |
| 212 if (web_resource_update_scheduled_) | 212 if (web_resource_update_scheduled_) |
| 213 return; | 213 return; |
| 214 if (delay_ms > 0) { | 214 if (delay_ms > 0) { |
| 215 web_resource_update_scheduled_ = true; | 215 web_resource_update_scheduled_ = true; |
| 216 MessageLoop::current()->PostDelayedTask( | 216 MessageLoop::current()->PostDelayedTask( |
| 217 FROM_HERE, | 217 FROM_HERE, |
| 218 base::Bind(&PromoResourceService::PromoResourceStateChange, | 218 base::Bind(&PromoResourceService::PromoResourceStateChange, |
| 219 weak_ptr_factory_.GetWeakPtr()), | 219 weak_ptr_factory_.GetWeakPtr()), |
| 220 base::TimeDelta::FromMilliseconds(delay_ms)); | 220 delay_ms); |
| 221 } else if (delay_ms == 0) { | 221 } else if (delay_ms == 0) { |
| 222 PromoResourceStateChange(); | 222 PromoResourceStateChange(); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 void PromoResourceService::PromoResourceStateChange() { | 226 void PromoResourceService::PromoResourceStateChange() { |
| 227 web_resource_update_scheduled_ = false; | 227 web_resource_update_scheduled_ = false; |
| 228 content::NotificationService* service = | 228 content::NotificationService* service = |
| 229 content::NotificationService::current(); | 229 content::NotificationService::current(); |
| 230 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, | 230 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (!prefs->HasPrefPath(prefs::kNTPSignInPromoGroup)) { | 479 if (!prefs->HasPrefPath(prefs::kNTPSignInPromoGroup)) { |
| 480 prefs->SetInteger(prefs::kNTPSignInPromoGroup, | 480 prefs->SetInteger(prefs::kNTPSignInPromoGroup, |
| 481 base::RandInt(1, kNTPSignInPromoNumberOfGroups)); | 481 base::RandInt(1, kNTPSignInPromoNumberOfGroups)); |
| 482 } | 482 } |
| 483 | 483 |
| 484 // A response is not kept if the build wasn't targeted, so the only thing | 484 // A response is not kept if the build wasn't targeted, so the only thing |
| 485 // required to check is the group this client has been tagged in. | 485 // required to check is the group this client has been tagged in. |
| 486 return prefs->GetInteger(prefs::kNTPSignInPromoGroupMax) >= | 486 return prefs->GetInteger(prefs::kNTPSignInPromoGroupMax) >= |
| 487 prefs->GetInteger(prefs::kNTPSignInPromoGroup); | 487 prefs->GetInteger(prefs::kNTPSignInPromoGroup); |
| 488 } | 488 } |
| OLD | NEW |