OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/desktop_session_agent.h" | 5 #include "remoting/host/desktop_session_agent.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/win/scoped_handle.h" | 11 #include "base/win/scoped_handle.h" |
12 #include "base/win/win_util.h" | 12 #include "base/win/win_util.h" |
13 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" |
14 #include "ipc/ipc_channel_proxy.h" | 14 #include "ipc/ipc_channel_proxy.h" |
15 #include "remoting/base/auto_thread_task_runner.h" | 15 #include "remoting/base/auto_thread_task_runner.h" |
16 #include "remoting/host/event_executor.h" | |
16 #include "remoting/host/win/launch_process_with_token.h" | 17 #include "remoting/host/win/launch_process_with_token.h" |
18 #include "remoting/host/win/session_event_executor.h" | |
17 | 19 |
18 using base::win::ScopedHandle; | 20 using base::win::ScopedHandle; |
19 | 21 |
20 namespace remoting { | 22 namespace remoting { |
21 | 23 |
22 // Provides screen/audio capturing and input injection services for | 24 // Provides screen/audio capturing and input injection services for |
23 // the network process. | 25 // the network process. |
24 class DesktopSessionAgentWin : public DesktopSessionAgent { | 26 class DesktopSessionAgentWin : public DesktopSessionAgent { |
25 public: | 27 public: |
26 DesktopSessionAgentWin( | 28 DesktopSessionAgentWin( |
27 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 29 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
28 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 30 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
29 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 31 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
30 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner); | 32 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner); |
31 | 33 |
32 protected: | 34 protected: |
33 virtual ~DesktopSessionAgentWin(); | 35 virtual ~DesktopSessionAgentWin(); |
34 | 36 |
35 virtual bool CreateChannelForNetworkProcess( | 37 virtual bool CreateChannelForNetworkProcess( |
36 IPC::PlatformFileForTransit* client_out, | 38 IPC::PlatformFileForTransit* client_out, |
37 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; | 39 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; |
40 virtual scoped_ptr<EventExecutor> CreateEventExecutor() OVERRIDE; | |
41 | |
42 // Requests the daemon to inject Secure Attention Sequence into the current | |
43 // session. | |
44 void InjectSas(); | |
38 | 45 |
39 private: | 46 private: |
40 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentWin); | 47 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentWin); |
41 }; | 48 }; |
42 | 49 |
43 DesktopSessionAgentWin::DesktopSessionAgentWin( | 50 DesktopSessionAgentWin::DesktopSessionAgentWin( |
44 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 51 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
45 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 52 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
46 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 53 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
47 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) | 54 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 if (!CreateConnectedIpcChannel(channel_name, security_descriptor, | 87 if (!CreateConnectedIpcChannel(channel_name, security_descriptor, |
81 io_task_runner(), this, &client, &server)) { | 88 io_task_runner(), this, &client, &server)) { |
82 return false; | 89 return false; |
83 } | 90 } |
84 | 91 |
85 *client_out = client.Take(); | 92 *client_out = client.Take(); |
86 *server_out = server.Pass(); | 93 *server_out = server.Pass(); |
87 return true; | 94 return true; |
88 } | 95 } |
89 | 96 |
97 scoped_ptr<EventExecutor> DesktopSessionAgentWin::CreateEventExecutor() { | |
98 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | |
99 | |
100 scoped_ptr<EventExecutor> event_executor = | |
101 EventExecutor::Create(input_task_runner(), caller_task_runner()); | |
102 event_executor.reset(new SessionEventExecutorWin( | |
103 input_task_runner(), event_executor.Pass(), caller_task_runner(), | |
104 base::Bind(&DesktopSessionAgentWin::InjectSas, this))); | |
105 return event_executor.Pass(); | |
106 } | |
107 | |
108 void DesktopSessionAgentWin::InjectSas() { | |
109 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | |
110 | |
111 if (delegate()) { | |
112 delegate()->InjectSas(); | |
113 } | |
Jamie
2012/12/06 21:42:25
Should there be an error log if there's no delegat
alexeypa (please no reviews)
2012/12/06 21:56:02
Nope, this case happen when shutting down DesktopS
| |
114 } | |
115 | |
90 // static | 116 // static |
91 scoped_refptr<DesktopSessionAgent> DesktopSessionAgent::Create( | 117 scoped_refptr<DesktopSessionAgent> DesktopSessionAgent::Create( |
92 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 118 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
93 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 119 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
94 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 120 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
95 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) { | 121 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) { |
96 return scoped_refptr<DesktopSessionAgent>(new DesktopSessionAgentWin( | 122 return scoped_refptr<DesktopSessionAgent>(new DesktopSessionAgentWin( |
97 caller_task_runner, input_task_runner, io_task_runner, | 123 caller_task_runner, input_task_runner, io_task_runner, |
98 video_capture_task_runner)); | 124 video_capture_task_runner)); |
99 } | 125 } |
100 | 126 |
101 } // namespace remoting | 127 } // namespace remoting |
OLD | NEW |