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

Side by Side Diff: chrome/browser/rlz/rlz.cc

Issue 11412067: [rlz,cros] RLZ glue for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Always save RLZ enabled flag. Created 8 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
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 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work 5 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work
6 // with or without the DLL being present. If the DLL is not present the 6 // with or without the DLL being present. If the DLL is not present the
7 // functions do nothing and just return false. 7 // functions do nothing and just return false.
8 8
9 #include "chrome/browser/rlz/rlz.h" 9 #include "chrome/browser/rlz/rlz.h"
10 10
11 #include <algorithm> 11 #include <algorithm>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/command_line.h"
14 #include "base/debug/trace_event.h" 15 #include "base/debug/trace_event.h"
15 #include "base/message_loop.h" 16 #include "base/message_loop.h"
16 #include "base/string_util.h" 17 #include "base/string_util.h"
17 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
18 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/google/google_util.h" 20 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/prefs/session_startup_pref.h"
20 #include "chrome/browser/search_engines/template_url.h" 23 #include "chrome/browser/search_engines/template_url.h"
21 #include "chrome/browser/search_engines/template_url_service.h" 24 #include "chrome/browser/search_engines/template_url_service.h"
22 #include "chrome/browser/search_engines/template_url_service_factory.h" 25 #include "chrome/browser/search_engines/template_url_service_factory.h"
26 #include "chrome/browser/ui/startup/startup_browser_creator.h"
23 #include "chrome/common/chrome_notification_types.h" 27 #include "chrome/common/chrome_notification_types.h"
28 #include "chrome/common/pref_names.h"
24 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/navigation_entry.h" 30 #include "content/public/browser/navigation_entry.h"
26 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
27 #include "net/http/http_util.h" 32 #include "net/http/http_util.h"
28 33
29 #if defined(OS_CHROMEOS)
30 #include "base/threading/sequenced_worker_pool.h"
31 #endif
32
33 #if defined(OS_WIN) 34 #if defined(OS_WIN)
34 #include "chrome/installer/util/google_update_settings.h" 35 #include "chrome/installer/util/google_update_settings.h"
35 #else 36 #else
36 namespace GoogleUpdateSettings { 37 namespace GoogleUpdateSettings {
37 static bool GetLanguage(string16* language) { 38 static bool GetLanguage(string16* language) {
38 // TODO(thakis): Implement. 39 // TODO(thakis): Implement.
39 NOTIMPLEMENTED(); 40 NOTIMPLEMENTED();
40 return false; 41 return false;
41 } 42 }
42 43
43 // The referral program is defunct and not used. No need to implement these 44 // The referral program is defunct and not used. No need to implement these
44 // functions on non-Win platforms. 45 // functions on non-Win platforms.
45 static bool GetReferral(string16* referral) { 46 static bool GetReferral(string16* referral) {
46 return true; 47 return true;
47 } 48 }
48 static bool ClearReferral() { 49 static bool ClearReferral() {
49 return true; 50 return true;
50 } 51 }
51 } // namespace GoogleUpdateSettings 52 } // namespace GoogleUpdateSettings
52 #endif 53 #endif
53 54
54 using content::BrowserThread; 55 using content::BrowserThread;
55 using content::NavigationEntry; 56 using content::NavigationEntry;
56 57
57 namespace { 58 namespace {
58 59
59 const char kRlzThreadName[] = "RLZ_thread"; 60 bool IsGoogleUrl(const GURL& url) {
61 return google_util::IsGoogleHomePageUrl(url.possibly_invalid_spec());
62 }
60 63
61 bool IsBrandOrganic(const std::string& brand) { 64 bool IsBrandOrganic(const std::string& brand) {
62 return brand.empty() || google_util::IsOrganic(brand); 65 return brand.empty() || google_util::IsOrganic(brand);
63 } 66 }
64 67
65 void RecordProductEvents(bool first_run, 68 void RecordProductEvents(bool first_run,
66 bool is_google_default_search, 69 bool is_google_default_search,
67 bool is_google_homepage, 70 bool is_google_homepage,
68 bool is_google_in_startpages, 71 bool is_google_in_startpages,
69 bool already_ran, 72 bool already_ran,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 RLZTracker* RLZTracker::GetInstance() { 173 RLZTracker* RLZTracker::GetInstance() {
171 return tracker_ ? tracker_ : Singleton<RLZTracker>::get(); 174 return tracker_ ? tracker_ : Singleton<RLZTracker>::get();
172 } 175 }
173 176
174 RLZTracker::RLZTracker() 177 RLZTracker::RLZTracker()
175 : first_run_(false), 178 : first_run_(false),
176 send_ping_immediately_(false), 179 send_ping_immediately_(false),
177 is_google_default_search_(false), 180 is_google_default_search_(false),
178 is_google_homepage_(false), 181 is_google_homepage_(false),
179 is_google_in_startpages_(false), 182 is_google_in_startpages_(false),
180 rlz_thread_(kRlzThreadName),
181 blocking_task_runner_(NULL),
182 url_request_context_(NULL),
183 already_ran_(false), 183 already_ran_(false),
184 omnibox_used_(false), 184 omnibox_used_(false),
185 homepage_used_(false) { 185 homepage_used_(false) {
186 } 186 }
187 187
188 RLZTracker::~RLZTracker() { 188 RLZTracker::~RLZTracker() {
189 } 189 }
190 190
191 // static 191 // static
192 bool RLZTracker::InitRlzDelayed(bool first_run, 192 bool RLZTracker::InitRlzDelayed(bool first_run,
193 int delay, 193 int delay,
194 bool is_google_default_search, 194 bool is_google_default_search,
195 bool is_google_homepage, 195 bool is_google_homepage,
196 bool is_google_in_startpages) { 196 bool is_google_in_startpages) {
197 return GetInstance()->Init(first_run, delay, is_google_default_search, 197 return GetInstance()->Init(first_run, delay, is_google_default_search,
198 is_google_homepage, is_google_in_startpages); 198 is_google_homepage, is_google_in_startpages);
199 } 199 }
200 200
201 // static
202 bool RLZTracker::InitRlzFromProfileDelayed(Profile* profile,
203 bool first_run,
204 int delay) {
205 bool is_google_default_search = false;
206 TemplateURLService* template_url_service =
207 TemplateURLServiceFactory::GetForProfile(profile);
208 if (template_url_service) {
209 const TemplateURL* url_template =
210 template_url_service->GetDefaultSearchProvider();
211 is_google_default_search =
212 url_template && url_template->url_ref().HasGoogleBaseURLs();
213 }
214
215 PrefService* pref_service = profile->GetPrefs();
216 bool is_google_homepage = google_util::IsGoogleHomePageUrl(
217 pref_service->GetString(prefs::kHomePage));
218
219 bool is_google_in_startpages = false;
220 SessionStartupPref session_startup_prefs =
221 StartupBrowserCreator::GetSessionStartupPref(
222 *CommandLine::ForCurrentProcess(), profile);
223 if (session_startup_prefs.type == SessionStartupPref::URLS) {
224 is_google_in_startpages = std::count_if(session_startup_prefs.urls.begin(),
225 session_startup_prefs.urls.end(),
226 IsGoogleUrl) > 0;
227 }
228
229 if (!InitRlzDelayed(first_run, delay,
230 is_google_default_search, is_google_homepage,
231 is_google_in_startpages)) {
232 return false;
233 }
234
235 // Prime the RLZ cache for the home page access point so that its avaiable
236 // for the startup page if needed (i.e., when the startup page is set to
237 // the home page).
238 GetAccessPointRlz(CHROME_HOME_PAGE, NULL);
239
240 return true;
241 }
242
201 bool RLZTracker::Init(bool first_run, 243 bool RLZTracker::Init(bool first_run,
202 int delay, 244 int delay,
203 bool is_google_default_search, 245 bool is_google_default_search,
204 bool is_google_homepage, 246 bool is_google_homepage,
205 bool is_google_in_startpages) { 247 bool is_google_in_startpages) {
206 first_run_ = first_run; 248 first_run_ = first_run;
207 is_google_default_search_ = is_google_default_search; 249 is_google_default_search_ = is_google_default_search;
208 is_google_homepage_ = is_google_homepage; 250 is_google_homepage_ = is_google_homepage;
209 is_google_in_startpages_ = is_google_in_startpages; 251 is_google_in_startpages_ = is_google_in_startpages;
210 252
211 if (!InitWorkers())
212 return false;
213
214 // A negative delay means that a financial ping should be sent immediately 253 // A negative delay means that a financial ping should be sent immediately
215 // after a first search is recorded, without waiting for the next restart 254 // after a first search is recorded, without waiting for the next restart
216 // of chrome. However, we only want this behaviour on first run. 255 // of chrome. However, we only want this behaviour on first run.
217 send_ping_immediately_ = false; 256 send_ping_immediately_ = false;
218 if (delay < 0) { 257 if (delay < 0) {
219 send_ping_immediately_ = true; 258 send_ping_immediately_ = true;
220 delay = -delay; 259 delay = -delay;
221 } 260 }
222 261
223 // Maximum and minimum delay we would allow to be set through master 262 // Maximum and minimum delay we would allow to be set through master
224 // preferences. Somewhat arbitrary, may need to be adjusted in future. 263 // preferences. Somewhat arbitrary, may need to be adjusted in future.
225 const int kMaxDelay = 200 * 1000; 264 const int kMaxDelay = 200 * 1000;
226 const int kMinDelay = 20 * 1000; 265 const int kMinDelay = 20 * 1000;
227 266
228 delay *= 1000; 267 delay *= 1000;
229 delay = (delay < kMinDelay) ? kMinDelay : delay; 268 delay = (delay < kMinDelay) ? kMinDelay : delay;
230 delay = (delay > kMaxDelay) ? kMaxDelay : delay; 269 delay = (delay > kMaxDelay) ? kMaxDelay : delay;
231 270
232 std::string brand; 271 if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) {
233 if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand)) {
234 // Register for notifications from the omnibox so that we can record when 272 // Register for notifications from the omnibox so that we can record when
235 // the user performs a first search. 273 // the user performs a first search.
236 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 274 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
237 content::NotificationService::AllSources()); 275 content::NotificationService::AllSources());
238 // If instant is enabled we'll start searching as soon as the user starts 276 // If instant is enabled we'll start searching as soon as the user starts
239 // typing in the omnibox (which triggers INSTANT_CONTROLLER_UPDATED). 277 // typing in the omnibox (which triggers INSTANT_CONTROLLER_UPDATED).
240 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, 278 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED,
241 content::NotificationService::AllSources()); 279 content::NotificationService::AllSources());
242 280
243 // Register for notifications from navigations, to see if the user has used 281 // Register for notifications from navigations, to see if the user has used
244 // the home page. 282 // the home page.
245 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 283 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
246 content::NotificationService::AllSources()); 284 content::NotificationService::AllSources());
247 } 285 }
286 google_util::GetReactivationBrand(&reactivation_brand_);
248 287
249 url_request_context_ = g_browser_process->system_request_context(); 288 rlz_lib::SetURLRequestContext(g_browser_process->system_request_context());
250 ScheduleDelayedInit(delay); 289 ScheduleDelayedInit(delay);
251 290
252 return true; 291 return true;
253 } 292 }
254 293
255 void RLZTracker::ScheduleDelayedInit(int delay) { 294 void RLZTracker::ScheduleDelayedInit(int delay) {
256 // The RLZTracker is a singleton object that outlives any runnable tasks 295 // The RLZTracker is a singleton object that outlives any runnable tasks
257 // that will be queued up. 296 // that will be queued up.
258 blocking_task_runner_->PostDelayedTask( 297 BrowserThread::GetBlockingPool()->PostDelayedTask(
259 FROM_HERE, 298 FROM_HERE,
260 base::Bind(&RLZTracker::DelayedInit, base::Unretained(this)), 299 base::Bind(&RLZTracker::DelayedInit, base::Unretained(this)),
261 base::TimeDelta::FromMilliseconds(delay)); 300 base::TimeDelta::FromMilliseconds(delay));
262 } 301 }
263 302
264 bool RLZTracker::InitWorkers() {
265 base::Thread::Options options;
266 options.message_loop_type = MessageLoop::TYPE_IO;
267 if (!rlz_thread_.StartWithOptions(options))
268 return false;
269 blocking_task_runner_ = rlz_thread_.message_loop_proxy();
270
271 #if defined(OS_CHROMEOS)
272 base::SequencedWorkerPool* worker_pool =
273 content::BrowserThread::GetBlockingPool();
274 if (!worker_pool)
275 return false;
276 rlz_lib::SetIOTaskRunner(
277 worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
278 worker_pool->GetSequenceToken(),
279 base::SequencedWorkerPool::BLOCK_SHUTDOWN));
280 #endif
281 return true;
282 }
283
284 void RLZTracker::DelayedInit() { 303 void RLZTracker::DelayedInit() {
285 if (!already_ran_) 304 worker_pool_token_ = BrowserThread::GetBlockingPool()->GetSequenceToken();
286 rlz_lib::SetURLRequestContext(url_request_context_);
287 305
288 bool schedule_ping = false; 306 bool schedule_ping = false;
289 307
290 // For organic brandcodes do not use rlz at all. Empty brandcode usually 308 // For organic brandcodes do not use rlz at all. Empty brandcode usually
291 // means a chromium install. This is ok. 309 // means a chromium install. This is ok.
292 std::string brand; 310 if (!IsBrandOrganic(brand_)) {
293 if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand)) {
294 RecordProductEvents(first_run_, is_google_default_search_, 311 RecordProductEvents(first_run_, is_google_default_search_,
295 is_google_homepage_, is_google_in_startpages_, 312 is_google_homepage_, is_google_in_startpages_,
296 already_ran_, omnibox_used_, homepage_used_); 313 already_ran_, omnibox_used_, homepage_used_);
297 schedule_ping = true; 314 schedule_ping = true;
298 } 315 }
299 316
300 // If chrome has been reactivated, record the events for this brand 317 // If chrome has been reactivated, record the events for this brand
301 // as well. 318 // as well.
302 std::string reactivation_brand; 319 if (!IsBrandOrganic(reactivation_brand_)) {
303 if (google_util::GetReactivationBrand(&reactivation_brand) && 320 rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str());
304 !IsBrandOrganic(reactivation_brand)) {
305 rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str());
306 RecordProductEvents(first_run_, is_google_default_search_, 321 RecordProductEvents(first_run_, is_google_default_search_,
307 is_google_homepage_, is_google_in_startpages_, 322 is_google_homepage_, is_google_in_startpages_,
308 already_ran_, omnibox_used_, homepage_used_); 323 already_ran_, omnibox_used_, homepage_used_);
309 schedule_ping = true; 324 schedule_ping = true;
310 } 325 }
311 326
312 already_ran_ = true; 327 already_ran_ = true;
313 328
314 if (schedule_ping) 329 if (schedule_ping)
315 ScheduleFinancialPing(); 330 ScheduleFinancialPing();
316 } 331 }
317 332
318 void RLZTracker::ScheduleFinancialPing() { 333 void RLZTracker::ScheduleFinancialPing() {
319 blocking_task_runner_->PostTask( 334 BrowserThread::GetBlockingPool()->PostSequencedWorkerTask(
335 worker_pool_token_,
320 FROM_HERE, 336 FROM_HERE,
321 base::Bind(&RLZTracker::PingNowImpl, base::Unretained(this))); 337 base::Bind(&RLZTracker::PingNowImpl, base::Unretained(this)));
322 } 338 }
323 339
324 void RLZTracker::PingNowImpl() { 340 void RLZTracker::PingNowImpl() {
325 TRACE_EVENT0("RLZ", "RLZTracker::PingNowImpl"); 341 TRACE_EVENT0("RLZ", "RLZTracker::PingNowImpl");
326 string16 lang; 342 string16 lang;
327 GoogleUpdateSettings::GetLanguage(&lang); 343 GoogleUpdateSettings::GetLanguage(&lang);
328 if (lang.empty()) 344 if (lang.empty())
329 lang = ASCIIToUTF16("en"); 345 lang = ASCIIToUTF16("en");
330 string16 referral; 346 string16 referral;
331 GoogleUpdateSettings::GetReferral(&referral); 347 GoogleUpdateSettings::GetReferral(&referral);
332 348
333 std::string brand; 349 if (!IsBrandOrganic(brand_) && SendFinancialPing(brand_, lang, referral)) {
334 if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand) &&
335 SendFinancialPing(brand, lang, referral)) {
336 GoogleUpdateSettings::ClearReferral(); 350 GoogleUpdateSettings::ClearReferral();
337 351
338 { 352 {
339 base::AutoLock lock(cache_lock_); 353 base::AutoLock lock(cache_lock_);
340 rlz_cache_.clear(); 354 rlz_cache_.clear();
341 } 355 }
342 356
343 // Prime the RLZ cache for the access points we are interested in. 357 // Prime the RLZ cache for the access points we are interested in.
344 GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, NULL); 358 GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, NULL);
345 GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL); 359 GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL);
346 } 360 }
347 361
348 std::string reactivation_brand; 362 if (!IsBrandOrganic(reactivation_brand_)) {
349 if (google_util::GetReactivationBrand(&reactivation_brand) && 363 rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str());
350 !IsBrandOrganic(reactivation_brand)) { 364 SendFinancialPing(reactivation_brand_, lang, referral);
351 rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str());
352 SendFinancialPing(reactivation_brand, lang, referral);
353 } 365 }
354 } 366 }
355 367
356 bool RLZTracker::SendFinancialPing(const std::string& brand, 368 bool RLZTracker::SendFinancialPing(const std::string& brand,
357 const string16& lang, 369 const string16& lang,
358 const string16& referral) { 370 const string16& referral) {
359 return ::SendFinancialPing(brand, lang, referral); 371 return ::SendFinancialPing(brand, lang, referral);
360 } 372 }
361 373
362 void RLZTracker::Observe(int type, 374 void RLZTracker::Observe(int type,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 rlz_lib::AccessPoint point, 412 rlz_lib::AccessPoint point,
401 rlz_lib::Event event_id) { 413 rlz_lib::Event event_id) {
402 // Make sure we don't access disk outside of the I/O thread. 414 // Make sure we don't access disk outside of the I/O thread.
403 // In such case we repost the task on the right thread and return error. 415 // In such case we repost the task on the right thread and return error.
404 if (ScheduleRecordProductEvent(product, point, event_id)) 416 if (ScheduleRecordProductEvent(product, point, event_id))
405 return true; 417 return true;
406 418
407 bool ret = rlz_lib::RecordProductEvent(product, point, event_id); 419 bool ret = rlz_lib::RecordProductEvent(product, point, event_id);
408 420
409 // If chrome has been reactivated, record the event for this brand as well. 421 // If chrome has been reactivated, record the event for this brand as well.
410 std::string reactivation_brand; 422 if (!reactivation_brand_.empty()) {
411 if (google_util::GetReactivationBrand(&reactivation_brand)) { 423 rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str());
412 rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str());
413 ret &= rlz_lib::RecordProductEvent(product, point, event_id); 424 ret &= rlz_lib::RecordProductEvent(product, point, event_id);
414 } 425 }
415 426
416 return ret; 427 return ret;
417 } 428 }
418 429
419 bool RLZTracker::ScheduleRecordProductEvent(rlz_lib::Product product, 430 bool RLZTracker::ScheduleRecordProductEvent(rlz_lib::Product product,
420 rlz_lib::AccessPoint point, 431 rlz_lib::AccessPoint point,
421 rlz_lib::Event event_id) { 432 rlz_lib::Event event_id) {
422 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) 433 if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
423 return false; 434 return false;
424 if (!blocking_task_runner_) { 435 if (!already_ran_) {
425 LOG(ERROR) << "Attempted recording RLZ event before RLZ init."; 436 LOG(ERROR) << "Attempted recording RLZ event before RLZ init.";
426 return true; 437 return true;
427 } 438 }
428 439
429 blocking_task_runner_->PostTask( 440 BrowserThread::GetBlockingPool()->PostSequencedWorkerTask(
441 worker_pool_token_,
430 FROM_HERE, 442 FROM_HERE,
431 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), 443 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent),
432 product, point, event_id)); 444 product, point, event_id));
433 445
434 return true; 446 return true;
435 } 447 }
436 448
437 void RLZTracker::RecordFirstSearch(rlz_lib::AccessPoint point) { 449 void RLZTracker::RecordFirstSearch(rlz_lib::AccessPoint point) {
438 // Make sure we don't access disk outside of the I/O thread. 450 // Make sure we don't access disk outside of the I/O thread.
439 // In such case we repost the task on the right thread and return error. 451 // In such case we repost the task on the right thread and return error.
440 if (ScheduleRecordFirstSearch(point)) 452 if (ScheduleRecordFirstSearch(point))
441 return; 453 return;
442 454
443 bool* record_used = point == CHROME_OMNIBOX ? 455 bool* record_used = point == CHROME_OMNIBOX ?
444 &omnibox_used_ : &homepage_used_; 456 &omnibox_used_ : &homepage_used_;
445 457
446 // Try to record event now, else set the flag to try later when we 458 // Try to record event now, else set the flag to try later when we
447 // attempt the ping. 459 // attempt the ping.
448 if (!RecordProductEvent(rlz_lib::CHROME, point, rlz_lib::FIRST_SEARCH)) 460 if (!RecordProductEvent(rlz_lib::CHROME, point, rlz_lib::FIRST_SEARCH))
449 *record_used = true; 461 *record_used = true;
450 else if (send_ping_immediately_ && point == CHROME_OMNIBOX) 462 else if (send_ping_immediately_ && point == CHROME_OMNIBOX)
451 ScheduleDelayedInit(0); 463 ScheduleDelayedInit(0);
452 } 464 }
453 465
454 bool RLZTracker::ScheduleRecordFirstSearch(rlz_lib::AccessPoint point) { 466 bool RLZTracker::ScheduleRecordFirstSearch(rlz_lib::AccessPoint point) {
455 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) 467 if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
456 return false; 468 return false;
457 blocking_task_runner_->PostTask( 469 BrowserThread::GetBlockingPool()->PostSequencedWorkerTask(
470 worker_pool_token_,
458 FROM_HERE, 471 FROM_HERE,
459 base::Bind(&RLZTracker::RecordFirstSearch, 472 base::Bind(&RLZTracker::RecordFirstSearch,
460 base::Unretained(this), point)); 473 base::Unretained(this), point));
461 return true; 474 return true;
462 } 475 }
463 476
464 // static 477 // static
465 std::string RLZTracker::GetAccessPointHttpHeader(rlz_lib::AccessPoint point) { 478 std::string RLZTracker::GetAccessPointHttpHeader(rlz_lib::AccessPoint point) {
466 TRACE_EVENT0("RLZ", "RLZTracker::GetAccessPointHttpHeader"); 479 TRACE_EVENT0("RLZ", "RLZTracker::GetAccessPointHttpHeader");
467 std::string extra_headers; 480 std::string extra_headers;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 base::AutoLock lock(cache_lock_); 528 base::AutoLock lock(cache_lock_);
516 rlz_cache_[point] = rlz_local; 529 rlz_cache_[point] = rlz_local;
517 return true; 530 return true;
518 } 531 }
519 532
520 bool RLZTracker::ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) { 533 bool RLZTracker::ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) {
521 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) 534 if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
522 return false; 535 return false;
523 536
524 string16* not_used = NULL; 537 string16* not_used = NULL;
525 blocking_task_runner_->PostTask( 538 BrowserThread::GetBlockingPool()->PostSequencedWorkerTask(
539 worker_pool_token_,
526 FROM_HERE, 540 FROM_HERE,
527 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, 541 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point,
528 not_used)); 542 not_used));
529 return true; 543 return true;
530 } 544 }
531 545
532 // static 546 // static
533 void RLZTracker::CleanupRlz() { 547 void RLZTracker::CleanupRlz() {
534 GetInstance()->rlz_cache_.clear(); 548 GetInstance()->rlz_cache_.clear();
535 GetInstance()->registrar_.RemoveAll(); 549 GetInstance()->registrar_.RemoveAll();
536 } 550 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698