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

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

Issue 639233002: Remote assistance on Chrome OS Part IV - It2MeHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build error on ozone Created 6 years, 1 month 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
« no previous file with comments | « remoting/host/policy_hack/policy_watcher_win.cc ('k') | remoting/remoting_host.gypi » ('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/debug/alias.h" 13 #include "base/debug/alias.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "base/synchronization/waitable_event.h"
23 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
24 #include "build/build_config.h" 23 #include "build/build_config.h"
25 #include "crypto/nss_util.h" 24 #include "crypto/nss_util.h"
26 #include "ipc/ipc_channel.h" 25 #include "ipc/ipc_channel.h"
27 #include "ipc/ipc_channel_proxy.h" 26 #include "ipc/ipc_channel_proxy.h"
28 #include "ipc/ipc_listener.h" 27 #include "ipc/ipc_listener.h"
29 #include "media/base/media.h" 28 #include "media/base/media.h"
30 #include "net/base/network_change_notifier.h" 29 #include "net/base/network_change_notifier.h"
31 #include "net/socket/client_socket_factory.h" 30 #include "net/socket/client_socket_factory.h"
32 #include "net/socket/ssl_server_socket.h" 31 #include "net/socket/ssl_server_socket.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 252
254 void RestartHost(); 253 void RestartHost();
255 254
256 // Stops the host and shuts down the process with the specified |exit_code|. 255 // Stops the host and shuts down the process with the specified |exit_code|.
257 void ShutdownHost(HostExitCodes exit_code); 256 void ShutdownHost(HostExitCodes exit_code);
258 257
259 void ScheduleHostShutdown(); 258 void ScheduleHostShutdown();
260 259
261 void ShutdownOnNetworkThread(); 260 void ShutdownOnNetworkThread();
262 261
262 void OnPolicyWatcherShutdown();
263
263 // Crashes the process in response to a daemon's request. The daemon passes 264 // Crashes the process in response to a daemon's request. The daemon passes
264 // the location of the code that detected the fatal error resulted in this 265 // the location of the code that detected the fatal error resulted in this
265 // request. 266 // request.
266 void OnCrash(const std::string& function_name, 267 void OnCrash(const std::string& function_name,
267 const std::string& file_name, 268 const std::string& file_name,
268 const int& line_number); 269 const int& line_number);
269 270
270 scoped_ptr<ChromotingHostContext> context_; 271 scoped_ptr<ChromotingHostContext> context_;
271 272
272 // Created on the UI thread but used from the network thread. 273 // Created on the UI thread but used from the network thread.
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 LOG(ERROR) << "Failed to apply the configuration."; 518 LOG(ERROR) << "Failed to apply the configuration.";
518 ShutdownHost(kInvalidHostConfigurationExitCode); 519 ShutdownHost(kInvalidHostConfigurationExitCode);
519 return; 520 return;
520 } 521 }
521 522
522 if (state_ == HOST_INITIALIZING) { 523 if (state_ == HOST_INITIALIZING) {
523 // TODO(sergeyu): Currently OnPolicyUpdate() assumes that host config is 524 // TODO(sergeyu): Currently OnPolicyUpdate() assumes that host config is
524 // already loaded so PolicyWatcher has to be started here. Separate policy 525 // already loaded so PolicyWatcher has to be started here. Separate policy
525 // loading from policy verifications and move |policy_watcher_| 526 // loading from policy verifications and move |policy_watcher_|
526 // initialization to StartOnNetworkThread(). 527 // initialization to StartOnNetworkThread().
527 policy_watcher_.reset( 528 policy_watcher_ = policy_hack::PolicyWatcher::Create(
528 policy_hack::PolicyWatcher::Create(context_->file_task_runner())); 529 nullptr, context_->network_task_runner());
529 policy_watcher_->StartWatching( 530 policy_watcher_->StartWatching(
530 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this))); 531 base::Bind(&HostProcess::OnPolicyUpdate, base::Unretained(this)));
531 } else { 532 } else {
532 // Reapply policies that could be affected by a new config. 533 // Reapply policies that could be affected by a new config.
533 ApplyHostDomainPolicy(); 534 ApplyHostDomainPolicy();
534 ApplyUsernamePolicy(); 535 ApplyUsernamePolicy();
535 536
536 if (state_ == HOST_STARTED) { 537 if (state_ == HOST_STARTED) {
537 // TODO(sergeyu): Here we assume that PIN is the only part of the config 538 // TODO(sergeyu): Here we assume that PIN is the only part of the config
538 // that may change while the service is running. Change ApplyConfig() to 539 // that may change while the service is running. Change ApplyConfig() to
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 oauth_token_getter_.reset(); 1405 oauth_token_getter_.reset();
1405 signal_strategy_.reset(); 1406 signal_strategy_.reset();
1406 network_change_notifier_.reset(); 1407 network_change_notifier_.reset();
1407 1408
1408 if (state_ == HOST_STOPPING_TO_RESTART) { 1409 if (state_ == HOST_STOPPING_TO_RESTART) {
1409 StartHost(); 1410 StartHost();
1410 } else if (state_ == HOST_STOPPING) { 1411 } else if (state_ == HOST_STOPPING) {
1411 state_ = HOST_STOPPED; 1412 state_ = HOST_STOPPED;
1412 1413
1413 if (policy_watcher_.get()) { 1414 if (policy_watcher_.get()) {
1414 base::WaitableEvent done_event(true, false); 1415 policy_watcher_->StopWatching(
1415 policy_watcher_->StopWatching(&done_event); 1416 base::Bind(&HostProcess::OnPolicyWatcherShutdown, this));
1416 done_event.Wait(); 1417 } else {
1417 policy_watcher_.reset(); 1418 OnPolicyWatcherShutdown();
1418 } 1419 }
1419
1420 config_watcher_.reset();
1421
1422 // Complete the rest of shutdown on the main thread.
1423 context_->ui_task_runner()->PostTask(
1424 FROM_HERE,
1425 base::Bind(&HostProcess::ShutdownOnUiThread, this));
1426 } else { 1420 } else {
1427 // This method is only called in STOPPING_TO_RESTART and STOPPING states. 1421 // This method is only called in STOPPING_TO_RESTART and STOPPING states.
1428 NOTREACHED(); 1422 NOTREACHED();
1429 } 1423 }
1430 } 1424 }
1431 1425
1426 void HostProcess::OnPolicyWatcherShutdown() {
1427 policy_watcher_.reset();
1428
1429 // Complete the rest of shutdown on the main thread.
1430 context_->ui_task_runner()->PostTask(
1431 FROM_HERE, base::Bind(&HostProcess::ShutdownOnUiThread, this));
1432 }
1433
1432 void HostProcess::OnCrash(const std::string& function_name, 1434 void HostProcess::OnCrash(const std::string& function_name,
1433 const std::string& file_name, 1435 const std::string& file_name,
1434 const int& line_number) { 1436 const int& line_number) {
1435 char message[1024]; 1437 char message[1024];
1436 base::snprintf(message, sizeof(message), 1438 base::snprintf(message, sizeof(message),
1437 "Requested by %s at %s, line %d.", 1439 "Requested by %s at %s, line %d.",
1438 function_name.c_str(), file_name.c_str(), line_number); 1440 function_name.c_str(), file_name.c_str(), line_number);
1439 base::debug::Alias(message); 1441 base::debug::Alias(message);
1440 1442
1441 // The daemon requested us to crash the process. 1443 // The daemon requested us to crash the process.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 int exit_code = kSuccessExitCode; 1476 int exit_code = kSuccessExitCode;
1475 new HostProcess(context.Pass(), &exit_code); 1477 new HostProcess(context.Pass(), &exit_code);
1476 1478
1477 // Run the main (also UI) message loop until the host no longer needs it. 1479 // Run the main (also UI) message loop until the host no longer needs it.
1478 message_loop.Run(); 1480 message_loop.Run();
1479 1481
1480 return exit_code; 1482 return exit_code;
1481 } 1483 }
1482 1484
1483 } // namespace remoting 1485 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/policy_hack/policy_watcher_win.cc ('k') | remoting/remoting_host.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698