| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/path_service.h" | 19 #include "base/path_service.h" |
| 19 #include "base/run_loop.h" | 20 #include "base/run_loop.h" |
| 20 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 23 #include "base/synchronization/waitable_event.h" | 24 #include "base/synchronization/waitable_event.h" |
| 24 #include "base/thread_task_runner_handle.h" | 25 #include "base/thread_task_runner_handle.h" |
| 25 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
| 26 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 27 #include "crypto/nss_util.h" | 28 #include "crypto/nss_util.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 public: | 162 public: |
| 162 // All requests for |hanging_domain| will hang on host resolution until the | 163 // All requests for |hanging_domain| will hang on host resolution until the |
| 163 // mock_resolver()->ResolveAllPending() is called. | 164 // mock_resolver()->ResolveAllPending() is called. |
| 164 explicit FetcherTestURLRequestContext(const std::string& hanging_domain) | 165 explicit FetcherTestURLRequestContext(const std::string& hanging_domain) |
| 165 : TestURLRequestContext(true), mock_resolver_(new MockHostResolver()) { | 166 : TestURLRequestContext(true), mock_resolver_(new MockHostResolver()) { |
| 166 mock_resolver_->set_ondemand_mode(true); | 167 mock_resolver_->set_ondemand_mode(true); |
| 167 mock_resolver_->rules()->AddRule(hanging_domain, "127.0.0.1"); | 168 mock_resolver_->rules()->AddRule(hanging_domain, "127.0.0.1"); |
| 168 // Pass ownership to ContextStorage to ensure correct destruction order. | 169 // Pass ownership to ContextStorage to ensure correct destruction order. |
| 169 context_storage_.set_host_resolver( | 170 context_storage_.set_host_resolver( |
| 170 scoped_ptr<HostResolver>(mock_resolver_)); | 171 scoped_ptr<HostResolver>(mock_resolver_)); |
| 171 context_storage_.set_throttler_manager(new URLRequestThrottlerManager()); | 172 context_storage_.set_throttler_manager( |
| 173 make_scoped_ptr(new URLRequestThrottlerManager())); |
| 172 Init(); | 174 Init(); |
| 173 } | 175 } |
| 174 | 176 |
| 175 MockHostResolver* mock_resolver() { return mock_resolver_; } | 177 MockHostResolver* mock_resolver() { return mock_resolver_; } |
| 176 | 178 |
| 177 private: | 179 private: |
| 178 MockHostResolver* mock_resolver_; | 180 MockHostResolver* mock_resolver_; |
| 179 | 181 |
| 180 DISALLOW_COPY_AND_ASSIGN(FetcherTestURLRequestContext); | 182 DISALLOW_COPY_AND_ASSIGN(FetcherTestURLRequestContext); |
| 181 }; | 183 }; |
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1415 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); | 1417 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); |
| 1416 EXPECT_TRUE(delegate.fetcher()->GetCookies().empty()); | 1418 EXPECT_TRUE(delegate.fetcher()->GetCookies().empty()); |
| 1417 std::string data; | 1419 std::string data; |
| 1418 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); | 1420 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); |
| 1419 EXPECT_TRUE(data.empty()); | 1421 EXPECT_TRUE(data.empty()); |
| 1420 } | 1422 } |
| 1421 | 1423 |
| 1422 } // namespace | 1424 } // namespace |
| 1423 | 1425 |
| 1424 } // namespace net | 1426 } // namespace net |
| OLD | NEW |