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

Unified Diff: content/browser/browser_thread_impl.cc

Issue 1131513007: Reland (3rd try): Lazily initialize MessageLoop for faster thread startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unnecessary include Created 5 years, 7 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 | « content/browser/browser_thread_impl.h ('k') | content/public/browser/browser_thread_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_thread_impl.cc
diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc
index 78e3836dadeef038f5db6e1a7fd0b1a3352fd8b6..1aac305bcb8b2a05e247276c36b77c54e9e98c34 100644
--- a/content/browser/browser_thread_impl.cc
+++ b/content/browser/browser_thread_impl.cc
@@ -159,14 +159,8 @@ void BrowserThreadImpl::Init() {
AtomicWord stored_pointer = base::subtle::NoBarrier_Load(storage);
BrowserThreadDelegate* delegate =
reinterpret_cast<BrowserThreadDelegate*>(stored_pointer);
- if (delegate) {
+ if (delegate)
delegate->Init();
- message_loop()->PostTask(FROM_HERE,
- base::Bind(&BrowserThreadDelegate::InitAsync,
- // Delegate is expected to exist for the
- // duration of the thread's lifetime
- base::Unretained(delegate)));
- }
}
// We disable optimizations for this block of functions so the compiler doesn't
@@ -300,6 +294,15 @@ BrowserThreadImpl::~BrowserThreadImpl() {
#endif
}
+bool BrowserThreadImpl::StartWithOptions(const Options& options) {
+ // The global thread table needs to be locked while a new thread is
+ // starting, as the new thread can asynchronously start touching the
+ // table (and other thread's message_loop).
+ BrowserThreadGlobals& globals = g_globals.Get();
+ base::AutoLock lock(globals.lock);
+ return Thread::StartWithOptions(options);
+}
+
// static
bool BrowserThreadImpl::PostTaskHelper(
BrowserThread::ID identifier,
« no previous file with comments | « content/browser/browser_thread_impl.h ('k') | content/public/browser/browser_thread_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698