Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1304)

Side by Side Diff: sync/tools/sync_listen_notifications.cc

Issue 819203002: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/tools/sync_client.cc ('k') | sync/tools/testserver/run_sync_testserver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « sync/tools/sync_client.cc ('k') | sync/tools/testserver/run_sync_testserver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698