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 // 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" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const char kStdinConfigPath[] = "-"; | 133 const char kStdinConfigPath[] = "-"; |
134 | 134 |
135 const char kWindowIdSwitchName[] = "window-id"; | 135 const char kWindowIdSwitchName[] = "window-id"; |
136 | 136 |
137 } // namespace | 137 } // namespace |
138 | 138 |
139 namespace remoting { | 139 namespace remoting { |
140 | 140 |
141 class HostProcess | 141 class HostProcess |
142 : public ConfigWatcher::Delegate, | 142 : public ConfigWatcher::Delegate, |
143 public HeartbeatSender::Listener, | |
144 public HostChangeNotificationListener::Listener, | 143 public HostChangeNotificationListener::Listener, |
145 public IPC::Listener, | 144 public IPC::Listener, |
146 public base::RefCountedThreadSafe<HostProcess> { | 145 public base::RefCountedThreadSafe<HostProcess> { |
147 public: | 146 public: |
148 HostProcess(scoped_ptr<ChromotingHostContext> context, | 147 HostProcess(scoped_ptr<ChromotingHostContext> context, |
149 int* exit_code_out); | 148 int* exit_code_out); |
150 | 149 |
151 // ConfigWatcher::Delegate interface. | 150 // ConfigWatcher::Delegate interface. |
152 void OnConfigUpdated(const std::string& serialized_config) override; | 151 void OnConfigUpdated(const std::string& serialized_config) override; |
153 void OnConfigWatcherError() override; | 152 void OnConfigWatcherError() override; |
154 | 153 |
155 // IPC::Listener implementation. | 154 // IPC::Listener implementation. |
156 bool OnMessageReceived(const IPC::Message& message) override; | 155 bool OnMessageReceived(const IPC::Message& message) override; |
157 void OnChannelError() override; | 156 void OnChannelError() override; |
158 | 157 |
159 // HeartbeatSender::Listener overrides. | |
160 void OnHeartbeatSuccessful() override; | |
161 void OnUnknownHostIdError() override; | |
162 | |
163 // HostChangeNotificationListener::Listener overrides. | 158 // HostChangeNotificationListener::Listener overrides. |
164 void OnHostDeleted() override; | 159 void OnHostDeleted() override; |
165 | 160 |
166 // Initializes the pairing registry on Windows. | 161 // Initializes the pairing registry on Windows. |
167 void OnInitializePairingRegistry( | 162 void OnInitializePairingRegistry( |
168 IPC::PlatformFileForTransit privileged_key, | 163 IPC::PlatformFileForTransit privileged_key, |
169 IPC::PlatformFileForTransit unprivileged_key); | 164 IPC::PlatformFileForTransit unprivileged_key); |
170 | 165 |
171 private: | 166 private: |
172 enum HostState { | 167 enum HostState { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 bool OnRelayPolicyUpdate(base::DictionaryValue* policies); | 235 bool OnRelayPolicyUpdate(base::DictionaryValue* policies); |
241 bool OnUdpPortPolicyUpdate(base::DictionaryValue* policies); | 236 bool OnUdpPortPolicyUpdate(base::DictionaryValue* policies); |
242 bool OnCurtainPolicyUpdate(base::DictionaryValue* policies); | 237 bool OnCurtainPolicyUpdate(base::DictionaryValue* policies); |
243 bool OnHostTalkGadgetPrefixPolicyUpdate(base::DictionaryValue* policies); | 238 bool OnHostTalkGadgetPrefixPolicyUpdate(base::DictionaryValue* policies); |
244 bool OnHostTokenUrlPolicyUpdate(base::DictionaryValue* policies); | 239 bool OnHostTokenUrlPolicyUpdate(base::DictionaryValue* policies); |
245 bool OnPairingPolicyUpdate(base::DictionaryValue* policies); | 240 bool OnPairingPolicyUpdate(base::DictionaryValue* policies); |
246 bool OnGnubbyAuthPolicyUpdate(base::DictionaryValue* policies); | 241 bool OnGnubbyAuthPolicyUpdate(base::DictionaryValue* policies); |
247 | 242 |
248 void StartHost(); | 243 void StartHost(); |
249 | 244 |
| 245 void OnHeartbeatSuccessful(); |
| 246 void OnUnknownHostIdError(); |
| 247 |
250 void OnAuthFailed(); | 248 void OnAuthFailed(); |
251 | 249 |
252 void RestartHost(); | 250 void RestartHost(); |
253 | 251 |
254 // Stops the host and shuts down the process with the specified |exit_code|. | 252 // Stops the host and shuts down the process with the specified |exit_code|. |
255 void ShutdownHost(HostExitCodes exit_code); | 253 void ShutdownHost(HostExitCodes exit_code); |
256 | 254 |
257 void ScheduleHostShutdown(); | 255 void ScheduleHostShutdown(); |
258 | 256 |
259 void ShutdownOnNetworkThread(); | 257 void ShutdownOnNetworkThread(); |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_); | 1314 frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_); |
1317 host_->AddExtension(frame_recorder_extension.Pass()); | 1315 host_->AddExtension(frame_recorder_extension.Pass()); |
1318 } | 1316 } |
1319 | 1317 |
1320 // TODO(simonmorris): Get the maximum session duration from a policy. | 1318 // TODO(simonmorris): Get the maximum session duration from a policy. |
1321 #if defined(OS_LINUX) | 1319 #if defined(OS_LINUX) |
1322 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); | 1320 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); |
1323 #endif | 1321 #endif |
1324 | 1322 |
1325 heartbeat_sender_.reset(new HeartbeatSender( | 1323 heartbeat_sender_.reset(new HeartbeatSender( |
1326 this, host_id_, signal_strategy_.get(), key_pair_, | 1324 base::Bind(&HostProcess::OnHeartbeatSuccessful, base::Unretained(this)), |
1327 directory_bot_jid_)); | 1325 base::Bind(&HostProcess::OnUnknownHostIdError, base::Unretained(this)), |
| 1326 host_id_, signal_strategy_.get(), key_pair_, directory_bot_jid_)); |
1328 | 1327 |
1329 host_change_notification_listener_.reset(new HostChangeNotificationListener( | 1328 host_change_notification_listener_.reset(new HostChangeNotificationListener( |
1330 this, host_id_, signal_strategy_.get(), directory_bot_jid_)); | 1329 this, host_id_, signal_strategy_.get(), directory_bot_jid_)); |
1331 | 1330 |
1332 host_status_logger_.reset( | 1331 host_status_logger_.reset( |
1333 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::ME2ME, | 1332 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::ME2ME, |
1334 signal_strategy_.get(), directory_bot_jid_)); | 1333 signal_strategy_.get(), directory_bot_jid_)); |
1335 | 1334 |
1336 // Set up reporting the host status notifications. | 1335 // Set up reporting the host status notifications. |
1337 #if defined(REMOTING_MULTI_PROCESS) | 1336 #if defined(REMOTING_MULTI_PROCESS) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 int exit_code = kSuccessExitCode; | 1481 int exit_code = kSuccessExitCode; |
1483 new HostProcess(context.Pass(), &exit_code); | 1482 new HostProcess(context.Pass(), &exit_code); |
1484 | 1483 |
1485 // Run the main (also UI) message loop until the host no longer needs it. | 1484 // Run the main (also UI) message loop until the host no longer needs it. |
1486 message_loop.Run(); | 1485 message_loop.Run(); |
1487 | 1486 |
1488 return exit_code; | 1487 return exit_code; |
1489 } | 1488 } |
1490 | 1489 |
1491 } // namespace remoting | 1490 } // namespace remoting |
OLD | NEW |