Index: chrome/browser/rlz/rlz.cc |
diff --git a/chrome/browser/rlz/rlz.cc b/chrome/browser/rlz/rlz.cc |
index e0798fc2ec61534f52b70cf1d410367ade6d47dc..6b0bf2472250e242e7e7067475ecb73c637214f2 100644 |
--- a/chrome/browser/rlz/rlz.cc |
+++ b/chrome/browser/rlz/rlz.cc |
@@ -1,4 +1,4 @@ |
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
// |
@@ -22,6 +22,7 @@ |
#include "base/threading/thread_restrictions.h" |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/browser_thread.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/search_engines/template_url.h" |
@@ -285,6 +286,25 @@ bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point, |
*rlz = cached_ommibox_rlz; |
return true; |
} |
+ |
+ // Make sure we don't access disk outside of the file context. |
+ // In such case we repost the task on the right thread and return error. |
+ if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
+ // Caching of access points is now only implemented for the CHROME_OMNIBOX. |
+ // Thus it is not possible to call this function on another thread for |
+ // other access points until proper caching for these has been implemented |
+ // and the code that calls this function can handle synchronous fetching |
+ // of the access point. |
+ DCHECK_EQ(rlz_lib::CHROME_OMNIBOX, point); |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ NewRunnableFunction(&RLZTracker::GetAccessPointRlz, |
+ point, &cached_ommibox_rlz)); |
+ rlz->erase(); |
+ return false; |
+ } |
+ |
char str_rlz[kMaxRlzLength + 1]; |
if (!rlz_lib::GetAccessPointRlz(point, str_rlz, rlz_lib::kMaxRlzLength, NULL)) |
return false; |