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

Unified Diff: ui/ozone/platform/drm/gpu/proxy_helpers.h

Issue 1311043016: Switch DRM platform to using a separate thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mv-drm-calls-on-thread2
Patch Set: update & fix clang Created 5 years, 2 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 | « ui/ozone/platform/drm/gpu/gbm_surfaceless.cc ('k') | ui/ozone/platform/drm/gpu/proxy_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/platform/drm/gpu/proxy_helpers.h
diff --git a/ui/ozone/platform/drm/gpu/proxy_helpers.h b/ui/ozone/platform/drm/gpu/proxy_helpers.h
new file mode 100644
index 0000000000000000000000000000000000000000..e676c142582b403d1c5d7ad58d8cd1d3a50cc783
--- /dev/null
+++ b/ui/ozone/platform/drm/gpu/proxy_helpers.h
@@ -0,0 +1,45 @@
+// Copyright 2015 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 UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_
+#define UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/memory/ref_counted.h"
+#include "base/thread_task_runner_handle.h"
+
+namespace ui {
+
+namespace internal {
+
+template <typename... Args>
+void PostAsyncTask(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ const base::Callback<void(Args...)>& callback,
+ Args... args) {
+ task_runner->PostTask(FROM_HERE, base::Bind(callback, args...));
+}
+
+} // namespace internal
+
+// Posts a task to a different thread and blocks waiting for the task to finish
+// executing.
+void PostSyncTask(
+ const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
+ const base::Closure& callback);
+
+// Creates a callback that will run |callback| on the calling thread. Useful
+// when posting a task on a different thread and expecting a callback when the
+// task finished (and the callback needs to run on the original thread).
+template <typename... Args>
+base::Callback<void(Args...)> CreateSafeCallback(
+ const base::Callback<void(Args...)>& callback) {
+ return base::Bind(&internal::PostAsyncTask<Args...>,
+ base::ThreadTaskRunnerHandle::Get(), callback);
+}
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_DRM_GPU_PROXY_HELPERS_H_
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_surfaceless.cc ('k') | ui/ozone/platform/drm/gpu/proxy_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698