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

Side by Side Diff: ui/ozone/platform/drm/gpu/proxy_helpers.h

Issue 2873153005: Revert of Update ozone/drm proxy_helpers.h to support move-only types. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/drm/BUILD.gn ('k') | ui/ozone/platform/drm/gpu/proxy_helpers_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_ 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_
6 #define UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_ 6 #define UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 12
13 namespace ui { 13 namespace ui {
14 14
15 namespace internal { 15 namespace internal {
16 16
17 template <typename... Args> 17 template <typename... Args>
18 void PostAsyncTask( 18 void PostAsyncTask(
19 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 19 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
20 const base::Callback<void(Args...)>& callback, 20 const base::Callback<void(Args...)>& callback,
21 Args... args) { 21 Args... args) {
22 task_runner->PostTask(FROM_HERE, base::Bind(callback, args...)); 22 task_runner->PostTask(FROM_HERE, base::Bind(callback, args...));
23 } 23 }
24 24
25 template <typename... Args>
26 void PostAsyncTaskOnce(
27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
28 base::OnceCallback<void(Args...)> callback,
29 Args... args) {
30 auto closure = base::BindOnce(std::move(callback), std::move(args)...);
31 task_runner->PostTask(FROM_HERE, std::move(closure));
32 }
33
34 } // namespace internal 25 } // namespace internal
35 26
36 // Posts a task to a different thread and blocks waiting for the task to finish 27 // Posts a task to a different thread and blocks waiting for the task to finish
37 // executing. 28 // executing.
38 void PostSyncTask( 29 void PostSyncTask(
39 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 30 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
40 const base::Closure& callback); 31 const base::Closure& callback);
41 32
42 // Creates a callback that will run |callback| on the calling thread. Useful 33 // Creates a callback that will run |callback| on the calling thread. Useful
43 // when posting a task on a different thread and expecting a callback when the 34 // when posting a task on a different thread and expecting a callback when the
44 // task finished (and the callback needs to run on the original thread). 35 // task finished (and the callback needs to run on the original thread).
45 template <typename... Args> 36 template <typename... Args>
46 base::Callback<void(Args...)> CreateSafeCallback( 37 base::Callback<void(Args...)> CreateSafeCallback(
47 const base::Callback<void(Args...)>& callback) { 38 const base::Callback<void(Args...)>& callback) {
48 return base::Bind(&internal::PostAsyncTask<Args...>, 39 return base::Bind(&internal::PostAsyncTask<Args...>,
49 base::ThreadTaskRunnerHandle::Get(), callback); 40 base::ThreadTaskRunnerHandle::Get(), callback);
50 } 41 }
51 42
52 // Creates a OnceCallback that will run |callback| on the calling thread. Useful
53 // when posting a task on a different thread and expecting a callback when the
54 // task finished (and the callback needs to run on the original thread).
55 template <typename... Args>
56 base::OnceCallback<void(Args...)> CreateSafeOnceCallback(
57 base::OnceCallback<void(Args...)> callback) {
58 return base::BindOnce(&internal::PostAsyncTaskOnce<Args...>,
59 base::ThreadTaskRunnerHandle::Get(),
60 std::move(callback));
61 }
62
63 } // namespace ui 43 } // namespace ui
64 44
65 #endif // UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_ 45 #endif // UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/BUILD.gn ('k') | ui/ozone/platform/drm/gpu/proxy_helpers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698