Avi Drissman | d6cdf9b | 2022-09-15 19:52:53 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors |
Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 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" |
Patrick Monette | 643cdf6 | 2021-10-15 19:13:42 | [diff] [blame] | 10 | #include "base/task/single_thread_task_runner.h" |
Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 11 | #include "remoting/proto/action.pb.h" |
| 12 | |
| 13 | namespace remoting { |
| 14 | |
| 15 | using protocol::ActionRequest; |
| 16 | |
| 17 | SessionActionExecutor::SessionActionExecutor( |
| 18 | scoped_refptr<base::SingleThreadTaskRunner> execute_action_task_runner, |
| 19 | const base::RepeatingClosure& inject_sas, |
| 20 | const base::RepeatingClosure& lock_workstation) |
| 21 | : execute_action_task_runner_(execute_action_task_runner), |
| 22 | inject_sas_(inject_sas), |
| 23 | lock_workstation_(lock_workstation) {} |
| 24 | |
| 25 | SessionActionExecutor::~SessionActionExecutor() = default; |
| 26 | |
| 27 | void SessionActionExecutor::ExecuteAction(const ActionRequest& request) { |
| 28 | DCHECK(request.has_action()); |
| 29 | |
| 30 | switch (request.action()) { |
Joe Downing | b511e4a9 | 2018-11-16 21:10:13 | [diff] [blame] | 31 | case ActionRequest::SEND_ATTENTION_SEQUENCE: |
Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 32 | execute_action_task_runner_->PostTask(FROM_HERE, inject_sas_); |
| 33 | break; |
| 34 | |
Joe Downing | b511e4a9 | 2018-11-16 21:10:13 | [diff] [blame] | 35 | case ActionRequest::LOCK_WORKSTATION: |
Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 36 | execute_action_task_runner_->PostTask(FROM_HERE, lock_workstation_); |
| 37 | break; |
| 38 | |
| 39 | default: |
| 40 | NOTREACHED() << "Unknown action type: " << request.action(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | } // namespace remoting |