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

Unified Diff: components/keyboard_lock/key_hook_activator_thread_proxy.cc

Issue 2879033002: Keyboard Lock Host implementation
Patch Set: Remove useless files Created 3 years, 4 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: components/keyboard_lock/key_hook_activator_thread_proxy.cc
diff --git a/components/keyboard_lock/key_hook_activator_thread_proxy.cc b/components/keyboard_lock/key_hook_activator_thread_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8ba8a759f8bedcc26efa4f915557bee117980ef6
--- /dev/null
+++ b/components/keyboard_lock/key_hook_activator_thread_proxy.cc
@@ -0,0 +1,75 @@
+// Copyright 2017 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.
+
+#include <utility>
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/logging.h"
+#include "components/keyboard_lock/key_hook_activator_thread_proxy.h"
+
+namespace keyboard_lock {
+
+KeyHookActivatorThreadProxy::KeyHookActivatorThreadProxy(
+ KeyHookActivator* const key_hook,
+ scoped_refptr<base::SingleThreadTaskRunner> runner)
+ : key_hook_(key_hook),
+ runner_(std::move(runner)) {
+ DCHECK(key_hook_);
+ DCHECK(runner_);
+}
+
+KeyHookActivatorThreadProxy::~KeyHookActivatorThreadProxy() = default;
+
+void KeyHookActivatorThreadProxy::RegisterKey(
+ const std::vector<ui::KeyboardCode>& codes,
+ base::Callback<void(bool)> on_result) {
+ runner_->PostTask(FROM_HERE,
+ base::Bind([](KeyHookActivator* const key_hook,
+ const std::vector<ui::KeyboardCode>& codes,
+ base::Callback<void(bool)> on_result) {
+ key_hook->RegisterKey(codes, std::move(on_result));
+ },
+ base::Unretained(key_hook_),
+ codes,
+ std::move(on_result)));
+}
+
+void KeyHookActivatorThreadProxy::UnregisterKey(
+ const std::vector<ui::KeyboardCode>& codes,
+ base::Callback<void(bool)> on_result) {
+ runner_->PostTask(FROM_HERE,
+ base::Bind([](KeyHookActivator* const key_hook,
+ const std::vector<ui::KeyboardCode>& codes,
+ base::Callback<void(bool)> on_result) {
+ key_hook->UnregisterKey(codes, std::move(on_result));
+ },
+ base::Unretained(key_hook_),
+ codes,
+ std::move(on_result)));
+}
+
+void KeyHookActivatorThreadProxy::Activate(
+ base::Callback<void(bool)> on_result) {
+ runner_->PostTask(FROM_HERE,
+ base::Bind([](KeyHookActivator* const key_hook,
+ base::Callback<void(bool)> on_result) {
+ key_hook->Activate(std::move(on_result));
+ },
+ base::Unretained(key_hook_),
+ std::move(on_result)));
+}
+
+void KeyHookActivatorThreadProxy::Deactivate(
+ base::Callback<void(bool)> on_result) {
+ runner_->PostTask(FROM_HERE,
+ base::Bind([](KeyHookActivator* const key_hook,
+ base::Callback<void(bool)> on_result) {
+ key_hook->Deactivate(std::move(on_result));
+ },
+ base::Unretained(key_hook_),
+ std::move(on_result)));
+}
+
+} // namespace keyboard_lock
« no previous file with comments | « components/keyboard_lock/key_hook_activator_thread_proxy.h ('k') | components/keyboard_lock/key_hook_share_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698