| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "net/url_request/url_fetcher.h" | 10 #include "net/url_request/url_fetcher.h" |
| 11 #include "remoting/host/host_exit_codes.h" | 11 #include "remoting/host/host_exit_codes.h" |
| 12 #include "remoting/host/logging.h" | 12 #include "remoting/host/logging.h" |
| 13 #include "remoting/host/pairing_registry_delegate.h" | 13 #include "remoting/host/pairing_registry_delegate.h" |
| 14 #include "remoting/host/setup/me2me_native_messaging_host.h" | 14 #include "remoting/host/setup/me2me_native_messaging_host.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const char kParentWindowSwitchName[] = "parent-window"; | 18 const char kParentWindowSwitchName[] = "parent-window"; |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 namespace remoting { | 22 namespace remoting { |
| 23 | 23 |
| 24 int NativeMessagingHostMain() { | 24 int Me2MeNativeMessagingHostMain() { |
| 25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 26 // GetStdHandle() returns pseudo-handles for stdin and stdout even if | 26 // GetStdHandle() returns pseudo-handles for stdin and stdout even if |
| 27 // the hosting executable specifies "Windows" subsystem. However the returned | 27 // the hosting executable specifies "Windows" subsystem. However the returned |
| 28 // handles are invalid in that case unless standard input and output are | 28 // handles are invalid in that case unless standard input and output are |
| 29 // redirected to a pipe or file. | 29 // redirected to a pipe or file. |
| 30 base::PlatformFile read_file = GetStdHandle(STD_INPUT_HANDLE); | 30 base::PlatformFile read_file = GetStdHandle(STD_INPUT_HANDLE); |
| 31 base::PlatformFile write_file = GetStdHandle(STD_OUTPUT_HANDLE); | 31 base::PlatformFile write_file = GetStdHandle(STD_OUTPUT_HANDLE); |
| 32 #elif defined(OS_POSIX) | 32 #elif defined(OS_POSIX) |
| 33 base::PlatformFile read_file = STDIN_FILENO; | 33 base::PlatformFile read_file = STDIN_FILENO; |
| 34 base::PlatformFile write_file = STDOUT_FILENO; | 34 base::PlatformFile write_file = STDOUT_FILENO; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 net::URLFetcher::SetIgnoreCertificateRequests(true); | 73 net::URLFetcher::SetIgnoreCertificateRequests(true); |
| 74 | 74 |
| 75 // Create the pairing registry and native messaging host. | 75 // Create the pairing registry and native messaging host. |
| 76 scoped_refptr<protocol::PairingRegistry> pairing_registry = | 76 scoped_refptr<protocol::PairingRegistry> pairing_registry = |
| 77 CreatePairingRegistry(io_thread.message_loop_proxy()); | 77 CreatePairingRegistry(io_thread.message_loop_proxy()); |
| 78 | 78 |
| 79 // Set up the native messaging channel. | 79 // Set up the native messaging channel. |
| 80 scoped_ptr<NativeMessagingChannel> channel( | 80 scoped_ptr<NativeMessagingChannel> channel( |
| 81 new NativeMessagingChannel(read_file, write_file)); | 81 new NativeMessagingChannel(read_file, write_file)); |
| 82 | 82 |
| 83 scoped_ptr<NativeMessagingHost> host( | 83 scoped_ptr<Me2MeNativeMessagingHost> host( |
| 84 new NativeMessagingHost(channel.Pass(), | 84 new Me2MeNativeMessagingHost(channel.Pass(), |
| 85 daemon_controller, | 85 daemon_controller, |
| 86 pairing_registry, | 86 pairing_registry, |
| 87 oauth_client.Pass())); | 87 oauth_client.Pass())); |
| 88 host->Start(run_loop.QuitClosure()); | 88 host->Start(run_loop.QuitClosure()); |
| 89 | 89 |
| 90 // Run the loop until channel is alive. | 90 // Run the loop until channel is alive. |
| 91 run_loop.Run(); | 91 run_loop.Run(); |
| 92 return kSuccessExitCode; | 92 return kSuccessExitCode; |
| 93 } | 93 } |
| 94 | 94 |
| 95 } // namespace remoting | 95 } // namespace remoting |
| 96 | 96 |
| 97 int main(int argc, char** argv) { | 97 int main(int argc, char** argv) { |
| 98 // This object instance is required by Chrome code (such as MessageLoop). | 98 // This object instance is required by Chrome code (such as MessageLoop). |
| 99 base::AtExitManager exit_manager; | 99 base::AtExitManager exit_manager; |
| 100 | 100 |
| 101 CommandLine::Init(argc, argv); | 101 CommandLine::Init(argc, argv); |
| 102 remoting::InitHostLogging(); | 102 remoting::InitHostLogging(); |
| 103 | 103 |
| 104 return remoting::NativeMessagingHostMain(); | 104 return remoting::Me2MeNativeMessagingHostMain(); |
| 105 } | 105 } |
| OLD | NEW |