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

Unified Diff: chrome/browser/autocomplete/history_url_provider.cc

Issue 9347030: Add DCHECK that HistoryURLProvider is on the main thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reformat comment. Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/history_url_provider.cc
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index d901d4d9aa74456f65ef1be8adf1400fd7037d61..9e6a8a9543829e8f6801e04d31fce0aff49d3d74 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -26,6 +26,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "content/public/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
#include "googleurl/src/url_parse.h"
#include "googleurl/src/url_util.h"
@@ -347,6 +348,17 @@ HistoryURLProvider::HistoryURLProvider(ACProviderListener* listener,
LOG(ERROR) << "Making automatic.";
}
// Automatic means eligible for the field trial.
+ // For the field trial stuff to work correctly, we must be running
+ // on the same thread as the thread that created the field trial,
+ // which happens via a call to AutocompleteFieldTrial::Active in
+ // chrome_browser_main.cc on the main thread. Let's check this to
+ // be sure. We check "if we've heard of the UI thread then we'd better
+ // be on it." The first part is necessary so unit tests pass. (Many
+ // unit tests don't set up the threading naming system; hence
+ // CurrentlyOn(UI thread) will fail.)
+ DCHECK(!content::BrowserThread::IsWellKnownThread(
+ content::BrowserThread::UI) ||
+ content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (AutocompleteFieldTrial::InAggressiveHUPFieldTrial()) {
if (AutocompleteFieldTrial::InAggressiveHUPFieldTrialExperimentGroup()) {
enable_aggressive_scoring_ = true;
« 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