| 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 "chrome/browser/net/connection_tester.h" | 5 #include "chrome/browser/net/connection_tester.h" |
| 6 | 6 |
| 7 #include "base/prefs/testing_pref_service.h" | 7 #include "base/prefs/testing_pref_service.h" |
| 8 #include "content/public/browser/cookie_store_factory.h" | 8 #include "content/public/browser/cookie_store_factory.h" |
| 9 #include "content/public/test/test_browser_thread.h" | 9 #include "content/public/test/test_browser_thread.h" |
| 10 #include "content/public/browser/cookie_store_factory.h" | 10 #include "content/public/browser/cookie_store_factory.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 int completed_connection_test_suite_count_; | 82 int completed_connection_test_suite_count_; |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // The test fixture is responsible for: | 85 // The test fixture is responsible for: |
| 86 // - Making sure each test has an IO loop running | 86 // - Making sure each test has an IO loop running |
| 87 // - Catching any host resolve requests and mapping them to localhost | 87 // - Catching any host resolve requests and mapping them to localhost |
| 88 // (so the test doesn't use any external network dependencies). | 88 // (so the test doesn't use any external network dependencies). |
| 89 class ConnectionTesterTest : public PlatformTest { | 89 class ConnectionTesterTest : public PlatformTest { |
| 90 public: | 90 public: |
| 91 ConnectionTesterTest() | 91 ConnectionTesterTest() |
| 92 : message_loop_(base::MessageLoop::TYPE_IO), | 92 : io_thread_(BrowserThread::IO, &message_loop_), |
| 93 io_thread_(BrowserThread::IO, &message_loop_), | |
| 94 test_server_(net::SpawnedTestServer::TYPE_HTTP, | 93 test_server_(net::SpawnedTestServer::TYPE_HTTP, |
| 95 net::SpawnedTestServer::kLocalhost, | 94 net::SpawnedTestServer::kLocalhost, |
| 96 // Nothing is read in this directory. | 95 // Nothing is read in this directory. |
| 97 base::FilePath(FILE_PATH_LITERAL("chrome"))), | 96 base::FilePath(FILE_PATH_LITERAL("chrome"))), |
| 98 proxy_script_fetcher_context_(new net::URLRequestContext) { | 97 proxy_script_fetcher_context_(new net::URLRequestContext) { |
| 99 InitializeRequestContext(); | 98 InitializeRequestContext(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 protected: | 101 protected: |
| 103 // Destroy last the MessageLoop last to give a chance for objects like | 102 // Destroy last the MessageLoop last to give a chance for objects like |
| 104 // ObserverListThreadSave to shut down properly. For example, | 103 // ObserverListThreadSave to shut down properly. For example, |
| 105 // SSLClientAuthCache calls RemoveObserver when destroyed, but if the | 104 // SSLClientAuthCache calls RemoveObserver when destroyed, but if the |
| 106 // MessageLoop is already destroyed, then the RemoveObserver will be a | 105 // MessageLoop is already destroyed, then the RemoveObserver will be a |
| 107 // no-op, and the ObserverList will contain invalid entries. | 106 // no-op, and the ObserverList will contain invalid entries. |
| 108 base::MessageLoop message_loop_; | 107 base::MessageLoopForIO message_loop_; |
| 109 content::TestBrowserThread io_thread_; | 108 content::TestBrowserThread io_thread_; |
| 110 net::SpawnedTestServer test_server_; | 109 net::SpawnedTestServer test_server_; |
| 111 ConnectionTesterDelegate test_delegate_; | 110 ConnectionTesterDelegate test_delegate_; |
| 112 net::MockHostResolver host_resolver_; | 111 net::MockHostResolver host_resolver_; |
| 113 scoped_ptr<net::CertVerifier> cert_verifier_; | 112 scoped_ptr<net::CertVerifier> cert_verifier_; |
| 114 scoped_ptr<net::TransportSecurityState> transport_security_state_; | 113 scoped_ptr<net::TransportSecurityState> transport_security_state_; |
| 115 scoped_ptr<net::ProxyService> proxy_service_; | 114 scoped_ptr<net::ProxyService> proxy_service_; |
| 116 scoped_refptr<net::SSLConfigService> ssl_config_service_; | 115 scoped_refptr<net::SSLConfigService> ssl_config_service_; |
| 117 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; | 116 scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; |
| 118 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; | 117 net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer | 209 // net::ClientSocketPoolBaseHelper, since the "Group" holds a pointer |
| 211 // |backup_task| that it will try to deref during the destructor, but | 210 // |backup_task| that it will try to deref during the destructor, but |
| 212 // depending on the order that pending tasks were deleted in, it might | 211 // depending on the order that pending tasks were deleted in, it might |
| 213 // already be invalid! See http://crbug.com/43291. | 212 // already be invalid! See http://crbug.com/43291. |
| 214 base::MessageLoop::current()->PostTask(FROM_HERE, | 213 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 215 base::MessageLoop::QuitClosure()); | 214 base::MessageLoop::QuitClosure()); |
| 216 base::MessageLoop::current()->Run(); | 215 base::MessageLoop::current()->Run(); |
| 217 } | 216 } |
| 218 | 217 |
| 219 } // namespace | 218 } // namespace |
| OLD | NEW |