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

Unified Diff: chrome/browser/chrome_thread.cc

Issue 1800008: Created a MessageLoopProxy interface. This provides a thread-safe refcounted ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | « chrome/browser/chrome_thread.h ('k') | chrome/browser/chrome_thread_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_thread.cc
===================================================================
--- chrome/browser/chrome_thread.cc (revision 45861)
+++ chrome/browser/chrome_thread.cc (working copy)
@@ -5,6 +5,7 @@
#include "chrome/browser/chrome_thread.h"
#include "base/message_loop.h"
+#include "base/message_loop_proxy.h"
// Friendly names for the well-known threads.
static const char* chrome_thread_names[ChromeThread::ID_COUNT] = {
@@ -19,6 +20,44 @@
#endif
};
+// An implementation of MessageLoopProxy to be used in conjunction
+// with ChromeThread.
+class ChromeThreadMessageLoopProxy : public MessageLoopProxy {
+ public:
+ explicit ChromeThreadMessageLoopProxy(ChromeThread::ID identifier)
+ : id_(identifier) {
+ }
+
+ // MessageLoopProxy implementation.
+ virtual bool PostTask(const tracked_objects::Location& from_here,
+ Task* task) {
+ return ChromeThread::PostTask(id_, from_here, task);
+ }
+
+ virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
+ Task* task, int64 delay_ms) {
+ return ChromeThread::PostDelayedTask(id_, from_here, task, delay_ms);
+ }
+
+ virtual bool PostNonNestableTask(const tracked_objects::Location& from_here,
+ Task* task) {
+ return ChromeThread::PostNonNestableTask(id_, from_here, task);
+ }
+
+ virtual bool PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ Task* task,
+ int64 delay_ms) {
+ return ChromeThread::PostNonNestableDelayedTask(id_, from_here, task,
+ delay_ms);
+ }
+
+ private:
+ ChromeThread::ID id_;
+ DISALLOW_COPY_AND_ASSIGN(ChromeThreadMessageLoopProxy);
+};
+
+
Lock ChromeThread::lock_;
ChromeThread* ChromeThread::chrome_threads_[ID_COUNT];
@@ -122,6 +161,14 @@
}
// static
+scoped_refptr<MessageLoopProxy> ChromeThread::GetMessageLoopProxyForThread(
+ ID identifier) {
+ scoped_refptr<MessageLoopProxy> proxy =
+ new ChromeThreadMessageLoopProxy(identifier);
+ return proxy;
+}
+
+// static
bool ChromeThread::PostTaskHelper(
ID identifier,
const tracked_objects::Location& from_here,
« no previous file with comments | « chrome/browser/chrome_thread.h ('k') | chrome/browser/chrome_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698