| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 IPC::Channel::MODE_CLIENT, | 481 IPC::Channel::MODE_CLIENT, |
| 482 this, | 482 this, |
| 483 context_->network_task_runner().get()); | 483 context_->network_task_runner().get()); |
| 484 } | 484 } |
| 485 | 485 |
| 486 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { | 486 if (cmd_line->HasSwitch(kHostConfigSwitchName)) { |
| 487 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); | 487 host_config_path_ = cmd_line->GetSwitchValuePath(kHostConfigSwitchName); |
| 488 | 488 |
| 489 // Read config from stdin if necessary. | 489 // Read config from stdin if necessary. |
| 490 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { | 490 if (host_config_path_ == base::FilePath(kStdinConfigPath)) { |
| 491 char buf[4096]; | 491 const size_t kBufferSize = 4096; |
| 492 scoped_ptr<char[]> buf(new char[kBufferSize]); |
| 492 size_t len; | 493 size_t len; |
| 493 while ((len = fread(buf, 1, sizeof(buf), stdin)) > 0) { | 494 while ((len = fread(buf.get(), 1, kBufferSize, stdin)) > 0) { |
| 494 host_config_.append(buf, len); | 495 host_config_.append(buf.get(), len); |
| 495 } | 496 } |
| 496 } | 497 } |
| 497 } else { | 498 } else { |
| 498 base::FilePath default_config_dir = remoting::GetConfigDir(); | 499 base::FilePath default_config_dir = remoting::GetConfigDir(); |
| 499 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); | 500 host_config_path_ = default_config_dir.Append(kDefaultHostConfigFile); |
| 500 } | 501 } |
| 501 | 502 |
| 502 if (host_config_path_ != base::FilePath(kStdinConfigPath) && | 503 if (host_config_path_ != base::FilePath(kStdinConfigPath) && |
| 503 !base::PathExists(host_config_path_)) { | 504 !base::PathExists(host_config_path_)) { |
| 504 LOG(ERROR) << "Can't find host config at " << host_config_path_.value(); | 505 LOG(ERROR) << "Can't find host config at " << host_config_path_.value(); |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1646 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); | 1647 base::TimeDelta::FromSeconds(kShutdownTimeoutSeconds)); |
| 1647 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); | 1648 new HostProcess(context.Pass(), &exit_code, &shutdown_watchdog); |
| 1648 | 1649 |
| 1649 // Run the main (also UI) message loop until the host no longer needs it. | 1650 // Run the main (also UI) message loop until the host no longer needs it. |
| 1650 message_loop.Run(); | 1651 message_loop.Run(); |
| 1651 | 1652 |
| 1652 return exit_code; | 1653 return exit_code; |
| 1653 } | 1654 } |
| 1654 | 1655 |
| 1655 } // namespace remoting | 1656 } // namespace remoting |
| OLD | NEW |