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

Side by Side Diff: google_apis/gcm/tools/mcs_probe.cc

Issue 121743002: Renaming RMQStore to GCMStore and breaking out its interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding a GCM_EXPORT directive to GCMStoreImpl Created 6 years, 11 months 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 | « google_apis/gcm/gcm.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // A standalone tool for testing MCS connections and the MCS client on their 5 // A standalone tool for testing MCS connections and the MCS client on their
6 // own. 6 // own.
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <cstdio> 9 #include <cstdio>
10 #include <string> 10 #include <string>
11 11
12 #include "base/at_exit.h" 12 #include "base/at_exit.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
21 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
22 #include "base/threading/worker_pool.h" 22 #include "base/threading/worker_pool.h"
23 #include "base/time/default_clock.h" 23 #include "base/time/default_clock.h"
24 #include "base/values.h" 24 #include "base/values.h"
25 #include "google_apis/gcm/base/mcs_message.h" 25 #include "google_apis/gcm/base/mcs_message.h"
26 #include "google_apis/gcm/base/mcs_util.h" 26 #include "google_apis/gcm/base/mcs_util.h"
27 #include "google_apis/gcm/engine/connection_factory_impl.h" 27 #include "google_apis/gcm/engine/connection_factory_impl.h"
28 #include "google_apis/gcm/engine/gcm_store_impl.h"
28 #include "google_apis/gcm/engine/mcs_client.h" 29 #include "google_apis/gcm/engine/mcs_client.h"
29 #include "net/base/host_mapping_rules.h" 30 #include "net/base/host_mapping_rules.h"
30 #include "net/base/net_log_logger.h" 31 #include "net/base/net_log_logger.h"
31 #include "net/cert/cert_verifier.h" 32 #include "net/cert/cert_verifier.h"
32 #include "net/dns/host_resolver.h" 33 #include "net/dns/host_resolver.h"
33 #include "net/http/http_auth_handler_factory.h" 34 #include "net/http/http_auth_handler_factory.h"
34 #include "net/http/http_network_session.h" 35 #include "net/http/http_network_session.h"
35 #include "net/http/http_server_properties_impl.h" 36 #include "net/http/http_server_properties_impl.h"
36 #include "net/http/transport_security_state.h" 37 #include "net/http/transport_security_state.h"
37 #include "net/socket/client_socket_factory.h" 38 #include "net/socket/client_socket_factory.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 void BuildNetworkSession(); 170 void BuildNetworkSession();
170 171
171 void InitializationCallback(bool success, 172 void InitializationCallback(bool success,
172 uint64 restored_android_id, 173 uint64 restored_android_id,
173 uint64 restored_security_token); 174 uint64 restored_security_token);
174 175
175 base::DefaultClock clock_; 176 base::DefaultClock clock_;
176 177
177 CommandLine command_line_; 178 CommandLine command_line_;
178 179
179 base::FilePath rmq_path_; 180 base::FilePath gcm_store_path_;
180 uint64 android_id_; 181 uint64 android_id_;
181 uint64 secret_; 182 uint64 secret_;
182 std::string server_host_; 183 std::string server_host_;
183 int server_port_; 184 int server_port_;
184 185
185 // Network state. 186 // Network state.
186 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 187 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
187 MyTestNetLog net_log_; 188 MyTestNetLog net_log_;
188 scoped_ptr<net::NetLogLogger> logger_; 189 scoped_ptr<net::NetLogLogger> logger_;
189 scoped_ptr<base::Value> net_constants_; 190 scoped_ptr<base::Value> net_constants_;
190 scoped_ptr<net::HostResolver> host_resolver_; 191 scoped_ptr<net::HostResolver> host_resolver_;
191 scoped_ptr<net::CertVerifier> cert_verifier_; 192 scoped_ptr<net::CertVerifier> cert_verifier_;
192 scoped_ptr<net::ServerBoundCertService> system_server_bound_cert_service_; 193 scoped_ptr<net::ServerBoundCertService> system_server_bound_cert_service_;
193 scoped_ptr<net::TransportSecurityState> transport_security_state_; 194 scoped_ptr<net::TransportSecurityState> transport_security_state_;
194 scoped_ptr<net::URLSecurityManager> url_security_manager_; 195 scoped_ptr<net::URLSecurityManager> url_security_manager_;
195 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_; 196 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_;
196 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_; 197 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_;
197 scoped_ptr<net::HostMappingRules> host_mapping_rules_; 198 scoped_ptr<net::HostMappingRules> host_mapping_rules_;
198 scoped_refptr<net::HttpNetworkSession> network_session_; 199 scoped_refptr<net::HttpNetworkSession> network_session_;
199 scoped_ptr<net::ProxyService> proxy_service_; 200 scoped_ptr<net::ProxyService> proxy_service_;
200 201
201 scoped_ptr<RMQStore> rmq_store_; 202 scoped_ptr<GCMStore> gcm_store_;
202 scoped_ptr<MCSClient> mcs_client_; 203 scoped_ptr<MCSClient> mcs_client_;
203 204
204 scoped_ptr<ConnectionFactoryImpl> connection_factory_; 205 scoped_ptr<ConnectionFactoryImpl> connection_factory_;
205 206
206 base::Thread file_thread_; 207 base::Thread file_thread_;
207 208
208 scoped_ptr<base::RunLoop> run_loop_; 209 scoped_ptr<base::RunLoop> run_loop_;
209 }; 210 };
210 211
211 MCSProbe::MCSProbe( 212 MCSProbe::MCSProbe(
212 const CommandLine& command_line, 213 const CommandLine& command_line,
213 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) 214 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter)
214 : command_line_(command_line), 215 : command_line_(command_line),
215 rmq_path_(base::FilePath(FILE_PATH_LITERAL("gcm_rmq_store"))), 216 gcm_store_path_(base::FilePath(FILE_PATH_LITERAL("gcm_store"))),
216 android_id_(0), 217 android_id_(0),
217 secret_(0), 218 secret_(0),
218 server_port_(0), 219 server_port_(0),
219 url_request_context_getter_(url_request_context_getter), 220 url_request_context_getter_(url_request_context_getter),
220 file_thread_("FileThread") { 221 file_thread_("FileThread") {
221 if (command_line.HasSwitch(kRMQFileName)) { 222 if (command_line.HasSwitch(kRMQFileName)) {
222 rmq_path_ = command_line.GetSwitchValuePath(kRMQFileName); 223 gcm_store_path_ = command_line.GetSwitchValuePath(kRMQFileName);
223 } 224 }
224 if (command_line.HasSwitch(kAndroidIdSwitch)) { 225 if (command_line.HasSwitch(kAndroidIdSwitch)) {
225 base::StringToUint64(command_line.GetSwitchValueASCII(kAndroidIdSwitch), 226 base::StringToUint64(command_line.GetSwitchValueASCII(kAndroidIdSwitch),
226 &android_id_); 227 &android_id_);
227 } 228 }
228 if (command_line.HasSwitch(kSecretSwitch)) { 229 if (command_line.HasSwitch(kSecretSwitch)) {
229 base::StringToUint64(command_line.GetSwitchValueASCII(kSecretSwitch), 230 base::StringToUint64(command_line.GetSwitchValueASCII(kSecretSwitch),
230 &secret_); 231 &secret_);
231 } 232 }
232 server_host_ = kMCSServerHost; 233 server_host_ = kMCSServerHost;
(...skipping 13 matching lines...) Expand all
246 247
247 void MCSProbe::Start() { 248 void MCSProbe::Start() {
248 file_thread_.Start(); 249 file_thread_.Start();
249 InitializeNetworkState(); 250 InitializeNetworkState();
250 BuildNetworkSession(); 251 BuildNetworkSession();
251 connection_factory_.reset( 252 connection_factory_.reset(
252 new ConnectionFactoryImpl(GURL("https://" + net::HostPortPair( 253 new ConnectionFactoryImpl(GURL("https://" + net::HostPortPair(
253 server_host_, server_port_).ToString()), 254 server_host_, server_port_).ToString()),
254 network_session_, 255 network_session_,
255 &net_log_)); 256 &net_log_));
256 rmq_store_.reset(new RMQStore(rmq_path_, file_thread_.message_loop_proxy())); 257 gcm_store_.reset(
258 new GCMStoreImpl(gcm_store_path_, file_thread_.message_loop_proxy()));
257 mcs_client_.reset(new MCSClient(&clock_, 259 mcs_client_.reset(new MCSClient(&clock_,
258 connection_factory_.get(), 260 connection_factory_.get(),
259 rmq_store_.get())); 261 gcm_store_.get()));
260 run_loop_.reset(new base::RunLoop()); 262 run_loop_.reset(new base::RunLoop());
261 rmq_store_->Load(base::Bind(&MCSClient::Initialize, 263 gcm_store_->Load(base::Bind(
262 base::Unretained(mcs_client_.get()), 264 &MCSClient::Initialize,
263 base::Bind(&MCSProbe::InitializationCallback, 265 base::Unretained(mcs_client_.get()),
264 base::Unretained(this)), 266 base::Bind(&MCSProbe::InitializationCallback, base::Unretained(this)),
265 base::Bind(&MessageReceivedCallback), 267 base::Bind(&MessageReceivedCallback),
266 base::Bind(&MessageSentCallback))); 268 base::Bind(&MessageSentCallback)));
267 run_loop_->Run(); 269 run_loop_->Run();
268 } 270 }
269 271
270 void MCSProbe::InitializeNetworkState() { 272 void MCSProbe::InitializeNetworkState() {
271 FILE* log_file = NULL; 273 FILE* log_file = NULL;
272 if (command_line_.HasSwitch(kLogFileSwitch)) { 274 if (command_line_.HasSwitch(kLogFileSwitch)) {
273 base::FilePath log_path = command_line_.GetSwitchValuePath(kLogFileSwitch); 275 base::FilePath log_path = command_line_.GetSwitchValuePath(kLogFileSwitch);
274 #if defined(OS_WIN) 276 #if defined(OS_WIN)
275 log_file = _wfopen(log_path.value().c_str(), L"w"); 277 log_file = _wfopen(log_path.value().c_str(), L"w");
276 #elif defined(OS_POSIX) 278 #elif defined(OS_POSIX)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 372
371 return 0; 373 return 0;
372 } 374 }
373 375
374 } // namespace 376 } // namespace
375 } // namespace gcm 377 } // namespace gcm
376 378
377 int main(int argc, char* argv[]) { 379 int main(int argc, char* argv[]) {
378 return gcm::MCSProbeMain(argc, argv); 380 return gcm::MCSProbeMain(argc, argv);
379 } 381 }
OLDNEW
« no previous file with comments | « google_apis/gcm/gcm.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698