| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 *base::CommandLine::ForCurrentProcess(); | 158 *base::CommandLine::ForCurrentProcess(); |
| 159 std::string email = command_line.GetSwitchValueASCII(kEmailSwitch); | 159 std::string email = command_line.GetSwitchValueASCII(kEmailSwitch); |
| 160 std::string token = command_line.GetSwitchValueASCII(kTokenSwitch); | 160 std::string token = command_line.GetSwitchValueASCII(kTokenSwitch); |
| 161 // TODO(akalin): Write a wrapper script that gets a token for an | 161 // TODO(akalin): Write a wrapper script that gets a token for an |
| 162 // email and password and passes that in to this utility. | 162 // email and password and passes that in to this utility. |
| 163 if (email.empty() || token.empty()) { | 163 if (email.empty() || token.empty()) { |
| 164 std::printf( | 164 std::printf( |
| 165 "Usage: %s --%s=foo@bar.com --%s=token\n" | 165 "Usage: %s --%s=foo@bar.com --%s=token\n" |
| 166 "[--%s=host:port] [--%s] [--%s]\n" | 166 "[--%s=host:port] [--%s] [--%s]\n" |
| 167 "Run chrome and set a breakpoint on\n" | 167 "Run chrome and set a breakpoint on\n" |
| 168 "SyncManagerImpl::UpdateCredentials() " | 168 "syncer::SyncManagerImpl::UpdateCredentials() " |
| 169 "after logging into\n" | 169 "after logging into\n" |
| 170 "sync to get the token to pass into this utility.\n", | 170 "sync to get the token to pass into this utility.\n", |
| 171 argv[0], kEmailSwitch, kTokenSwitch, kHostPortSwitch, | 171 argv[0], kEmailSwitch, kTokenSwitch, kHostPortSwitch, |
| 172 kTrySslTcpFirstSwitch, kAllowInsecureConnectionSwitch); | 172 kTrySslTcpFirstSwitch, kAllowInsecureConnectionSwitch); |
| 173 return -1; | 173 return -1; |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Set up objects that monitor the network. | 176 // Set up objects that monitor the network. |
| 177 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( | 177 std::unique_ptr<net::NetworkChangeNotifier> network_change_notifier( |
| 178 net::NetworkChangeNotifier::Create()); | 178 net::NetworkChangeNotifier::Create()); |
| 179 | 179 |
| 180 const notifier::NotifierOptions& notifier_options = ParseNotifierOptions( | 180 const notifier::NotifierOptions& notifier_options = ParseNotifierOptions( |
| 181 command_line, new MyTestURLRequestContextGetter(io_thread.task_runner())); | 181 command_line, new MyTestURLRequestContextGetter(io_thread.task_runner())); |
| 182 NetworkChannelCreator network_channel_creator = | 182 syncer::NetworkChannelCreator network_channel_creator = |
| 183 NonBlockingInvalidator::MakePushClientChannelCreator(notifier_options); | 183 syncer::NonBlockingInvalidator::MakePushClientChannelCreator( |
| 184 notifier_options); |
| 184 const char kClientInfo[] = "sync_listen_notifications"; | 185 const char kClientInfo[] = "sync_listen_notifications"; |
| 185 NullInvalidationStateTracker null_invalidation_state_tracker; | 186 NullInvalidationStateTracker null_invalidation_state_tracker; |
| 186 std::unique_ptr<Invalidator> invalidator(new NonBlockingInvalidator( | 187 std::unique_ptr<Invalidator> invalidator(new NonBlockingInvalidator( |
| 187 network_channel_creator, base::RandBytesAsString(8), | 188 network_channel_creator, base::RandBytesAsString(8), |
| 188 null_invalidation_state_tracker.GetSavedInvalidations(), | 189 null_invalidation_state_tracker.GetSavedInvalidations(), |
| 189 null_invalidation_state_tracker.GetBootstrapData(), | 190 null_invalidation_state_tracker.GetBootstrapData(), |
| 190 &null_invalidation_state_tracker, kClientInfo, | 191 &null_invalidation_state_tracker, kClientInfo, |
| 191 notifier_options.request_context_getter)); | 192 notifier_options.request_context_getter)); |
| 192 | 193 |
| 193 NotificationPrinter notification_printer; | 194 NotificationPrinter notification_printer; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 205 io_thread.Stop(); | 206 io_thread.Stop(); |
| 206 return 0; | 207 return 0; |
| 207 } | 208 } |
| 208 | 209 |
| 209 } // namespace | 210 } // namespace |
| 210 } // namespace syncer | 211 } // namespace syncer |
| 211 | 212 |
| 212 int main(int argc, char* argv[]) { | 213 int main(int argc, char* argv[]) { |
| 213 return syncer::SyncListenNotificationsMain(argc, argv); | 214 return syncer::SyncListenNotificationsMain(argc, argv); |
| 214 } | 215 } |
| OLD | NEW |