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

Unified Diff: content/browser/browser_thread_impl.cc

Issue 10291011: Remove BrowserThread-specific implementation of MessageLoopProxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | content/public/browser/browser_thread.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 297bb30d7cbbcc660439f6b19738ae13eea039b1..50108d9105044cdcc37aa2fb9fbe7882fe14d51a 100644
--- a/content/browser/browser_thread_impl.cc
+++ b/content/browser/browser_thread_impl.cc
@@ -175,53 +175,6 @@ bool BrowserThreadImpl::PostTaskHelper(
return !!message_loop;
}
-// An implementation of MessageLoopProxy to be used in conjunction
-// with BrowserThread.
-class BrowserThreadMessageLoopProxy : public base::MessageLoopProxy {
- public:
- explicit BrowserThreadMessageLoopProxy(BrowserThread::ID identifier)
- : id_(identifier) {
- }
-
- // MessageLoopProxy implementation.
- virtual bool PostDelayedTask(
- const tracked_objects::Location& from_here,
- const base::Closure& task, int64 delay_ms) OVERRIDE {
- return BrowserThread::PostDelayedTask(id_, from_here, task, delay_ms);
- }
- virtual bool PostDelayedTask(
- const tracked_objects::Location& from_here,
- const base::Closure& task, base::TimeDelta delay) OVERRIDE {
- return BrowserThread::PostDelayedTask(id_, from_here, task, delay);
- }
-
- virtual bool PostNonNestableDelayedTask(
- const tracked_objects::Location& from_here,
- const base::Closure& task,
- int64 delay_ms) OVERRIDE {
- return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task,
- delay_ms);
- }
- virtual bool PostNonNestableDelayedTask(
- const tracked_objects::Location& from_here,
- const base::Closure& task,
- base::TimeDelta delay) OVERRIDE {
- return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task,
- delay);
- }
-
- virtual bool RunsTasksOnCurrentThread() const OVERRIDE {
- return BrowserThread::CurrentlyOn(id_);
- }
-
- protected:
- virtual ~BrowserThreadMessageLoopProxy() {}
-
- private:
- BrowserThread::ID id_;
- DISALLOW_COPY_AND_ASSIGN(BrowserThreadMessageLoopProxy);
-};
-
// static
bool BrowserThread::PostBlockingPoolTask(
const tracked_objects::Location& from_here,
@@ -389,9 +342,30 @@ bool BrowserThread::GetCurrentThreadIdentifier(ID* identifier) {
// static
scoped_refptr<base::MessageLoopProxy>
BrowserThread::GetMessageLoopProxyForThread(ID identifier) {
- scoped_refptr<base::MessageLoopProxy> proxy(
- new BrowserThreadMessageLoopProxy(identifier));
- return proxy;
+ if (g_globals == NULL)
+ return NULL;
+
+ BrowserThread::ID current_thread;
+ bool guaranteed_to_outlive_target_thread =
+ GetCurrentThreadIdentifier(&current_thread) &&
+ current_thread <= identifier;
+
+ BrowserThreadGlobals& globals = g_globals.Get();
+ if (!guaranteed_to_outlive_target_thread)
+ globals.lock.Acquire();
+
+ base::Thread* thread = globals.threads[identifier];
+ if (!thread) {
+ if (!guaranteed_to_outlive_target_thread)
+ globals.lock.Release();
+ return NULL;
+ }
+ scoped_refptr<base::MessageLoopProxy> loop = thread->message_loop_proxy();
+
+ if (!guaranteed_to_outlive_target_thread)
+ globals.lock.Release();
+
+ return loop;
}
// static
« no previous file with comments | « no previous file | content/public/browser/browser_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698