| 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 #include <cstddef> | 5 #include <cstddef> |
| 6 #include <cstdio> | 6 #include <cstdio> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 private: | 249 private: |
| 250 SyncManager* sync_manager_; | 250 SyncManager* sync_manager_; |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 void LogUnrecoverableErrorContext() { | 253 void LogUnrecoverableErrorContext() { |
| 254 base::debug::StackTrace().Print(); | 254 base::debug::StackTrace().Print(); |
| 255 } | 255 } |
| 256 | 256 |
| 257 notifier::NotifierOptions ParseNotifierOptions( | 257 notifier::NotifierOptions ParseNotifierOptions( |
| 258 const CommandLine& command_line, | 258 const base::CommandLine& command_line, |
| 259 const scoped_refptr<net::URLRequestContextGetter>& | 259 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) { |
| 260 request_context_getter) { | |
| 261 notifier::NotifierOptions notifier_options; | 260 notifier::NotifierOptions notifier_options; |
| 262 notifier_options.request_context_getter = request_context_getter; | 261 notifier_options.request_context_getter = request_context_getter; |
| 263 notifier_options.auth_mechanism = "X-OAUTH2"; | 262 notifier_options.auth_mechanism = "X-OAUTH2"; |
| 264 | 263 |
| 265 if (command_line.HasSwitch(kXmppHostPortSwitch)) { | 264 if (command_line.HasSwitch(kXmppHostPortSwitch)) { |
| 266 notifier_options.xmpp_host_port = | 265 notifier_options.xmpp_host_port = |
| 267 net::HostPortPair::FromString( | 266 net::HostPortPair::FromString( |
| 268 command_line.GetSwitchValueASCII(kXmppHostPortSwitch)); | 267 command_line.GetSwitchValueASCII(kXmppHostPortSwitch)); |
| 269 LOG(INFO) << "Using " << notifier_options.xmpp_host_port.ToString() | 268 LOG(INFO) << "Using " << notifier_options.xmpp_host_port.ToString() |
| 270 << " for test sync notification server."; | 269 << " for test sync notification server."; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 286 void StubNetworkTimeUpdateCallback(const base::Time&, | 285 void StubNetworkTimeUpdateCallback(const base::Time&, |
| 287 const base::TimeDelta&, | 286 const base::TimeDelta&, |
| 288 const base::TimeDelta&) { | 287 const base::TimeDelta&) { |
| 289 } | 288 } |
| 290 | 289 |
| 291 int SyncClientMain(int argc, char* argv[]) { | 290 int SyncClientMain(int argc, char* argv[]) { |
| 292 #if defined(OS_MACOSX) | 291 #if defined(OS_MACOSX) |
| 293 base::mac::ScopedNSAutoreleasePool pool; | 292 base::mac::ScopedNSAutoreleasePool pool; |
| 294 #endif | 293 #endif |
| 295 base::AtExitManager exit_manager; | 294 base::AtExitManager exit_manager; |
| 296 CommandLine::Init(argc, argv); | 295 base::CommandLine::Init(argc, argv); |
| 297 logging::LoggingSettings settings; | 296 logging::LoggingSettings settings; |
| 298 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 297 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 299 logging::InitLogging(settings); | 298 logging::InitLogging(settings); |
| 300 | 299 |
| 301 base::MessageLoop sync_loop; | 300 base::MessageLoop sync_loop; |
| 302 base::Thread io_thread("IO thread"); | 301 base::Thread io_thread("IO thread"); |
| 303 base::Thread::Options options; | 302 base::Thread::Options options; |
| 304 options.message_loop_type = base::MessageLoop::TYPE_IO; | 303 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 305 io_thread.StartWithOptions(options); | 304 io_thread.StartWithOptions(options); |
| 306 | 305 |
| 307 // Parse command line. | 306 // Parse command line. |
| 308 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 307 const base::CommandLine& command_line = |
| 308 *base::CommandLine::ForCurrentProcess(); |
| 309 SyncCredentials credentials; | 309 SyncCredentials credentials; |
| 310 credentials.email = command_line.GetSwitchValueASCII(kEmailSwitch); | 310 credentials.email = command_line.GetSwitchValueASCII(kEmailSwitch); |
| 311 credentials.sync_token = command_line.GetSwitchValueASCII(kTokenSwitch); | 311 credentials.sync_token = command_line.GetSwitchValueASCII(kTokenSwitch); |
| 312 // TODO(akalin): Write a wrapper script that gets a token for an | 312 // TODO(akalin): Write a wrapper script that gets a token for an |
| 313 // email and password and passes that in to this utility. | 313 // email and password and passes that in to this utility. |
| 314 if (credentials.email.empty() || credentials.sync_token.empty()) { | 314 if (credentials.email.empty() || credentials.sync_token.empty()) { |
| 315 std::printf("Usage: %s --%s=foo@bar.com --%s=token\n" | 315 std::printf("Usage: %s --%s=foo@bar.com --%s=token\n" |
| 316 "[--%s=host:port] [--%s] [--%s]\n" | 316 "[--%s=host:port] [--%s] [--%s]\n" |
| 317 "Run chrome and set a breakpoint on\n" | 317 "Run chrome and set a breakpoint on\n" |
| 318 "syncer::SyncManagerImpl::UpdateCredentials() " | 318 "syncer::SyncManagerImpl::UpdateCredentials() " |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 io_thread.Stop(); | 454 io_thread.Stop(); |
| 455 return 0; | 455 return 0; |
| 456 } | 456 } |
| 457 | 457 |
| 458 } // namespace | 458 } // namespace |
| 459 } // namespace syncer | 459 } // namespace syncer |
| 460 | 460 |
| 461 int main(int argc, char* argv[]) { | 461 int main(int argc, char* argv[]) { |
| 462 return syncer::SyncClientMain(argc, argv); | 462 return syncer::SyncClientMain(argc, argv); |
| 463 } | 463 } |
| OLD | NEW |