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

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

Issue 6028012: Fixed RLZTracker::GetAccessPointRlz to route IO calls to the FILE thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/2010/2011/ Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 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 // 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 <windows.h> 11 #include <windows.h>
12 #include <process.h> 12 #include <process.h>
13 13
14 #include <algorithm> 14 #include <algorithm>
15 15
16 #include "base/file_path.h" 16 #include "base/file_path.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/task.h" 20 #include "base/task.h"
21 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
22 #include "base/threading/thread_restrictions.h" 22 #include "base/threading/thread_restrictions.h"
23 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/browser_thread.h"
25 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
26 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/search_engines/template_url.h" 28 #include "chrome/browser/search_engines/template_url.h"
28 #include "chrome/browser/search_engines/template_url_model.h" 29 #include "chrome/browser/search_engines/template_url_model.h"
29 #include "chrome/common/chrome_paths.h" 30 #include "chrome/common/chrome_paths.h"
30 #include "chrome/common/env_vars.h" 31 #include "chrome/common/env_vars.h"
31 #include "chrome/common/notification_registrar.h" 32 #include "chrome/common/notification_registrar.h"
32 #include "chrome/common/notification_service.h" 33 #include "chrome/common/notification_service.h"
33 #include "chrome/installer/util/google_update_settings.h" 34 #include "chrome/installer/util/google_update_settings.h"
34 35
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // cached value. 279 // cached value.
279 280
280 bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point, 281 bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point,
281 std::wstring* rlz) { 282 std::wstring* rlz) {
282 static std::wstring cached_ommibox_rlz; 283 static std::wstring cached_ommibox_rlz;
283 if ((rlz_lib::CHROME_OMNIBOX == point) && 284 if ((rlz_lib::CHROME_OMNIBOX == point) &&
284 (access_values_state == ACCESS_VALUES_FRESH)) { 285 (access_values_state == ACCESS_VALUES_FRESH)) {
285 *rlz = cached_ommibox_rlz; 286 *rlz = cached_ommibox_rlz;
286 return true; 287 return true;
287 } 288 }
289
290 // Make sure we don't access disk outside of the file context.
291 // In such case we repost the task on the right thread and return error.
292 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) {
293 // Caching of access points is now only implemented for the CHROME_OMNIBOX.
294 // Thus it is not possible to call this function on another thread for
295 // other access points until proper caching for these has been implemented
296 // and the code that calls this function can handle synchronous fetching
297 // of the access point.
298 DCHECK_EQ(rlz_lib::CHROME_OMNIBOX, point);
299
300 BrowserThread::PostTask(
301 BrowserThread::FILE, FROM_HERE,
302 NewRunnableFunction(&RLZTracker::GetAccessPointRlz,
303 point, &cached_ommibox_rlz));
304 rlz->erase();
305 return false;
306 }
307
288 char str_rlz[kMaxRlzLength + 1]; 308 char str_rlz[kMaxRlzLength + 1];
289 if (!rlz_lib::GetAccessPointRlz(point, str_rlz, rlz_lib::kMaxRlzLength, NULL)) 309 if (!rlz_lib::GetAccessPointRlz(point, str_rlz, rlz_lib::kMaxRlzLength, NULL))
290 return false; 310 return false;
291 *rlz = ASCIIToWide(std::string(str_rlz)); 311 *rlz = ASCIIToWide(std::string(str_rlz));
292 if (rlz_lib::CHROME_OMNIBOX == point) { 312 if (rlz_lib::CHROME_OMNIBOX == point) {
293 access_values_state = ACCESS_VALUES_FRESH; 313 access_values_state = ACCESS_VALUES_FRESH;
294 cached_ommibox_rlz.assign(*rlz); 314 cached_ommibox_rlz.assign(*rlz);
295 } 315 }
296 return true; 316 return true;
297 } 317 }
298 318
299 // static 319 // static
300 void RLZTracker::CleanupRlz() { 320 void RLZTracker::CleanupRlz() {
301 OmniBoxUsageObserver::DeleteInstance(); 321 OmniBoxUsageObserver::DeleteInstance();
302 } 322 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/search_engines/search_terms_data.cc » ('j') | chrome/browser/search_engines/search_terms_data.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698