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

Side by Side Diff: remoting/host/remoting_me2me_host.cc

Issue 11118005: Pass the client end handle of the network-to-daemon IPC channel via handle inheritance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 8 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/ipc_consts.cc ('k') | remoting/host/win/launch_process_with_token.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/scoped_native_library.h" 18 #include "base/scoped_native_library.h"
19 #include "base/string_number_conversions.h"
19 #include "base/string_util.h" 20 #include "base/string_util.h"
20 #include "base/stringize_macros.h" 21 #include "base/stringize_macros.h"
21 #include "base/synchronization/waitable_event.h" 22 #include "base/synchronization/waitable_event.h"
22 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
23 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
24 #include "base/win/windows_version.h" 25 #include "base/win/windows_version.h"
25 #include "build/build_config.h" 26 #include "build/build_config.h"
26 #include "crypto/nss_util.h" 27 #include "crypto/nss_util.h"
27 #include "google_apis/google_api_keys.h" 28 #include "google_apis/google_api_keys.h"
28 #include "ipc/ipc_channel.h" 29 #include "ipc/ipc_channel.h"
(...skipping 12 matching lines...) Expand all
41 #include "remoting/host/curtaining_host_observer.h" 42 #include "remoting/host/curtaining_host_observer.h"
42 #include "remoting/host/desktop_environment_factory.h" 43 #include "remoting/host/desktop_environment_factory.h"
43 #include "remoting/host/desktop_resizer.h" 44 #include "remoting/host/desktop_resizer.h"
44 #include "remoting/host/dns_blackhole_checker.h" 45 #include "remoting/host/dns_blackhole_checker.h"
45 #include "remoting/host/event_executor.h" 46 #include "remoting/host/event_executor.h"
46 #include "remoting/host/heartbeat_sender.h" 47 #include "remoting/host/heartbeat_sender.h"
47 #include "remoting/host/host_config.h" 48 #include "remoting/host/host_config.h"
48 #include "remoting/host/host_event_logger.h" 49 #include "remoting/host/host_event_logger.h"
49 #include "remoting/host/host_exit_codes.h" 50 #include "remoting/host/host_exit_codes.h"
50 #include "remoting/host/host_user_interface.h" 51 #include "remoting/host/host_user_interface.h"
52 #include "remoting/host/ipc_consts.h"
51 #include "remoting/host/json_host_config.h" 53 #include "remoting/host/json_host_config.h"
52 #include "remoting/host/log_to_server.h" 54 #include "remoting/host/log_to_server.h"
53 #include "remoting/host/network_settings.h" 55 #include "remoting/host/network_settings.h"
54 #include "remoting/host/policy_hack/policy_watcher.h" 56 #include "remoting/host/policy_hack/policy_watcher.h"
55 #include "remoting/host/resizing_host_observer.h" 57 #include "remoting/host/resizing_host_observer.h"
56 #include "remoting/host/session_manager_factory.h" 58 #include "remoting/host/session_manager_factory.h"
57 #include "remoting/host/signaling_connector.h" 59 #include "remoting/host/signaling_connector.h"
58 #include "remoting/host/usage_stats_consent.h" 60 #include "remoting/host/usage_stats_consent.h"
59 #include "remoting/host/video_frame_capturer.h" 61 #include "remoting/host/video_frame_capturer.h"
60 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 62 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
61 #include "remoting/protocol/me2me_host_authenticator_factory.h" 63 #include "remoting/protocol/me2me_host_authenticator_factory.h"
62 64
63 #if defined(OS_POSIX) 65 #if defined(OS_POSIX)
64 #include <signal.h> 66 #include <signal.h>
67 #include "base/file_descriptor_posix.h"
65 #include "remoting/host/posix/signal_handler.h" 68 #include "remoting/host/posix/signal_handler.h"
66 #endif // defined(OS_POSIX) 69 #endif // defined(OS_POSIX)
67 70
68 #if defined(OS_MACOSX) 71 #if defined(OS_MACOSX)
69 #include "base/mac/scoped_cftyperef.h" 72 #include "base/mac/scoped_cftyperef.h"
70 #include "base/mac/scoped_nsautorelease_pool.h" 73 #include "base/mac/scoped_nsautorelease_pool.h"
71 #endif // defined(OS_MACOSX) 74 #endif // defined(OS_MACOSX)
72 75
73 #if defined(OS_LINUX) 76 #if defined(OS_LINUX)
74 #include "remoting/host/audio_capturer_linux.h" 77 #include "remoting/host/audio_capturer_linux.h"
75 #endif // defined(OS_LINUX) 78 #endif // defined(OS_LINUX)
76 79
77 // N.B. OS_WIN is defined by including src/base headers. 80 // N.B. OS_WIN is defined by including src/base headers.
78 #if defined(OS_WIN) 81 #if defined(OS_WIN)
79 #include <commctrl.h> 82 #include <commctrl.h>
83 #include "base/win/scoped_handle.h"
80 #include "remoting/host/win/session_desktop_environment_factory.h" 84 #include "remoting/host/win/session_desktop_environment_factory.h"
81 #endif // defined(OS_WIN) 85 #endif // defined(OS_WIN)
82 86
83 #if defined(TOOLKIT_GTK) 87 #if defined(TOOLKIT_GTK)
84 #include "ui/gfx/gtk_util.h" 88 #include "ui/gfx/gtk_util.h"
85 #endif // defined(TOOLKIT_GTK) 89 #endif // defined(TOOLKIT_GTK)
86 90
87 namespace { 91 namespace {
88 92
89 // This is used for tagging system event logs. 93 // This is used for tagging system event logs.
90 const char kApplicationName[] = "chromoting"; 94 const char kApplicationName[] = "chromoting";
91 95
92 // The command line switch specifying the name of the daemon IPC endpoint.
93 const char kDaemonIpcSwitchName[] = "daemon-pipe";
94
95 // The command line switch used to get version of the daemon. 96 // The command line switch used to get version of the daemon.
96 const char kVersionSwitchName[] = "version"; 97 const char kVersionSwitchName[] = "version";
97 98
98 // The command line switch used to pass name of the pipe to capture audio on 99 // The command line switch used to pass name of the pipe to capture audio on
99 // linux. 100 // linux.
100 const char kAudioPipeSwitchName[] = "audio-pipe-name"; 101 const char kAudioPipeSwitchName[] = "audio-pipe-name";
101 102
102 const char kUnofficialOAuth2ClientId[] = 103 const char kUnofficialOAuth2ClientId[] =
103 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com"; 104 "440925447803-2pi3v45bff6tp1rde2f7q6lgbor3o5uj.apps.googleusercontent.com";
104 const char kUnofficialOAuth2ClientSecret[] = "W2ieEsG-R1gIA4MMurGrgMc_"; 105 const char kUnofficialOAuth2ClientSecret[] = "W2ieEsG-R1gIA4MMurGrgMc_";
(...skipping 27 matching lines...) Expand all
132 desktop_resizer_(DesktopResizer::Create()), 133 desktop_resizer_(DesktopResizer::Create()),
133 exit_code_(kSuccessExitCode) { 134 exit_code_(kSuccessExitCode) {
134 network_change_notifier_.reset(net::NetworkChangeNotifier::Create()); 135 network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
135 curtain_ = CurtainMode::Create( 136 curtain_ = CurtainMode::Create(
136 base::Bind(&HostProcess::OnDisconnectRequested, 137 base::Bind(&HostProcess::OnDisconnectRequested,
137 base::Unretained(this)), 138 base::Unretained(this)),
138 base::Bind(&HostProcess::OnDisconnectRequested, 139 base::Bind(&HostProcess::OnDisconnectRequested,
139 base::Unretained(this))); 140 base::Unretained(this)));
140 } 141 }
141 142
143 #if defined(REMOTING_MULTI_PROCESS)
144
145 bool InitWithCommandLine(const CommandLine* cmd_line) {
146 // Parse the handle value and convert it to a handle/file descriptor.
147 std::string channel_name =
148 cmd_line->GetSwitchValueASCII(kDaemonPipeSwitchName);
149
150 int pipe_handle = 0;
151 if (channel_name.empty() ||
152 !base::StringToInt(channel_name, &pipe_handle)) {
153 LOG(ERROR) << "Invalid '" << kDaemonPipeSwitchName
154 << "' value: " << channel_name;
155 return false;
156 }
157
158 #if defined(OS_WIN)
159 base::win::ScopedHandle pipe(reinterpret_cast<HANDLE>(pipe_handle));
160 IPC::ChannelHandle channel_handle(pipe);
161 #elif defined(OS_POSIX)
162 base::FileDescriptor pipe(pipe_handle, true);
163 IPC::ChannelHandle channel_handle(channel_name, pipe);
164 #endif // defined(OS_POSIX)
165
166 // Connect to the daemon process.
167 daemon_channel_.reset(new IPC::ChannelProxy(
168 channel_handle,
169 IPC::Channel::MODE_CLIENT,
170 this,
171 context_->network_task_runner()));
172
173 return true;
174 }
175
176 #else // !defined(REMOTING_MULTI_PROCESS)
177
142 bool InitWithCommandLine(const CommandLine* cmd_line) { 178 bool InitWithCommandLine(const CommandLine* cmd_line) {
143 // Connect to the daemon process. 179 // Connect to the daemon process.
144 std::string channel_name = 180 std::string channel_name =
145 cmd_line->GetSwitchValueASCII(kDaemonIpcSwitchName); 181 cmd_line->GetSwitchValueASCII(kDaemonPipeSwitchName);
146
147 #if defined(REMOTING_MULTI_PROCESS)
148 if (channel_name.empty())
149 return false;
150 #endif // defined(REMOTING_MULTI_PROCESS)
151
152 if (!channel_name.empty()) { 182 if (!channel_name.empty()) {
153 daemon_channel_.reset(new IPC::ChannelProxy( 183 daemon_channel_.reset(new IPC::ChannelProxy(
154 channel_name, IPC::Channel::MODE_CLIENT, this, 184 channel_name, IPC::Channel::MODE_CLIENT, this,
155 context_->network_task_runner())); 185 context_->network_task_runner()));
156 } 186 }
157 187
158 #if !defined(REMOTING_MULTI_PROCESS)
159 FilePath default_config_dir = remoting::GetConfigDir(); 188 FilePath default_config_dir = remoting::GetConfigDir();
160 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); 189 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile);
161 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { 190 if (cmd_line->HasSwitch(kHostConfigSwitchName)) {
162 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); 191 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName);
163 } 192 }
164 #endif // !defined(REMOTING_MULTI_PROCESS)
165 193
166 return true; 194 return true;
167 } 195 }
168 196
197 #endif // !defined(REMOTING_MULTI_PROCESS)
198
169 #if defined(OS_POSIX) 199 #if defined(OS_POSIX)
170 void SigTermHandler(int signal_number) { 200 void SigTermHandler(int signal_number) {
171 DCHECK(signal_number == SIGTERM); 201 DCHECK(signal_number == SIGTERM);
172 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 202 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
173 LOG(INFO) << "Caught SIGTERM: Shutting down..."; 203 LOG(INFO) << "Caught SIGTERM: Shutting down...";
174 Shutdown(kSuccessExitCode); 204 Shutdown(kSuccessExitCode);
175 } 205 }
176 #endif 206 #endif
177 207
178 virtual void OnConfigUpdated(const std::string& serialized_config) OVERRIDE { 208 virtual void OnConfigUpdated(const std::string& serialized_config) OVERRIDE {
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 user32.GetFunctionPointer("SetProcessDPIAware")); 829 user32.GetFunctionPointer("SetProcessDPIAware"));
800 set_process_dpi_aware(); 830 set_process_dpi_aware();
801 } 831 }
802 832
803 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 833 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
804 // the command line from GetCommandLineW(), so we can safely pass NULL here. 834 // the command line from GetCommandLineW(), so we can safely pass NULL here.
805 return main(0, NULL); 835 return main(0, NULL);
806 } 836 }
807 837
808 #endif // defined(OS_WIN) 838 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/ipc_consts.cc ('k') | remoting/host/win/launch_process_with_token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698