| 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, which is currently | 5 // This file implements a standalone host process for Me2Me, which is currently |
| 6 // used for the Linux-only Virtual Me2Me build. | 6 // used for the Linux-only Virtual Me2Me build. |
| 7 | 7 |
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 #endif | 10 #endif |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "remoting/host/signaling_connector.h" | 41 #include "remoting/host/signaling_connector.h" |
| 42 #include "remoting/jingle_glue/xmpp_signal_strategy.h" | 42 #include "remoting/jingle_glue/xmpp_signal_strategy.h" |
| 43 #include "remoting/protocol/me2me_host_authenticator_factory.h" | 43 #include "remoting/protocol/me2me_host_authenticator_factory.h" |
| 44 | 44 |
| 45 #if defined(TOOLKIT_GTK) | 45 #if defined(TOOLKIT_GTK) |
| 46 #include "ui/gfx/gtk_util.h" | 46 #include "ui/gfx/gtk_util.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 const int kSuccessExitCode = 0; |
| 52 const int kInvalidHostConfigurationExitCode = 1; |
| 53 |
| 51 // This is used for tagging system event logs. | 54 // This is used for tagging system event logs. |
| 52 const char kApplicationName[] = "chromoting"; | 55 const char kApplicationName[] = "chromoting"; |
| 53 | 56 |
| 54 // These are used for parsing the config-file locations from the command line, | 57 // These are used for parsing the config-file locations from the command line, |
| 55 // and for defining the default locations if the switches are not present. | 58 // and for defining the default locations if the switches are not present. |
| 56 const char kAuthConfigSwitchName[] = "auth-config"; | 59 const char kAuthConfigSwitchName[] = "auth-config"; |
| 57 const char kHostConfigSwitchName[] = "host-config"; | 60 const char kHostConfigSwitchName[] = "host-config"; |
| 58 | 61 |
| 59 const FilePath::CharType kDefaultAuthConfigFile[] = | 62 const FilePath::CharType kDefaultAuthConfigFile[] = |
| 60 FILE_PATH_LITERAL("auth.json"); | 63 FILE_PATH_LITERAL("auth.json"); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 103 } |
| 101 | 104 |
| 102 #if defined(OS_LINUX) | 105 #if defined(OS_LINUX) |
| 103 Capturer::EnableXDamage(true); | 106 Capturer::EnableXDamage(true); |
| 104 #endif | 107 #endif |
| 105 } | 108 } |
| 106 | 109 |
| 107 int Run() { | 110 int Run() { |
| 108 bool tokens_pending = false; | 111 bool tokens_pending = false; |
| 109 if (!LoadConfig(file_io_thread_.message_loop_proxy(), &tokens_pending)) { | 112 if (!LoadConfig(file_io_thread_.message_loop_proxy(), &tokens_pending)) { |
| 110 return 1; | 113 return kInvalidHostConfigurationExitCode; |
| 111 } | 114 } |
| 112 if (tokens_pending) { | 115 if (tokens_pending) { |
| 113 // If we have an OAuth refresh token, then XmppSignalStrategy can't | 116 // If we have an OAuth refresh token, then XmppSignalStrategy can't |
| 114 // handle it directly, so refresh it asynchronously. A task will be | 117 // handle it directly, so refresh it asynchronously. A task will be |
| 115 // posted on the message loop to start watching the NAT policy when | 118 // posted on the message loop to start watching the NAT policy when |
| 116 // the access token is available. | 119 // the access token is available. |
| 117 oauth_client_.Start(oauth_refresh_token_, this, | 120 oauth_client_.Start(oauth_refresh_token_, this, |
| 118 message_loop_.message_loop_proxy()); | 121 message_loop_.message_loop_proxy()); |
| 119 } else { | 122 } else { |
| 120 StartWatchingNatPolicy(); | 123 StartWatchingNatPolicy(); |
| 121 } | 124 } |
| 122 | 125 |
| 123 message_loop_.Run(); | 126 message_loop_.Run(); |
| 124 | 127 |
| 125 return 0; | 128 return kSuccessExitCode; |
| 126 } | 129 } |
| 127 | 130 |
| 128 // Overridden from OAuthClient::Delegate | 131 // Overridden from OAuthClient::Delegate |
| 129 virtual void OnRefreshTokenResponse(const std::string& access_token, | 132 virtual void OnRefreshTokenResponse(const std::string& access_token, |
| 130 int expires) OVERRIDE { | 133 int expires) OVERRIDE { |
| 131 xmpp_auth_token_ = access_token; | 134 xmpp_auth_token_ = access_token; |
| 132 // If there's already a signal strategy object, update it ready for the | 135 // If there's already a signal strategy object, update it ready for the |
| 133 // next time it calls Connect. If not, then this is the initial token | 136 // next time it calls Connect. If not, then this is the initial token |
| 134 // exchange, so proceed to the next stage of connection. | 137 // exchange, so proceed to the next stage of connection. |
| 135 if (signal_strategy_.get()) { | 138 if (signal_strategy_.get()) { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 int CALLBACK WinMain(HINSTANCE instance, | 379 int CALLBACK WinMain(HINSTANCE instance, |
| 377 HINSTANCE previous_instance, | 380 HINSTANCE previous_instance, |
| 378 LPSTR command_line, | 381 LPSTR command_line, |
| 379 int show_command) { | 382 int show_command) { |
| 380 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 383 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
| 381 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 384 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
| 382 return main(0, NULL); | 385 return main(0, NULL); |
| 383 } | 386 } |
| 384 | 387 |
| 385 #endif | 388 #endif |
| OLD | NEW |