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

Unified Diff: base/thread_main_task_runner.h

Issue 10210008: Make MessageLoopProxy::current() usable on threads that don't have MessageLoop. (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 | « base/message_loop_unittest.cc ('k') | base/thread_main_task_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/thread_main_task_runner.h
diff --git a/base/thread_main_task_runner.h b/base/thread_main_task_runner.h
new file mode 100644
index 0000000000000000000000000000000000000000..8a65cc9688d70d944e7a1cbd9abc6741a474035c
--- /dev/null
+++ b/base/thread_main_task_runner.h
@@ -0,0 +1,39 @@
+// Copyright (c) 2012 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.
+
+#ifndef BASE_THREAD_MAIN_TASK_RUNNER_H_
+#define BASE_THREAD_MAIN_TASK_RUNNER_H_
+#pragma once
+
+#include "base/base_export.h"
+#include "base/single_thread_task_runner.h"
+
+namespace base {
+
+// ThreadMainTaskRunner is a SingleThreadTaskRunner that is used for
+// the main task runner of a thread. There should never be more than
+// one object implementing this interface per thread. It provides
+// static current() method that returns the instance of this interface
+// that corresponds to the current thread.
+class BASE_EXPORT ThreadMainTaskRunner : public SingleThreadTaskRunner {
+ public:
+ // Gets the ThreadMainTaskRunner for the current thread.
+ static scoped_refptr<ThreadMainTaskRunner> current();
+
+ ThreadMainTaskRunner();
+
+ protected:
+ virtual ~ThreadMainTaskRunner();
+
+ // This method must be called on the thread this object belongs to
+ // before the thread and this object are destroyed.
+ void Detach();
+
+ private:
+ bool detached_;
+};
+
+} // namespace base
+
+#endif // BASE_THREAD_MAIN_TASK_RUNNER_H_
« no previous file with comments | « base/message_loop_unittest.cc ('k') | base/thread_main_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698