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