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

Unified Diff: base/thread_task_runner_handle.h

Issue 10380016: Add base::ThreadTaskRunner class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
Index: base/thread_task_runner_handle.h
diff --git a/base/thread_task_runner_handle.h b/base/thread_task_runner_handle.h
new file mode 100644
index 0000000000000000000000000000000000000000..599d15bb52ffce3187aaeb575c2c805ca9aa6f5f
--- /dev/null
+++ b/base/thread_task_runner_handle.h
@@ -0,0 +1,35 @@
+// 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_TASK_RUNNER_HANDLE_H_
+#define BASE_THREAD_TASK_RUNNER_HANDLE_H_
+
+#include "base/base_export.h"
+#include "base/memory/ref_counted.h"
+
+namespace base {
+
+class SingleThreadTaskRunner;
+
+// ThreadTaskRunnerHandle stores a reference to the main task runner
+// for each thread. Not more than one of these objects can be created
+// per thread. After an instance of this object is created the Get()
+// function will return the |task_runner| specified in the
+// constructor.
+class BASE_EXPORT ThreadTaskRunnerHandle {
+ public:
+ // Gets the SingleThreadTaskRunner for the current thread.
+ static scoped_refptr<SingleThreadTaskRunner> Get();
+
+ ThreadTaskRunnerHandle(
+ const scoped_refptr<SingleThreadTaskRunner>& task_runner);
+ ~ThreadTaskRunnerHandle();
+
+ private:
+ scoped_refptr<SingleThreadTaskRunner> task_runner_;
+};
+
+} // namespace base
+
+#endif // BASE_THREAD_TASK_RUNNER_HANDLE_H_

Powered by Google App Engine
This is Rietveld 408576698