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

Unified Diff: base/threading/task_runner_handle_internal.h

Issue 2042383004: Introduce TaskRunnerHandle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comments Created 4 years, 6 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/threading/task_runner_handle.cc ('k') | base/threading/task_runner_handle_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/task_runner_handle_internal.h
diff --git a/base/threading/task_runner_handle_internal.h b/base/threading/task_runner_handle_internal.h
new file mode 100644
index 0000000000000000000000000000000000000000..c26b14e2596523a1d96ca3c3dfb1a6256fc95bab
--- /dev/null
+++ b/base/threading/task_runner_handle_internal.h
@@ -0,0 +1,48 @@
+// Copyright 2016 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_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_
+#define BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+
+namespace base {
+
+class SequencedTaskRunner;
+class SingleThreadTaskRunner;
+class TaskRunner;
+
+namespace internal {
+
+// Holds the state associated with one of the TaskScope variants. Stores the
+// relevant pointer in a generic TaskRunner pointer and remembers the type
+// through an enum which makes for fast lookup of which levels of TaskRunners
+// are available.
+struct TaskScopeState {
+ TaskScopeState(scoped_refptr<TaskRunner> task_runner);
+ TaskScopeState(scoped_refptr<SequencedTaskRunner> sequenced_task_runner);
+ TaskScopeState(
+ scoped_refptr<SingleThreadTaskRunner> single_thread_task_runner);
+
+ ~TaskScopeState();
+
+ // TaskScope types sorted from least restrictive to most restrictive. Order
+ // is used for quick lookup of available TaskScope type on current thread.
+ enum Type { PARALLEL, SEQUENCED, SINGLE_THREADED };
+
+ const Type type;
+
+ // A generic TaskRunner to store the potentially more specific TaskRunner
+ // which can safely be upcasted if |type| allows.
+ const scoped_refptr<TaskRunner> task_runner;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TaskScopeState);
+};
+
+} // namespace internal
+} // namespace base
+
+#endif // BASE_THREADING_TASK_RUNNER_HANDLE_INTERNAL_H_
« no previous file with comments | « base/threading/task_runner_handle.cc ('k') | base/threading/task_runner_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698