Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "remoting/host/win/session_action_executor.h" |
| 6 | |
| 7 | #include "base/bind.h" |
| 8 | #include "base/callback.h" |
| 9 | #include "base/location.h" |
| 10 | #include "base/macros.h" |
Patrick Monette | 643cdf6 | 2021-10-15 19:13:42 | [diff] [blame^] | 11 | #include "base/task/single_thread_task_runner.h" |
Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 12 | #include "remoting/proto/action.pb.h" |
| 13 | |
| 14 | namespace remoting { |
| 15 | |
| 16 | using protocol::ActionRequest; |
| 17 | |
| 18 | SessionActionExecutor::SessionActionExecutor( |
| 19 | scoped_refptr<base::SingleThreadTaskRunner> execute_action_task_runner, |
| 20 | const base::RepeatingClosure& inject_sas, |
| 21 | const base::RepeatingClosure& lock_workstation) |
| 22 | : execute_action_task_runner_(execute_action_task_runner), |
| 23 | inject_sas_(inject_sas), |
| 24 | lock_workstation_(lock_workstation) {} |
| 25 | |
| 26 | SessionActionExecutor::~SessionActionExecutor() = default; |
| 27 | |
| 28 | void SessionActionExecutor::ExecuteAction(const ActionRequest& request) { |
| 29 | DCHECK(request.has_action()); |
| 30 | |
| 31 | switch (request.action()) { |
Joe Downing | b511e4a9 | 2018-11-16 21:10:13 | [diff] [blame] | 32 | case ActionRequest::SEND_ATTENTION_SEQUENCE: |
Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 33 | execute_action_task_runner_->PostTask(FROM_HERE, inject_sas_); |
| 34 | break; |
| 35 | |
Joe Downing | b511e4a9 | 2018-11-16 21:10:13 | [diff] [blame] | 36 | case ActionRequest::LOCK_WORKSTATION: |
Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 37 | execute_action_task_runner_->PostTask(FROM_HERE, lock_workstation_); |
| 38 | break; |
| 39 | |
| 40 | default: |
| 41 | NOTREACHED() << "Unknown action type: " << request.action(); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | } // namespace remoting |