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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 int Run() { | 141 int Run() { |
142 bool tokens_pending = false; | 142 bool tokens_pending = false; |
143 if (!LoadConfig(file_io_thread_.message_loop_proxy(), &tokens_pending)) { | 143 if (!LoadConfig(file_io_thread_.message_loop_proxy(), &tokens_pending)) { |
144 return kInvalidHostConfigurationExitCode; | 144 return kInvalidHostConfigurationExitCode; |
145 } | 145 } |
146 if (tokens_pending) { | 146 if (tokens_pending) { |
147 // If we have an OAuth refresh token, then XmppSignalStrategy can't | 147 // If we have an OAuth refresh token, then XmppSignalStrategy can't |
148 // handle it directly, so refresh it asynchronously. A task will be | 148 // handle it directly, so refresh it asynchronously. A task will be |
149 // posted on the message loop to start watching the NAT policy when | 149 // posted on the message loop to start watching the NAT policy when |
150 // the access token is available. | 150 // the access token is available. |
151 // | |
152 // TODO(sergeyu): Move this code to SignalingConnector. | |
151 oauth_client_.Start(oauth_refresh_token_, this, | 153 oauth_client_.Start(oauth_refresh_token_, this, |
152 message_loop_.message_loop_proxy()); | 154 message_loop_.message_loop_proxy()); |
153 } else { | 155 } else { |
154 StartWatchingNatPolicy(); | 156 StartWatchingNatPolicy(); |
155 } | 157 } |
156 | 158 |
157 #if defined(OS_MACOSX) | 159 #if defined(OS_MACOSX) |
158 file_io_thread_.message_loop_proxy()->PostTask( | 160 file_io_thread_.message_loop_proxy()->PostTask( |
159 FROM_HERE, | 161 FROM_HERE, |
160 base::Bind(&HostProcess::ListenForConfigChanges, | 162 base::Bind(&HostProcess::ListenForConfigChanges, |
161 base::Unretained(this))); | 163 base::Unretained(this))); |
162 #endif | 164 #endif |
163 message_loop_.Run(); | 165 message_loop_.Run(); |
164 | 166 |
165 return kSuccessExitCode; | 167 return kSuccessExitCode; |
166 } | 168 } |
167 | 169 |
168 // Overridden from OAuthClient::Delegate | 170 // Overridden from OAuthClient::Delegate |
169 virtual void OnRefreshTokenResponse(const std::string& access_token, | 171 virtual void OnRefreshTokenResponse(const std::string& access_token, |
170 int expires) OVERRIDE { | 172 int expires) OVERRIDE { |
171 xmpp_auth_token_ = access_token; | 173 xmpp_auth_token_ = access_token; |
172 // If there's already a signal strategy object, update it ready for the | 174 // If there's already a signal strategy object, update it ready for the |
173 // next time it calls Connect. If not, then this is the initial token | 175 // next time it calls Connect. If not, then this is the initial token |
174 // exchange, so proceed to the next stage of connection. | 176 // exchange, so proceed to the next stage of connection. |
175 if (signal_strategy_.get()) { | 177 if (signal_strategy_.get()) { |
176 signal_strategy_->SetAuthInfo(xmpp_login_, xmpp_auth_token_, | 178 context_->network_message_loop()->PostTask( |
177 xmpp_auth_service_); | 179 FROM_HERE, base::Bind( |
180 &XmppSignalStrategy::SetAuthInfo, | |
181 base::Unretained(signal_strategy_.get()), | |
Wez
2012/04/13 22:40:52
Looks like ChromotingContext gets torn down after
Jamie
2012/04/13 22:41:08
I think there's a race condition here. signal_stra
Sergey Ulanov
2012/04/13 23:43:50
Yes, I realize this may be unsafe, but we never ne
| |
182 xmpp_login_, xmpp_auth_token_, xmpp_auth_service_)); | |
178 } else { | 183 } else { |
179 StartWatchingNatPolicy(); | 184 StartWatchingNatPolicy(); |
180 } | 185 } |
181 } | 186 } |
182 | 187 |
183 virtual void OnOAuthError() OVERRIDE { | 188 virtual void OnOAuthError() OVERRIDE { |
184 LOG(ERROR) << "OAuth: invalid credentials."; | 189 LOG(ERROR) << "OAuth: invalid credentials."; |
185 } | 190 } |
186 | 191 |
187 private: | 192 private: |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 int CALLBACK WinMain(HINSTANCE instance, | 414 int CALLBACK WinMain(HINSTANCE instance, |
410 HINSTANCE previous_instance, | 415 HINSTANCE previous_instance, |
411 LPSTR command_line, | 416 LPSTR command_line, |
412 int show_command) { | 417 int show_command) { |
413 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting | 418 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting |
414 // the command line from GetCommandLineW(), so we can safely pass NULL here. | 419 // the command line from GetCommandLineW(), so we can safely pass NULL here. |
415 return main(0, NULL); | 420 return main(0, NULL); |
416 } | 421 } |
417 | 422 |
418 #endif | 423 #endif |
OLD | NEW |