OLD | NEW |
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> |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "google_apis/gcm/engine/checkin_request.h" | 31 #include "google_apis/gcm/engine/checkin_request.h" |
32 #include "google_apis/gcm/engine/connection_factory_impl.h" | 32 #include "google_apis/gcm/engine/connection_factory_impl.h" |
33 #include "google_apis/gcm/engine/gcm_store_impl.h" | 33 #include "google_apis/gcm/engine/gcm_store_impl.h" |
34 #include "google_apis/gcm/engine/gservices_settings.h" | 34 #include "google_apis/gcm/engine/gservices_settings.h" |
35 #include "google_apis/gcm/engine/mcs_client.h" | 35 #include "google_apis/gcm/engine/mcs_client.h" |
36 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" | 36 #include "google_apis/gcm/monitoring/fake_gcm_stats_recorder.h" |
37 #include "net/base/host_mapping_rules.h" | 37 #include "net/base/host_mapping_rules.h" |
38 #include "net/cert/cert_verifier.h" | 38 #include "net/cert/cert_verifier.h" |
39 #include "net/dns/host_resolver.h" | 39 #include "net/dns/host_resolver.h" |
40 #include "net/http/http_auth_handler_factory.h" | 40 #include "net/http/http_auth_handler_factory.h" |
| 41 #include "net/http/http_auth_preferences.h" |
| 42 #include "net/http/http_auth_scheme.h" |
41 #include "net/http/http_network_session.h" | 43 #include "net/http/http_network_session.h" |
42 #include "net/http/http_server_properties_impl.h" | 44 #include "net/http/http_server_properties_impl.h" |
43 #include "net/http/transport_security_state.h" | 45 #include "net/http/transport_security_state.h" |
44 #include "net/log/write_to_file_net_log_observer.h" | 46 #include "net/log/write_to_file_net_log_observer.h" |
45 #include "net/socket/client_socket_factory.h" | 47 #include "net/socket/client_socket_factory.h" |
46 #include "net/socket/ssl_client_socket.h" | 48 #include "net/socket/ssl_client_socket.h" |
47 #include "net/ssl/channel_id_service.h" | 49 #include "net/ssl/channel_id_service.h" |
48 #include "net/ssl/default_channel_id_store.h" | 50 #include "net/ssl/default_channel_id_store.h" |
49 #include "net/url_request/url_request_test_util.h" | 51 #include "net/url_request/url_request_test_util.h" |
50 | 52 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 int flags, | 178 int flags, |
177 net::CRLSet* crl_set, | 179 net::CRLSet* crl_set, |
178 net::CertVerifyResult* verify_result, | 180 net::CertVerifyResult* verify_result, |
179 const net::CompletionCallback& callback, | 181 const net::CompletionCallback& callback, |
180 scoped_ptr<Request>* out_req, | 182 scoped_ptr<Request>* out_req, |
181 const net::BoundNetLog& net_log) override { | 183 const net::BoundNetLog& net_log) override { |
182 return net::OK; | 184 return net::OK; |
183 } | 185 } |
184 }; | 186 }; |
185 | 187 |
| 188 class MCSProbeAuthPreferences : public net::HttpAuthPreferences { |
| 189 public: |
| 190 MCSProbeAuthPreferences() |
| 191 : HttpAuthPreferences(std::vector<std::string>() |
| 192 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 193 , |
| 194 std::string() |
| 195 #endif |
| 196 ) { |
| 197 } |
| 198 bool IsSupportedScheme(const std::string& scheme) const override { |
| 199 return scheme == std::string(net::kBasicAuthScheme); |
| 200 } |
| 201 bool NegotiateDisableCnameLookup() const override { return false; } |
| 202 bool NegotiateEnablePort() const override { return false; } |
| 203 bool CanUseDefaultCredentials(const GURL& auth_origin) const override { |
| 204 return false; |
| 205 } |
| 206 bool CanDelegate(const GURL& auth_origin) const override { return false; } |
| 207 }; |
| 208 |
186 class MCSProbe { | 209 class MCSProbe { |
187 public: | 210 public: |
188 MCSProbe( | 211 MCSProbe( |
189 const base::CommandLine& command_line, | 212 const base::CommandLine& command_line, |
190 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); | 213 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); |
191 ~MCSProbe(); | 214 ~MCSProbe(); |
192 | 215 |
193 void Start(); | 216 void Start(); |
194 | 217 |
195 uint64 android_id() const { return android_id_; } | 218 uint64 android_id() const { return android_id_; } |
(...skipping 22 matching lines...) Expand all Loading... |
218 int server_port_; | 241 int server_port_; |
219 | 242 |
220 // Network state. | 243 // Network state. |
221 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 244 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
222 net::NetLog net_log_; | 245 net::NetLog net_log_; |
223 scoped_ptr<net::WriteToFileNetLogObserver> logger_; | 246 scoped_ptr<net::WriteToFileNetLogObserver> logger_; |
224 scoped_ptr<net::HostResolver> host_resolver_; | 247 scoped_ptr<net::HostResolver> host_resolver_; |
225 scoped_ptr<net::CertVerifier> cert_verifier_; | 248 scoped_ptr<net::CertVerifier> cert_verifier_; |
226 scoped_ptr<net::ChannelIDService> system_channel_id_service_; | 249 scoped_ptr<net::ChannelIDService> system_channel_id_service_; |
227 scoped_ptr<net::TransportSecurityState> transport_security_state_; | 250 scoped_ptr<net::TransportSecurityState> transport_security_state_; |
228 scoped_ptr<net::URLSecurityManager> url_security_manager_; | 251 MCSProbeAuthPreferences http_auth_preferences_; |
229 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_; | 252 scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory_; |
230 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_; | 253 scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_; |
231 scoped_ptr<net::HostMappingRules> host_mapping_rules_; | 254 scoped_ptr<net::HostMappingRules> host_mapping_rules_; |
232 scoped_ptr<net::HttpNetworkSession> network_session_; | 255 scoped_ptr<net::HttpNetworkSession> network_session_; |
233 scoped_ptr<net::ProxyService> proxy_service_; | 256 scoped_ptr<net::ProxyService> proxy_service_; |
234 | 257 |
235 FakeGCMStatsRecorder recorder_; | 258 FakeGCMStatsRecorder recorder_; |
236 scoped_ptr<GCMStore> gcm_store_; | 259 scoped_ptr<GCMStore> gcm_store_; |
237 scoped_ptr<MCSClient> mcs_client_; | 260 scoped_ptr<MCSClient> mcs_client_; |
238 scoped_ptr<CheckinRequest> checkin_request_; | 261 scoped_ptr<CheckinRequest> checkin_request_; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 cert_verifier_.reset(new MyTestCertVerifier()); | 392 cert_verifier_.reset(new MyTestCertVerifier()); |
370 } else { | 393 } else { |
371 cert_verifier_ = net::CertVerifier::CreateDefault(); | 394 cert_verifier_ = net::CertVerifier::CreateDefault(); |
372 } | 395 } |
373 system_channel_id_service_.reset( | 396 system_channel_id_service_.reset( |
374 new net::ChannelIDService( | 397 new net::ChannelIDService( |
375 new net::DefaultChannelIDStore(NULL), | 398 new net::DefaultChannelIDStore(NULL), |
376 base::WorkerPool::GetTaskRunner(true))); | 399 base::WorkerPool::GetTaskRunner(true))); |
377 | 400 |
378 transport_security_state_.reset(new net::TransportSecurityState()); | 401 transport_security_state_.reset(new net::TransportSecurityState()); |
379 url_security_manager_.reset(net::URLSecurityManager::Create(NULL, NULL)); | 402 http_auth_handler_factory_ = |
380 http_auth_handler_factory_.reset(net::HttpAuthHandlerRegistryFactory::Create( | 403 net::HttpAuthHandlerRegistryFactory::Create(&http_auth_preferences_, |
381 std::vector<std::string>(1, "basic"), url_security_manager_.get(), | 404 host_resolver_.get()) |
382 host_resolver_.get(), std::string(), std::string(), false, false)); | 405 .Pass(); |
383 http_server_properties_.reset(new net::HttpServerPropertiesImpl()); | 406 http_server_properties_.reset(new net::HttpServerPropertiesImpl()); |
384 host_mapping_rules_.reset(new net::HostMappingRules()); | 407 host_mapping_rules_.reset(new net::HostMappingRules()); |
385 proxy_service_ = net::ProxyService::CreateDirectWithNetLog(&net_log_); | 408 proxy_service_ = net::ProxyService::CreateDirectWithNetLog(&net_log_); |
386 } | 409 } |
387 | 410 |
388 void MCSProbe::BuildNetworkSession() { | 411 void MCSProbe::BuildNetworkSession() { |
389 net::HttpNetworkSession::Params session_params; | 412 net::HttpNetworkSession::Params session_params; |
390 session_params.host_resolver = host_resolver_.get(); | 413 session_params.host_resolver = host_resolver_.get(); |
391 session_params.cert_verifier = cert_verifier_.get(); | 414 session_params.cert_verifier = cert_verifier_.get(); |
392 session_params.channel_id_service = system_channel_id_service_.get(); | 415 session_params.channel_id_service = system_channel_id_service_.get(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 | 513 |
491 return 0; | 514 return 0; |
492 } | 515 } |
493 | 516 |
494 } // namespace | 517 } // namespace |
495 } // namespace gcm | 518 } // namespace gcm |
496 | 519 |
497 int main(int argc, char* argv[]) { | 520 int main(int argc, char* argv[]) { |
498 return gcm::MCSProbeMain(argc, argv); | 521 return gcm::MCSProbeMain(argc, argv); |
499 } | 522 } |
OLD | NEW |