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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return context_.get(); | 102 return context_.get(); |
103 } | 103 } |
104 | 104 |
105 private: | 105 private: |
106 ~MyTestURLRequestContextGetter() override {} | 106 ~MyTestURLRequestContextGetter() override {} |
107 | 107 |
108 scoped_ptr<MyTestURLRequestContext> context_; | 108 scoped_ptr<MyTestURLRequestContext> context_; |
109 }; | 109 }; |
110 | 110 |
111 notifier::NotifierOptions ParseNotifierOptions( | 111 notifier::NotifierOptions ParseNotifierOptions( |
112 const CommandLine& command_line, | 112 const base::CommandLine& command_line, |
113 const scoped_refptr<net::URLRequestContextGetter>& | 113 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter) { |
114 request_context_getter) { | |
115 notifier::NotifierOptions notifier_options; | 114 notifier::NotifierOptions notifier_options; |
116 notifier_options.request_context_getter = request_context_getter; | 115 notifier_options.request_context_getter = request_context_getter; |
117 | 116 |
118 if (command_line.HasSwitch(kHostPortSwitch)) { | 117 if (command_line.HasSwitch(kHostPortSwitch)) { |
119 notifier_options.xmpp_host_port = | 118 notifier_options.xmpp_host_port = |
120 net::HostPortPair::FromString( | 119 net::HostPortPair::FromString( |
121 command_line.GetSwitchValueASCII(kHostPortSwitch)); | 120 command_line.GetSwitchValueASCII(kHostPortSwitch)); |
122 LOG(INFO) << "Using " << notifier_options.xmpp_host_port.ToString() | 121 LOG(INFO) << "Using " << notifier_options.xmpp_host_port.ToString() |
123 << " for test sync notification server."; | 122 << " for test sync notification server."; |
124 } | 123 } |
(...skipping 10 matching lines...) Expand all Loading... |
135 | 134 |
136 return notifier_options; | 135 return notifier_options; |
137 } | 136 } |
138 | 137 |
139 int SyncListenNotificationsMain(int argc, char* argv[]) { | 138 int SyncListenNotificationsMain(int argc, char* argv[]) { |
140 using namespace syncer; | 139 using namespace syncer; |
141 #if defined(OS_MACOSX) | 140 #if defined(OS_MACOSX) |
142 base::mac::ScopedNSAutoreleasePool pool; | 141 base::mac::ScopedNSAutoreleasePool pool; |
143 #endif | 142 #endif |
144 base::AtExitManager exit_manager; | 143 base::AtExitManager exit_manager; |
145 CommandLine::Init(argc, argv); | 144 base::CommandLine::Init(argc, argv); |
146 logging::LoggingSettings settings; | 145 logging::LoggingSettings settings; |
147 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 146 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
148 logging::InitLogging(settings); | 147 logging::InitLogging(settings); |
149 | 148 |
150 base::MessageLoop ui_loop; | 149 base::MessageLoop ui_loop; |
151 base::Thread io_thread("IO thread"); | 150 base::Thread io_thread("IO thread"); |
152 base::Thread::Options options; | 151 base::Thread::Options options; |
153 options.message_loop_type = base::MessageLoop::TYPE_IO; | 152 options.message_loop_type = base::MessageLoop::TYPE_IO; |
154 io_thread.StartWithOptions(options); | 153 io_thread.StartWithOptions(options); |
155 | 154 |
156 // Parse command line. | 155 // Parse command line. |
157 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 156 const base::CommandLine& command_line = |
| 157 *base::CommandLine::ForCurrentProcess(); |
158 std::string email = command_line.GetSwitchValueASCII(kEmailSwitch); | 158 std::string email = command_line.GetSwitchValueASCII(kEmailSwitch); |
159 std::string token = command_line.GetSwitchValueASCII(kTokenSwitch); | 159 std::string token = command_line.GetSwitchValueASCII(kTokenSwitch); |
160 // TODO(akalin): Write a wrapper script that gets a token for an | 160 // TODO(akalin): Write a wrapper script that gets a token for an |
161 // email and password and passes that in to this utility. | 161 // email and password and passes that in to this utility. |
162 if (email.empty() || token.empty()) { | 162 if (email.empty() || token.empty()) { |
163 std::printf("Usage: %s --%s=foo@bar.com --%s=token\n" | 163 std::printf("Usage: %s --%s=foo@bar.com --%s=token\n" |
164 "[--%s=host:port] [--%s] [--%s]\n" | 164 "[--%s=host:port] [--%s] [--%s]\n" |
165 "Run chrome and set a breakpoint on\n" | 165 "Run chrome and set a breakpoint on\n" |
166 "syncer::SyncManagerImpl::UpdateCredentials() " | 166 "syncer::SyncManagerImpl::UpdateCredentials() " |
167 "after logging into\n" | 167 "after logging into\n" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 io_thread.Stop(); | 210 io_thread.Stop(); |
211 return 0; | 211 return 0; |
212 } | 212 } |
213 | 213 |
214 } // namespace | 214 } // namespace |
215 } // namespace syncer | 215 } // namespace syncer |
216 | 216 |
217 int main(int argc, char* argv[]) { | 217 int main(int argc, char* argv[]) { |
218 return syncer::SyncListenNotificationsMain(argc, argv); | 218 return syncer::SyncListenNotificationsMain(argc, argv); |
219 } | 219 } |
OLD | NEW |