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" | |
17 #include "remoting/host/win/launch_process_with_token.h" | 16 #include "remoting/host/win/launch_process_with_token.h" |
18 #include "remoting/host/win/session_event_executor.h" | |
19 | 17 |
20 using base::win::ScopedHandle; | 18 using base::win::ScopedHandle; |
21 | 19 |
22 namespace remoting { | 20 namespace remoting { |
23 | 21 |
24 // Provides screen/audio capturing and input injection services for | 22 // Provides screen/audio capturing and input injection services for |
25 // the network process. | 23 // the network process. |
26 class DesktopSessionAgentWin : public DesktopSessionAgent { | 24 class DesktopSessionAgentWin : public DesktopSessionAgent { |
27 public: | 25 public: |
28 DesktopSessionAgentWin( | 26 DesktopSessionAgentWin( |
29 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, | 27 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, |
30 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 28 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
31 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 29 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
32 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 30 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
33 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner); | 31 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner); |
34 | 32 |
35 protected: | 33 protected: |
36 virtual ~DesktopSessionAgentWin(); | 34 virtual ~DesktopSessionAgentWin(); |
37 | 35 |
38 virtual bool CreateChannelForNetworkProcess( | 36 virtual bool CreateChannelForNetworkProcess( |
39 IPC::PlatformFileForTransit* client_out, | 37 IPC::PlatformFileForTransit* client_out, |
40 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; | 38 scoped_ptr<IPC::ChannelProxy>* server_out) OVERRIDE; |
41 virtual scoped_ptr<EventExecutor> CreateEventExecutor() OVERRIDE; | |
42 | |
43 // Requests the daemon to inject Secure Attention Sequence into the current | |
44 // session. | |
45 void InjectSas(); | |
46 | 39 |
47 private: | 40 private: |
48 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentWin); | 41 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgentWin); |
49 }; | 42 }; |
50 | 43 |
51 DesktopSessionAgentWin::DesktopSessionAgentWin( | 44 DesktopSessionAgentWin::DesktopSessionAgentWin( |
52 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, | 45 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, |
53 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 46 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
54 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 47 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
55 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 48 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 if (!CreateConnectedIpcChannel(channel_name, security_descriptor, | 83 if (!CreateConnectedIpcChannel(channel_name, security_descriptor, |
91 io_task_runner(), this, &client, &server)) { | 84 io_task_runner(), this, &client, &server)) { |
92 return false; | 85 return false; |
93 } | 86 } |
94 | 87 |
95 *client_out = client.Take(); | 88 *client_out = client.Take(); |
96 *server_out = server.Pass(); | 89 *server_out = server.Pass(); |
97 return true; | 90 return true; |
98 } | 91 } |
99 | 92 |
100 scoped_ptr<EventExecutor> DesktopSessionAgentWin::CreateEventExecutor() { | |
101 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | |
102 | |
103 scoped_ptr<EventExecutor> event_executor = | |
104 EventExecutor::Create(input_task_runner(), caller_task_runner()); | |
105 event_executor.reset(new SessionEventExecutorWin( | |
106 input_task_runner(), event_executor.Pass(), caller_task_runner(), | |
107 base::Bind(&DesktopSessionAgentWin::InjectSas, this))); | |
108 return event_executor.Pass(); | |
109 } | |
110 | |
111 void DesktopSessionAgentWin::InjectSas() { | |
112 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | |
113 | |
114 if (delegate().get()) | |
115 delegate()->InjectSas(); | |
116 } | |
117 | |
118 // static | 93 // static |
119 scoped_refptr<DesktopSessionAgent> DesktopSessionAgent::Create( | 94 scoped_refptr<DesktopSessionAgent> DesktopSessionAgent::Create( |
120 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, | 95 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner, |
121 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 96 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
122 scoped_refptr<AutoThreadTaskRunner> input_task_runner, | 97 scoped_refptr<AutoThreadTaskRunner> input_task_runner, |
123 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 98 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
124 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) { | 99 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner) { |
125 return scoped_refptr<DesktopSessionAgent>(new DesktopSessionAgentWin( | 100 return scoped_refptr<DesktopSessionAgent>(new DesktopSessionAgentWin( |
126 audio_capture_task_runner, caller_task_runner, input_task_runner, | 101 audio_capture_task_runner, caller_task_runner, input_task_runner, |
127 io_task_runner, video_capture_task_runner)); | 102 io_task_runner, video_capture_task_runner)); |
128 } | 103 } |
129 | 104 |
130 } // namespace remoting | 105 } // namespace remoting |
OLD | NEW |