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

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

Issue 8931005: Remove debug code that accidentally got committed with promo_service changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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/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 12 matching lines...) Expand all
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "googleurl/src/gurl.h" 25 #include "googleurl/src/gurl.h"
26 26
27 namespace { 27 namespace {
28 28
29 // Delay on first fetch so we don't interfere with startup. 29 // Delay on first fetch so we don't interfere with startup.
30 static const int kStartResourceFetchDelay = 5000; 30 static const int kStartResourceFetchDelay = 5000;
31 31
32 // Delay between calls to update the cache (48 hours), and 3 min in debug mode. 32 // Delay between calls to update the cache (48 hours), and 3 min in debug mode.
33 static const int kCacheUpdateDelay = 1 * 60 * 1000; 33 static const int kCacheUpdateDelay = 48 * 60 * 60 * 1000;
34 static const int kTestCacheUpdateDelay = 1 * 60 * 1000; 34 static const int kTestCacheUpdateDelay = 3 * 60 * 1000;
35 35
36 // The version of the service (used to expire the cache when upgrading Chrome 36 // The version of the service (used to expire the cache when upgrading Chrome
37 // to versions with different types of promos). 37 // to versions with different types of promos).
38 static const int kPromoServiceVersion = 7; 38 static const int kPromoServiceVersion = 7;
39 39
40 // The number of groups sign-in promo users will be divided into (which gives us 40 // The number of groups sign-in promo users will be divided into (which gives us
41 // a 1/N granularity when targeting more groups). 41 // a 1/N granularity when targeting more groups).
42 static const int kNTPSignInPromoNumberOfGroups = 100; 42 static const int kNTPSignInPromoNumberOfGroups = 100;
43 43
44 // Properties used by the server. 44 // Properties used by the server.
45 static const char kAnswerIdProperty[] = "answer_id"; 45 static const char kAnswerIdProperty[] = "answer_id";
46 static const char kWebStoreHeaderProperty[] = "question"; 46 static const char kWebStoreHeaderProperty[] = "question";
47 static const char kWebStoreButtonProperty[] = "inproduct_target"; 47 static const char kWebStoreButtonProperty[] = "inproduct_target";
48 static const char kWebStoreLinkProperty[] = "inproduct"; 48 static const char kWebStoreLinkProperty[] = "inproduct";
49 static const char kWebStoreExpireProperty[] = "tooltip"; 49 static const char kWebStoreExpireProperty[] = "tooltip";
50 50
51 const char* GetPromoResourceURL() { 51 const char* GetPromoResourceURL() {
52 const char* kCaitPromoResourceServer =
53 "http://caitkp-desktop.mon.corp.google.com/promo.js?";
54 std::string promo_server_url = CommandLine::ForCurrentProcess()-> 52 std::string promo_server_url = CommandLine::ForCurrentProcess()->
55 GetSwitchValueASCII(switches::kPromoServerURL); 53 GetSwitchValueASCII(switches::kPromoServerURL);
56 return promo_server_url.empty() ? 54 return promo_server_url.empty() ?
57 PromoResourceService::kDefaultPromoResourceServer : 55 PromoResourceService::kDefaultPromoResourceServer :
58 kCaitPromoResourceServer; 56 promo_server_url.c_str();
59 //promo_server_url.c_str();
60 } 57 }
61 58
62 bool IsTest() { 59 bool IsTest() {
63 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kPromoServerURL); 60 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kPromoServerURL);
64 } 61 }
65 62
66 int GetCacheUpdateDelay() { 63 int GetCacheUpdateDelay() {
67 return IsTest() ? kTestCacheUpdateDelay : kCacheUpdateDelay; 64 return IsTest() ? kTestCacheUpdateDelay : kCacheUpdateDelay;
68 } 65 }
69 66
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 default: 122 default:
126 // Show promos for local builds when using a custom promo URL. 123 // Show promos for local builds when using a custom promo URL.
127 return CommandLine::ForCurrentProcess()->HasSwitch( 124 return CommandLine::ForCurrentProcess()->HasSwitch(
128 switches::kPromoServerURL); 125 switches::kPromoServerURL);
129 } 126 }
130 } 127 }
131 128
132 PromoResourceService::PromoResourceService(Profile* profile) 129 PromoResourceService::PromoResourceService(Profile* profile)
133 : WebResourceService(profile->GetPrefs(), 130 : WebResourceService(profile->GetPrefs(),
134 GetPromoResourceURL(), 131 GetPromoResourceURL(),
135 false,//true, // append locale to URL 132 true, // append locale to URL
136 chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED, 133 chrome::NOTIFICATION_PROMO_RESOURCE_STATE_CHANGED,
137 prefs::kNTPPromoResourceCacheUpdate, 134 prefs::kNTPPromoResourceCacheUpdate,
138 kStartResourceFetchDelay, 135 kStartResourceFetchDelay,
139 GetCacheUpdateDelay()), 136 GetCacheUpdateDelay()),
140 profile_(profile), 137 profile_(profile),
141 channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { 138 channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {
142 Init(); 139 Init();
143 } 140 }
144 141
145 PromoResourceService::~PromoResourceService() { } 142 PromoResourceService::~PromoResourceService() { }
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 if (!prefs->HasPrefPath(prefs::kNTPSignInPromoGroup)) { 455 if (!prefs->HasPrefPath(prefs::kNTPSignInPromoGroup)) {
459 prefs->SetInteger(prefs::kNTPSignInPromoGroup, 456 prefs->SetInteger(prefs::kNTPSignInPromoGroup,
460 base::RandInt(1, kNTPSignInPromoNumberOfGroups)); 457 base::RandInt(1, kNTPSignInPromoNumberOfGroups));
461 } 458 }
462 459
463 // A response is not kept if the build wasn't targeted, so the only thing 460 // A response is not kept if the build wasn't targeted, so the only thing
464 // required to check is the group this client has been tagged in. 461 // required to check is the group this client has been tagged in.
465 return prefs->GetInteger(prefs::kNTPSignInPromoGroupMax) >= 462 return prefs->GetInteger(prefs::kNTPSignInPromoGroupMax) >=
466 prefs->GetInteger(prefs::kNTPSignInPromoGroup); 463 prefs->GetInteger(prefs::kNTPSignInPromoGroup);
467 } 464 }
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