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

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

Issue 7972022: Minor debugging fix so we fetch promos every 3 min when we're testing. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 9 years, 3 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) 2011 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/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/threading/thread_restrictions.h" 9 #include "base/threading/thread_restrictions.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "content/browser/browser_thread.h" 22 #include "content/browser/browser_thread.h"
23 #include "content/common/notification_service.h" 23 #include "content/common/notification_service.h"
24 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
25 25
26 namespace { 26 namespace {
27 27
28 // Delay on first fetch so we don't interfere with startup. 28 // Delay on first fetch so we don't interfere with startup.
29 static const int kStartResourceFetchDelay = 5000; 29 static const int kStartResourceFetchDelay = 5000;
30 30
31 // Delay between calls to update the cache (48 hours). 31 // Delay between calls to update the cache (48 hours), and 3 min in debug mode.
32 static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000; 32 static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000;
33 static const int kDebugCacheUpdateDelay = 3 * 60 * 1000;
33 34
34 // Users are randomly assigned to one of kNTPPromoGroupSize buckets, in order 35 // Users are randomly assigned to one of kNTPPromoGroupSize buckets, in order
35 // to be able to roll out promos slowly, or display different promos to 36 // to be able to roll out promos slowly, or display different promos to
36 // different groups. 37 // different groups.
37 static const int kNTPPromoGroupSize = 100; 38 static const int kNTPPromoGroupSize = 100;
38 39
39 // Maximum number of hours for each time slice (4 weeks). 40 // Maximum number of hours for each time slice (4 weeks).
40 static const int kMaxTimeSliceHours = 24 * 7 * 4; 41 static const int kMaxTimeSliceHours = 24 * 7 * 4;
41 42
42 // The version of the service (used to expire the cache when upgrading Chrome 43 // The version of the service (used to expire the cache when upgrading Chrome
(...skipping 30 matching lines...) Expand all
73 } 74 }
74 75
75 const char* GetPromoResourceURL() { 76 const char* GetPromoResourceURL() {
76 std::string promo_server_url = CommandLine::ForCurrentProcess()-> 77 std::string promo_server_url = CommandLine::ForCurrentProcess()->
77 GetSwitchValueASCII(switches::kPromoServerURL); 78 GetSwitchValueASCII(switches::kPromoServerURL);
78 return promo_server_url.empty() ? 79 return promo_server_url.empty() ?
79 PromoResourceService::kDefaultPromoResourceServer : 80 PromoResourceService::kDefaultPromoResourceServer :
80 promo_server_url.c_str(); 81 promo_server_url.c_str();
81 } 82 }
82 83
84 int GetCacheUpdateDelay() {
85 return CommandLine::ForCurrentProcess()->HasSwitch(
86 switches::kPromoServerURL) ? kDebugCacheUpdateDelay : kCacheUpdateDelay;
87 }
88
83 } // namespace 89 } // namespace
84 90
85 // Server for dynamically loaded NTP HTML elements. 91 // Server for dynamically loaded NTP HTML elements.
86 const char* PromoResourceService::kDefaultPromoResourceServer = 92 const char* PromoResourceService::kDefaultPromoResourceServer =
87 "https://www.google.com/support/chrome/bin/topic/1142433/inproduct?hl="; 93 "https://www.google.com/support/chrome/bin/topic/1142433/inproduct?hl=";
88 94
89 // static 95 // static
90 void PromoResourceService::RegisterPrefs(PrefService* local_state) { 96 void PromoResourceService::RegisterPrefs(PrefService* local_state) {
91 local_state->RegisterIntegerPref(prefs::kNTPPromoVersion, 0); 97 local_state->RegisterIntegerPref(prefs::kNTPPromoVersion, 0);
92 local_state->RegisterStringPref(prefs::kNTPPromoLocale, std::string()); 98 local_state->RegisterStringPref(prefs::kNTPPromoLocale, std::string());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 154 }
149 } 155 }
150 156
151 PromoResourceService::PromoResourceService(Profile* profile) 157 PromoResourceService::PromoResourceService(Profile* profile)
152 : WebResourceService(profile->GetPrefs(), 158 : WebResourceService(profile->GetPrefs(),
153 GetPromoResourceURL(), 159 GetPromoResourceURL(),
154 true, // append locale to URL 160 true, // append locale to URL
155 chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, 161 chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
156 prefs::kNTPPromoResourceCacheUpdate, 162 prefs::kNTPPromoResourceCacheUpdate,
157 kStartResourceFetchDelay, 163 kStartResourceFetchDelay,
158 kCacheUpdateDelay), 164 GetCacheUpdateDelay()),
159 profile_(profile), 165 profile_(profile),
160 channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { 166 channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {
161 Init(); 167 Init();
162 } 168 }
163 169
164 PromoResourceService::~PromoResourceService() { } 170 PromoResourceService::~PromoResourceService() { }
165 171
166 void PromoResourceService::Init() { 172 void PromoResourceService::Init() {
167 ScheduleNotificationOnInit(); 173 ScheduleNotificationOnInit();
168 } 174 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 if (!(old_logo_start == logo_start) || 577 if (!(old_logo_start == logo_start) ||
572 !(old_logo_end == logo_end)) { 578 !(old_logo_end == logo_end)) {
573 prefs_->SetDouble(prefs::kNTPCustomLogoStart, logo_start); 579 prefs_->SetDouble(prefs::kNTPCustomLogoStart, logo_start);
574 prefs_->SetDouble(prefs::kNTPCustomLogoEnd, logo_end); 580 prefs_->SetDouble(prefs::kNTPCustomLogoEnd, logo_end);
575 NotificationService* service = NotificationService::current(); 581 NotificationService* service = NotificationService::current();
576 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, 582 service->Notify(chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
577 Source<WebResourceService>(this), 583 Source<WebResourceService>(this),
578 NotificationService::NoDetails()); 584 NotificationService::NoDetails());
579 } 585 }
580 } 586 }
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