OLD | NEW |
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 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 RLZTracker* RLZTracker::GetInstance() { | 173 RLZTracker* RLZTracker::GetInstance() { |
174 return tracker_ ? tracker_ : Singleton<RLZTracker>::get(); | 174 return tracker_ ? tracker_ : Singleton<RLZTracker>::get(); |
175 } | 175 } |
176 | 176 |
177 RLZTracker::RLZTracker() | 177 RLZTracker::RLZTracker() |
178 : first_run_(false), | 178 : first_run_(false), |
179 send_ping_immediately_(false), | 179 send_ping_immediately_(false), |
180 is_google_default_search_(false), | 180 is_google_default_search_(false), |
181 is_google_homepage_(false), | 181 is_google_homepage_(false), |
182 is_google_in_startpages_(false), | 182 is_google_in_startpages_(false), |
| 183 worker_pool_token_(BrowserThread::GetBlockingPool()->GetSequenceToken()), |
183 already_ran_(false), | 184 already_ran_(false), |
184 omnibox_used_(false), | 185 omnibox_used_(false), |
185 homepage_used_(false) { | 186 homepage_used_(false) { |
186 } | 187 } |
187 | 188 |
188 RLZTracker::~RLZTracker() { | 189 RLZTracker::~RLZTracker() { |
189 } | 190 } |
190 | 191 |
191 // static | 192 // static |
192 bool RLZTracker::InitRlzDelayed(bool first_run, | 193 bool RLZTracker::InitRlzDelayed(bool first_run, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 288 |
288 rlz_lib::SetURLRequestContext(g_browser_process->system_request_context()); | 289 rlz_lib::SetURLRequestContext(g_browser_process->system_request_context()); |
289 ScheduleDelayedInit(delay); | 290 ScheduleDelayedInit(delay); |
290 | 291 |
291 return true; | 292 return true; |
292 } | 293 } |
293 | 294 |
294 void RLZTracker::ScheduleDelayedInit(int delay) { | 295 void RLZTracker::ScheduleDelayedInit(int delay) { |
295 // The RLZTracker is a singleton object that outlives any runnable tasks | 296 // The RLZTracker is a singleton object that outlives any runnable tasks |
296 // that will be queued up. | 297 // that will be queued up. |
297 BrowserThread::GetBlockingPool()->PostDelayedTask( | 298 BrowserThread::GetBlockingPool()->PostDelayedSequencedWorkerTask( |
| 299 worker_pool_token_, |
298 FROM_HERE, | 300 FROM_HERE, |
299 base::Bind(&RLZTracker::DelayedInit, base::Unretained(this)), | 301 base::Bind(&RLZTracker::DelayedInit, base::Unretained(this)), |
300 base::TimeDelta::FromMilliseconds(delay)); | 302 base::TimeDelta::FromMilliseconds(delay)); |
301 } | 303 } |
302 | 304 |
303 void RLZTracker::DelayedInit() { | 305 void RLZTracker::DelayedInit() { |
304 worker_pool_token_ = BrowserThread::GetBlockingPool()->GetSequenceToken(); | |
305 | |
306 bool schedule_ping = false; | 306 bool schedule_ping = false; |
307 | 307 |
308 // 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 |
309 // means a chromium install. This is ok. | 309 // means a chromium install. This is ok. |
310 if (!IsBrandOrganic(brand_)) { | 310 if (!IsBrandOrganic(brand_)) { |
311 RecordProductEvents(first_run_, is_google_default_search_, | 311 RecordProductEvents(first_run_, is_google_default_search_, |
312 is_google_homepage_, is_google_in_startpages_, | 312 is_google_homepage_, is_google_in_startpages_, |
313 already_ran_, omnibox_used_, homepage_used_); | 313 already_ran_, omnibox_used_, homepage_used_); |
314 schedule_ping = true; | 314 schedule_ping = true; |
315 } | 315 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 } | 425 } |
426 | 426 |
427 return ret; | 427 return ret; |
428 } | 428 } |
429 | 429 |
430 bool RLZTracker::ScheduleRecordProductEvent(rlz_lib::Product product, | 430 bool RLZTracker::ScheduleRecordProductEvent(rlz_lib::Product product, |
431 rlz_lib::AccessPoint point, | 431 rlz_lib::AccessPoint point, |
432 rlz_lib::Event event_id) { | 432 rlz_lib::Event event_id) { |
433 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) | 433 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) |
434 return false; | 434 return false; |
435 if (!already_ran_) { | |
436 LOG(ERROR) << "Attempted recording RLZ event before RLZ init."; | |
437 return true; | |
438 } | |
439 | 435 |
440 BrowserThread::GetBlockingPool()->PostSequencedWorkerTask( | 436 BrowserThread::GetBlockingPool()->PostSequencedWorkerTask( |
441 worker_pool_token_, | 437 worker_pool_token_, |
442 FROM_HERE, | 438 FROM_HERE, |
443 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), | 439 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), |
444 product, point, event_id)); | 440 product, point, event_id)); |
445 | 441 |
446 return true; | 442 return true; |
447 } | 443 } |
448 | 444 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, | 537 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, |
542 not_used)); | 538 not_used)); |
543 return true; | 539 return true; |
544 } | 540 } |
545 | 541 |
546 // static | 542 // static |
547 void RLZTracker::CleanupRlz() { | 543 void RLZTracker::CleanupRlz() { |
548 GetInstance()->rlz_cache_.clear(); | 544 GetInstance()->rlz_cache_.clear(); |
549 GetInstance()->registrar_.RemoveAll(); | 545 GetInstance()->registrar_.RemoveAll(); |
550 } | 546 } |
OLD | NEW |