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

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

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