| 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 "net/url_request/url_fetcher_impl.h" | 5 #include "net/url_request/url_fetcher_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
| 13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "crypto/nss_util.h" | 16 #include "crypto/nss_util.h" |
| 17 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
| 18 #include "net/test/test_server.h" | 18 #include "net/test/test_server.h" |
| 19 #include "net/url_request/url_fetcher_delegate.h" | 19 #include "net/url_request/url_fetcher_delegate.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
| 21 #include "net/url_request/url_request_test_util.h" | 21 #include "net/url_request/url_request_test_util.h" |
| 22 #include "net/url_request/url_request_throttler_manager.h" | 22 #include "net/url_request/url_request_throttler_manager.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 24 |
| 25 #if defined(USE_NSS) | 25 #if defined(USE_NSS) || defined(OS_IOS) |
| 26 #include "net/ocsp/nss_ocsp.h" | 26 #include "net/ocsp/nss_ocsp.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace net { | 29 namespace net { |
| 30 | 30 |
| 31 using base::Time; | 31 using base::Time; |
| 32 using base::TimeDelta; | 32 using base::TimeDelta; |
| 33 | 33 |
| 34 // TODO(eroman): Add a regression test for http://crbug.com/40505. | 34 // TODO(eroman): Add a regression test for http://crbug.com/40505. |
| 35 | 35 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return context_.get(); | 106 return context_.get(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 protected: | 109 protected: |
| 110 // testing::Test: | 110 // testing::Test: |
| 111 virtual void SetUp() OVERRIDE { | 111 virtual void SetUp() OVERRIDE { |
| 112 testing::Test::SetUp(); | 112 testing::Test::SetUp(); |
| 113 | 113 |
| 114 io_message_loop_proxy_ = base::MessageLoopProxy::current(); | 114 io_message_loop_proxy_ = base::MessageLoopProxy::current(); |
| 115 | 115 |
| 116 #if defined(USE_NSS) | 116 #if defined(USE_NSS) || defined(OS_IOS) |
| 117 crypto::EnsureNSSInit(); | 117 crypto::EnsureNSSInit(); |
| 118 EnsureNSSHttpIOInit(); | 118 EnsureNSSHttpIOInit(); |
| 119 #endif | 119 #endif |
| 120 } | 120 } |
| 121 | 121 |
| 122 virtual void TearDown() OVERRIDE { | 122 virtual void TearDown() OVERRIDE { |
| 123 #if defined(USE_NSS) | 123 #if defined(USE_NSS) || defined(OS_IOS) |
| 124 ShutdownNSSHttpIO(); | 124 ShutdownNSSHttpIO(); |
| 125 #endif | 125 #endif |
| 126 } | 126 } |
| 127 | 127 |
| 128 // URLFetcher is designed to run on the main UI thread, but in our tests | 128 // URLFetcher is designed to run on the main UI thread, but in our tests |
| 129 // we assume that the current thread is the IO thread where the URLFetcher | 129 // we assume that the current thread is the IO thread where the URLFetcher |
| 130 // dispatches its requests to. When we wish to simulate being used from | 130 // dispatches its requests to. When we wish to simulate being used from |
| 131 // a UI thread, we dispatch a worker thread to do so. | 131 // a UI thread, we dispatch a worker thread to do so. |
| 132 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 132 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
| 133 | 133 |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). | 1271 MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit(). |
| 1272 | 1272 |
| 1273 MessageLoop::current()->RunUntilIdle(); | 1273 MessageLoop::current()->RunUntilIdle(); |
| 1274 ASSERT_FALSE(file_util::PathExists(file_path_)) | 1274 ASSERT_FALSE(file_util::PathExists(file_path_)) |
| 1275 << file_path_.value() << " not removed."; | 1275 << file_path_.value() << " not removed."; |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 } // namespace | 1278 } // namespace |
| 1279 | 1279 |
| 1280 } // namespace net | 1280 } // namespace net |
| OLD | NEW |