| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/cronet/ios/cronet_environment.h" | 5 #include "components/cronet/ios/cronet_environment.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "url/scheme_host_port.h" | 49 #include "url/scheme_host_port.h" |
| 50 #include "url/url_util.h" | 50 #include "url/url_util.h" |
| 51 | 51 |
| 52 namespace { | 52 namespace { |
| 53 | 53 |
| 54 base::AtExitManager* g_at_exit_ = nullptr; | 54 base::AtExitManager* g_at_exit_ = nullptr; |
| 55 net::NetworkChangeNotifier* g_network_change_notifier = nullptr; | 55 net::NetworkChangeNotifier* g_network_change_notifier = nullptr; |
| 56 // MessageLoop on the main thread. | 56 // MessageLoop on the main thread. |
| 57 base::MessageLoop* g_main_message_loop = nullptr; | 57 base::MessageLoop* g_main_message_loop = nullptr; |
| 58 | 58 |
| 59 #if USE_FAKE_CERT_VERIFIER | |
| 60 // TODO(mef): Remove this after GRPC testing is done. | |
| 61 class FakeCertVerifier : public net::CertVerifier { | |
| 62 public: | |
| 63 FakeCertVerifier() {} | |
| 64 | |
| 65 ~FakeCertVerifier() override {} | |
| 66 | |
| 67 // CertVerifier implementation | |
| 68 int Verify(net::X509Certificate* cert, | |
| 69 const std::string& hostname, | |
| 70 const std::string& ocsp_response, | |
| 71 int flags, | |
| 72 net::CRLSet* crl_set, | |
| 73 net::CertVerifyResult* verify_result, | |
| 74 const net::CompletionCallback& callback, | |
| 75 std::unique_ptr<Request>* out_req, | |
| 76 const net::BoundNetLog& net_log) override { | |
| 77 // It's all good! | |
| 78 verify_result->verified_cert = cert; | |
| 79 verify_result->cert_status = MapNetErrorToCertStatus(net::OK); | |
| 80 return net::OK; | |
| 81 } | |
| 82 }; | |
| 83 #endif // USE_FAKE_CERT_VERIFIER | |
| 84 | |
| 85 } // namespace | 59 } // namespace |
| 86 | 60 |
| 87 namespace cronet { | 61 namespace cronet { |
| 88 | 62 |
| 89 bool CronetEnvironment::IsOnNetworkThread() { | 63 bool CronetEnvironment::IsOnNetworkThread() { |
| 90 return network_io_thread_->task_runner()->BelongsToCurrentThread(); | 64 return network_io_thread_->task_runner()->BelongsToCurrentThread(); |
| 91 } | 65 } |
| 92 | 66 |
| 93 void CronetEnvironment::PostToNetworkThread( | 67 void CronetEnvironment::PostToNetworkThread( |
| 94 const tracked_objects::Location& from_here, | 68 const tracked_objects::Location& from_here, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 quic_hints_.push_back(net::HostPortPair(host, port)); | 180 quic_hints_.push_back(net::HostPortPair(host, port)); |
| 207 } | 181 } |
| 208 | 182 |
| 209 CronetEnvironment::CronetEnvironment(const std::string& user_agent_product_name) | 183 CronetEnvironment::CronetEnvironment(const std::string& user_agent_product_name) |
| 210 : http2_enabled_(false), | 184 : http2_enabled_(false), |
| 211 quic_enabled_(false), | 185 quic_enabled_(false), |
| 212 user_agent_product_name_(user_agent_product_name), | 186 user_agent_product_name_(user_agent_product_name), |
| 213 net_log_(new net::NetLog) {} | 187 net_log_(new net::NetLog) {} |
| 214 | 188 |
| 215 void CronetEnvironment::Start() { | 189 void CronetEnvironment::Start() { |
| 216 #if USE_FAKE_CERT_VERIFIER | |
| 217 // TODO(mef): Remove this and FakeCertVerifier after GRPC testing. | |
| 218 set_cert_verifier(std::unique_ptr<net::CertVerifier>(new FakeCertVerifier())); | |
| 219 #endif // USE_FAKE_CERT_VERIFIER | |
| 220 | |
| 221 // Threads setup. | 190 // Threads setup. |
| 222 network_cache_thread_.reset(new base::Thread("Chrome Network Cache Thread")); | 191 network_cache_thread_.reset(new base::Thread("Chrome Network Cache Thread")); |
| 223 network_cache_thread_->StartWithOptions( | 192 network_cache_thread_->StartWithOptions( |
| 224 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 193 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 225 network_io_thread_.reset(new base::Thread("Chrome Network IO Thread")); | 194 network_io_thread_.reset(new base::Thread("Chrome Network IO Thread")); |
| 226 network_io_thread_->StartWithOptions( | 195 network_io_thread_->StartWithOptions( |
| 227 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 196 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 228 file_thread_.reset(new base::Thread("Chrome File Thread")); | 197 file_thread_.reset(new base::Thread("Chrome File Thread")); |
| 229 file_thread_->StartWithOptions( | 198 file_thread_->StartWithOptions( |
| 230 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 199 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 const net::HttpUserAgentSettings* user_agent_settings = | 342 const net::HttpUserAgentSettings* user_agent_settings = |
| 374 main_context_->http_user_agent_settings(); | 343 main_context_->http_user_agent_settings(); |
| 375 if (!user_agent_settings) { | 344 if (!user_agent_settings) { |
| 376 return nullptr; | 345 return nullptr; |
| 377 } | 346 } |
| 378 | 347 |
| 379 return user_agent_settings->GetUserAgent(); | 348 return user_agent_settings->GetUserAgent(); |
| 380 } | 349 } |
| 381 | 350 |
| 382 } // namespace cronet | 351 } // namespace cronet |
| OLD | NEW |