summaryrefslogtreecommitdiffstats
path: root/remoting/base/plugin_thread_task_runner.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-27 20:57:05 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-27 20:57:05 +0000
commit89f96d350ac401bec3c108b0bf3f4c4a4634bba7 (patch)
tree49e8e5ffa2c0947de628fc64a6750cce23d61c7b /remoting/base/plugin_thread_task_runner.h
parentc7e526f86f0fc900b9f285da0dfd9dfc004c8fac (diff)
downloadchromium_src-89f96d350ac401bec3c108b0bf3f4c4a4634bba7.zip
chromium_src-89f96d350ac401bec3c108b0bf3f4c4a4634bba7.tar.gz
chromium_src-89f96d350ac401bec3c108b0bf3f4c4a4634bba7.tar.bz2
Replace PluginMessageLoopProxy with PluginThreadTaskRunner.
Previosly plugin code was using PluginMessageLoopProxy that implements MessageLoopProxy interface. We no longer need MessageLoopProxy. Replacing PluginMessageLoopProxy with PluginThreadTaskRunner that implements SingleThreadTaskRunner interface Review URL: https://chromiumcodereview.appspot.com/10830016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148801 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base/plugin_thread_task_runner.h')
-rw-r--r--remoting/base/plugin_thread_task_runner.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/remoting/base/plugin_thread_task_runner.h b/remoting/base/plugin_thread_task_runner.h
new file mode 100644
index 0000000..5ebafe1
--- /dev/null
+++ b/remoting/base/plugin_thread_task_runner.h
@@ -0,0 +1,64 @@
+// 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 REMOTING_BASE_PLUGIN_THREAD_TASK_RUNNER_H_
+#define REMOTING_BASE_PLUGIN_THREAD_TASK_RUNNER_H_
+
+#include "base/callback_forward.h"
+#include "base/compiler_specific.h"
+#include "base/single_thread_task_runner.h"
+#include "base/synchronization/lock.h"
+#include "base/threading/platform_thread.h"
+
+namespace remoting {
+
+// SingleThreadTaskRunner for plugin main threads.
+class PluginThreadTaskRunner : public base::SingleThreadTaskRunner {
+ public:
+ class Delegate {
+ public:
+ Delegate() { }
+ virtual ~Delegate() { }
+
+ virtual bool RunOnPluginThread(
+ base::TimeDelta delay, void(function)(void*), void* data) = 0;
+ };
+
+ // Caller keeps ownership of delegate.
+ PluginThreadTaskRunner(Delegate* delegate);
+
+ void Detach();
+
+ // base::SingleThreadTaskRunner interface.
+ virtual bool PostDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) OVERRIDE;
+ virtual bool PostNonNestableDelayedTask(
+ const tracked_objects::Location& from_here,
+ const base::Closure& task,
+ base::TimeDelta delay) OVERRIDE;
+
+ virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
+
+ protected:
+ virtual ~PluginThreadTaskRunner();
+
+ private:
+ static void TaskSpringboard(void* data);
+
+ void RunClosureIf(const base::Closure& task);
+
+ base::PlatformThreadId plugin_thread_id_;
+
+ // |lock_| must be acquired when accessing |delegate_|.
+ base::Lock lock_;
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginThreadTaskRunner);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_BASE_PLUGIN_THREAD_TASK_RUNNER_H_