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

Side by Side Diff: remoting/host/win/wts_session_process_delegate.cc

Issue 1547473005: Switch to standard integer types in remoting/host/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 unified diff | Download patch
OLDNEW
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 // This file implements the Windows service controlling Me2Me host processes 5 // This file implements the Windows service controlling Me2Me host processes
6 // running within user sessions. 6 // running within user sessions.
7 7
8 #include "remoting/host/win/wts_session_process_delegate.h" 8 #include "remoting/host/win/wts_session_process_delegate.h"
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
18 #include "base/win/scoped_handle.h" 19 #include "base/win/scoped_handle.h"
19 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
20 #include "ipc/ipc_channel.h" 21 #include "ipc/ipc_channel.h"
21 #include "ipc/ipc_channel_proxy.h" 22 #include "ipc/ipc_channel_proxy.h"
22 #include "ipc/ipc_listener.h" 23 #include "ipc/ipc_listener.h"
23 #include "ipc/ipc_message.h" 24 #include "ipc/ipc_message.h"
(...skipping 20 matching lines...) Expand all
44 : public base::RefCountedThreadSafe<Core>, 45 : public base::RefCountedThreadSafe<Core>,
45 public base::MessagePumpForIO::IOHandler, 46 public base::MessagePumpForIO::IOHandler,
46 public IPC::Listener { 47 public IPC::Listener {
47 public: 48 public:
48 Core(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 49 Core(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
49 scoped_ptr<base::CommandLine> target, 50 scoped_ptr<base::CommandLine> target,
50 bool launch_elevated, 51 bool launch_elevated,
51 const std::string& channel_security); 52 const std::string& channel_security);
52 53
53 // Initializes the object returning true on success. 54 // Initializes the object returning true on success.
54 bool Initialize(uint32 session_id); 55 bool Initialize(uint32_t session_id);
55 56
56 // Stops the object asynchronously. 57 // Stops the object asynchronously.
57 void Stop(); 58 void Stop();
58 59
59 // Mirrors WorkerProcessLauncher::Delegate. 60 // Mirrors WorkerProcessLauncher::Delegate.
60 void LaunchProcess(WorkerProcessLauncher* event_handler); 61 void LaunchProcess(WorkerProcessLauncher* event_handler);
61 void Send(IPC::Message* message); 62 void Send(IPC::Message* message);
62 void CloseChannel(); 63 void CloseChannel();
63 void KillProcess(); 64 void KillProcess();
64 65
65 private: 66 private:
66 friend class base::RefCountedThreadSafe<Core>; 67 friend class base::RefCountedThreadSafe<Core>;
67 ~Core() override; 68 ~Core() override;
68 69
69 // base::MessagePumpForIO::IOHandler implementation. 70 // base::MessagePumpForIO::IOHandler implementation.
70 void OnIOCompleted(base::MessagePumpForIO::IOContext* context, 71 void OnIOCompleted(base::MessagePumpForIO::IOContext* context,
71 DWORD bytes_transferred, 72 DWORD bytes_transferred,
72 DWORD error) override; 73 DWORD error) override;
73 74
74 // IPC::Listener implementation. 75 // IPC::Listener implementation.
75 bool OnMessageReceived(const IPC::Message& message) override; 76 bool OnMessageReceived(const IPC::Message& message) override;
76 void OnChannelConnected(int32 peer_pid) override; 77 void OnChannelConnected(int32_t peer_pid) override;
77 void OnChannelError() override; 78 void OnChannelError() override;
78 79
79 // The actual implementation of LaunchProcess() 80 // The actual implementation of LaunchProcess()
80 void DoLaunchProcess(); 81 void DoLaunchProcess();
81 82
82 // Drains the completion port queue to make sure that all job object 83 // Drains the completion port queue to make sure that all job object
83 // notifications have been received. 84 // notifications have been received.
84 void DrainJobNotifications(); 85 void DrainJobNotifications();
85 86
86 // Notified that the completion port queue has been drained. 87 // Notified that the completion port queue has been drained.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), 151 : caller_task_runner_(base::ThreadTaskRunnerHandle::Get()),
151 io_task_runner_(io_task_runner), 152 io_task_runner_(io_task_runner),
152 channel_security_(channel_security), 153 channel_security_(channel_security),
153 event_handler_(nullptr), 154 event_handler_(nullptr),
154 get_named_pipe_client_pid_(nullptr), 155 get_named_pipe_client_pid_(nullptr),
155 launch_elevated_(launch_elevated), 156 launch_elevated_(launch_elevated),
156 launch_pending_(false), 157 launch_pending_(false),
157 target_command_(target_command.Pass()) { 158 target_command_(target_command.Pass()) {
158 } 159 }
159 160
160 bool WtsSessionProcessDelegate::Core::Initialize(uint32 session_id) { 161 bool WtsSessionProcessDelegate::Core::Initialize(uint32_t session_id) {
161 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 162 DCHECK(caller_task_runner_->BelongsToCurrentThread());
162 163
163 // Windows XP does not support elevation. 164 // Windows XP does not support elevation.
164 if (base::win::GetVersion() < base::win::VERSION_VISTA) 165 if (base::win::GetVersion() < base::win::VERSION_VISTA)
165 launch_elevated_ = false; 166 launch_elevated_ = false;
166 167
167 if (launch_elevated_) { 168 if (launch_elevated_) {
168 // GetNamedPipeClientProcessId() is available starting from Vista. 169 // GetNamedPipeClientProcessId() is available starting from Vista.
169 HMODULE kernel32 = ::GetModuleHandle(L"kernel32.dll"); 170 HMODULE kernel32 = ::GetModuleHandle(L"kernel32.dll");
170 CHECK(kernel32 != nullptr); 171 CHECK(kernel32 != nullptr);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 293 }
293 } 294 }
294 295
295 bool WtsSessionProcessDelegate::Core::OnMessageReceived( 296 bool WtsSessionProcessDelegate::Core::OnMessageReceived(
296 const IPC::Message& message) { 297 const IPC::Message& message) {
297 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 298 DCHECK(caller_task_runner_->BelongsToCurrentThread());
298 299
299 return event_handler_->OnMessageReceived(message); 300 return event_handler_->OnMessageReceived(message);
300 } 301 }
301 302
302 void WtsSessionProcessDelegate::Core::OnChannelConnected(int32 peer_pid) { 303 void WtsSessionProcessDelegate::Core::OnChannelConnected(int32_t peer_pid) {
303 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 304 DCHECK(caller_task_runner_->BelongsToCurrentThread());
304 305
305 // Report the worker PID now if the worker process is launched indirectly. 306 // Report the worker PID now if the worker process is launched indirectly.
306 // Note that in this case the pipe's security descriptor is the only 307 // Note that in this case the pipe's security descriptor is the only
307 // protection against a malicious processed connecting to the pipe. 308 // protection against a malicious processed connecting to the pipe.
308 if (launch_elevated_) { 309 if (launch_elevated_) {
309 DWORD pid; 310 DWORD pid;
310 if (!get_named_pipe_client_pid_(pipe_.Get(), &pid)) { 311 if (!get_named_pipe_client_pid_(pipe_.Get(), &pid)) {
311 PLOG(ERROR) << "Failed to retrive PID of the client"; 312 PLOG(ERROR) << "Failed to retrive PID of the client";
312 ReportFatalError(); 313 ReportFatalError();
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 core_ = new Core(io_task_runner, 538 core_ = new Core(io_task_runner,
538 target_command.Pass(), 539 target_command.Pass(),
539 launch_elevated, 540 launch_elevated,
540 channel_security); 541 channel_security);
541 } 542 }
542 543
543 WtsSessionProcessDelegate::~WtsSessionProcessDelegate() { 544 WtsSessionProcessDelegate::~WtsSessionProcessDelegate() {
544 core_->Stop(); 545 core_->Stop();
545 } 546 }
546 547
547 bool WtsSessionProcessDelegate::Initialize(uint32 session_id) { 548 bool WtsSessionProcessDelegate::Initialize(uint32_t session_id) {
548 return core_->Initialize(session_id); 549 return core_->Initialize(session_id);
549 } 550 }
550 551
551 void WtsSessionProcessDelegate::LaunchProcess( 552 void WtsSessionProcessDelegate::LaunchProcess(
552 WorkerProcessLauncher* event_handler) { 553 WorkerProcessLauncher* event_handler) {
553 core_->LaunchProcess(event_handler); 554 core_->LaunchProcess(event_handler);
554 } 555 }
555 556
556 void WtsSessionProcessDelegate::Send(IPC::Message* message) { 557 void WtsSessionProcessDelegate::Send(IPC::Message* message) {
557 core_->Send(message); 558 core_->Send(message);
558 } 559 }
559 560
560 void WtsSessionProcessDelegate::CloseChannel() { 561 void WtsSessionProcessDelegate::CloseChannel() {
561 core_->CloseChannel(); 562 core_->CloseChannel();
562 } 563 }
563 564
564 void WtsSessionProcessDelegate::KillProcess() { 565 void WtsSessionProcessDelegate::KillProcess() {
565 core_->KillProcess(); 566 core_->KillProcess();
566 } 567 }
567 568
568 } // namespace remoting 569 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/wts_session_process_delegate.h ('k') | remoting/host/win/wts_terminal_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698