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

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

Issue 10823083: [Chromoting] Implement the host domain policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync. Created 8 years, 4 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/plugin/host_script_object.cc ('k') | remoting/tools/me2me_virtual_host.py » ('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/files/file_path_watcher.h" 15 #include "base/files/file_path_watcher.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/message_loop.h" 18 #include "base/message_loop.h"
19 #include "base/scoped_native_library.h" 19 #include "base/scoped_native_library.h"
20 #include "base/string_util.h"
20 #include "base/synchronization/waitable_event.h" 21 #include "base/synchronization/waitable_event.h"
21 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
22 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
23 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
24 #include "build/build_config.h" 25 #include "build/build_config.h"
25 #include "crypto/nss_util.h" 26 #include "crypto/nss_util.h"
26 #include "net/base/network_change_notifier.h" 27 #include "net/base/network_change_notifier.h"
27 #include "net/socket/ssl_server_socket.h" 28 #include "net/socket/ssl_server_socket.h"
28 #include "remoting/base/breakpad.h" 29 #include "remoting/base/breakpad.h"
29 #include "remoting/base/constants.h" 30 #include "remoting/base/constants.h"
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 302
302 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { 303 void OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
303 if (!context_->network_task_runner()->BelongsToCurrentThread()) { 304 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
304 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( 305 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
305 &HostProcess::OnPolicyUpdate, base::Unretained(this), 306 &HostProcess::OnPolicyUpdate, base::Unretained(this),
306 base::Passed(&policies))); 307 base::Passed(&policies)));
307 return; 308 return;
308 } 309 }
309 310
310 bool bool_value; 311 bool bool_value;
312 std::string string_value;
313 if (policies->GetString(policy_hack::PolicyWatcher::kHostDomainPolicyName,
314 &string_value)) {
315 OnHostDomainPolicyUpdate(string_value);
316 }
311 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName, 317 if (policies->GetBoolean(policy_hack::PolicyWatcher::kNatPolicyName,
312 &bool_value)) { 318 &bool_value)) {
313 OnNatPolicyUpdate(bool_value); 319 OnNatPolicyUpdate(bool_value);
314 } 320 }
315 } 321 }
316 322
323 void OnHostDomainPolicyUpdate(const std::string& host_domain) {
324 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
325 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
326 &HostProcess::OnHostDomainPolicyUpdate, base::Unretained(this),
327 host_domain));
328 return;
329 }
330
331 if (!host_domain.empty() &&
332 !EndsWith(xmpp_login_, std::string("@") + host_domain, false)) {
333 Shutdown(kInvalidHostDomainExitCode);
334 }
335 }
336
317 void OnNatPolicyUpdate(bool nat_traversal_enabled) { 337 void OnNatPolicyUpdate(bool nat_traversal_enabled) {
318 if (!context_->network_task_runner()->BelongsToCurrentThread()) { 338 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
319 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( 339 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
320 &HostProcess::OnNatPolicyUpdate, base::Unretained(this), 340 &HostProcess::OnNatPolicyUpdate, base::Unretained(this),
321 nat_traversal_enabled)); 341 nat_traversal_enabled));
322 return; 342 return;
323 } 343 }
324 344
325 bool policy_changed = allow_nat_traversal_ != nat_traversal_enabled; 345 bool policy_changed = allow_nat_traversal_ != nat_traversal_enabled;
326 allow_nat_traversal_ = nat_traversal_enabled; 346 allow_nat_traversal_ = nat_traversal_enabled;
327 347
328 if (host_) { 348 if (host_) {
329 // Restart the host if the policy has changed while the host was 349 // Restart the host if the policy has changed while the host was
330 // online. 350 // online.
331 if (policy_changed) 351 if (policy_changed)
332 RestartHost(); 352 RestartHost();
333 } else { 353 } else {
334 // Just start the host otherwise. 354 // Just start the host otherwise.
335 StartHost(); 355 StartHost();
336 } 356 }
337 } 357 }
338 358
339 void StartHost() { 359 void StartHost() {
340 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 360 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
341 DCHECK(!host_); 361 DCHECK(!host_);
342 362
363 if (shutting_down_)
364 return;
365
343 if (!signal_strategy_.get()) { 366 if (!signal_strategy_.get()) {
344 signal_strategy_.reset( 367 signal_strategy_.reset(
345 new XmppSignalStrategy(context_->url_request_context_getter(), 368 new XmppSignalStrategy(context_->url_request_context_getter(),
346 xmpp_login_, xmpp_auth_token_, 369 xmpp_login_, xmpp_auth_token_,
347 xmpp_auth_service_)); 370 xmpp_auth_service_));
348 371
349 signaling_connector_.reset(new SignalingConnector( 372 signaling_connector_.reset(new SignalingConnector(
350 signal_strategy_.get(), 373 signal_strategy_.get(),
351 base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this)))); 374 base::Bind(&HostProcess::OnAuthFailed, base::Unretained(this))));
352 375
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 480 }
458 481
459 void Shutdown(int exit_code) { 482 void Shutdown(int exit_code) {
460 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 483 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
461 484
462 if (shutting_down_) 485 if (shutting_down_)
463 return; 486 return;
464 487
465 shutting_down_ = true; 488 shutting_down_ = true;
466 exit_code_ = exit_code; 489 exit_code_ = exit_code;
467 host_->Shutdown(base::Bind( 490 if (host_) {
468 &HostProcess::OnShutdownFinished, base::Unretained(this))); 491 host_->Shutdown(base::Bind(
492 &HostProcess::OnShutdownFinished, base::Unretained(this)));
493 } else {
494 OnShutdownFinished();
495 }
469 } 496 }
470 497
471 void OnShutdownFinished() { 498 void OnShutdownFinished() {
472 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); 499 DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
473 500
474 // Destroy networking objects while we are on the network thread. 501 // Destroy networking objects while we are on the network thread.
475 host_ = NULL; 502 host_ = NULL;
476 host_event_logger_.reset(); 503 host_event_logger_.reset();
477 log_to_server_.reset(); 504 log_to_server_.reset();
478 heartbeat_sender_.reset(); 505 heartbeat_sender_.reset();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 user32.GetFunctionPointer("SetProcessDPIAware")); 637 user32.GetFunctionPointer("SetProcessDPIAware"));
611 set_process_dpi_aware(); 638 set_process_dpi_aware();
612 } 639 }
613 640
614 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 641 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
615 // the command line from GetCommandLineW(), so we can safely pass NULL here. 642 // the command line from GetCommandLineW(), so we can safely pass NULL here.
616 return main(0, NULL); 643 return main(0, NULL);
617 } 644 }
618 645
619 #endif // defined(OS_WIN) 646 #endif // defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/plugin/host_script_object.cc ('k') | remoting/tools/me2me_virtual_host.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698