| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/loader/async_revalidation_manager.h" | 5 #include "content/browser/loader/async_revalidation_manager.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/shared_memory_handle.h" | 15 #include "base/memory/shared_memory_handle.h" |
| 16 #include "base/pickle.h" | 16 #include "base/pickle.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "content/browser/child_process_security_policy_impl.h" | 19 #include "content/browser/child_process_security_policy_impl.h" |
| 20 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 20 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 21 #include "content/browser/loader/resource_message_filter.h" | 21 #include "content/browser/loader/resource_message_filter.h" |
| 22 #include "content/browser/loader_delegate_impl.h" |
| 22 #include "content/common/child_process_host_impl.h" | 23 #include "content/common/child_process_host_impl.h" |
| 23 #include "content/common/resource_messages.h" | 24 #include "content/common/resource_messages.h" |
| 24 #include "content/common/resource_request.h" | 25 #include "content/common/resource_request.h" |
| 25 #include "content/public/browser/resource_context.h" | 26 #include "content/public/browser/resource_context.h" |
| 26 #include "content/public/common/appcache_info.h" | 27 #include "content/public/common/appcache_info.h" |
| 27 #include "content/public/common/process_type.h" | 28 #include "content/public/common/process_type.h" |
| 28 #include "content/public/common/resource_type.h" | 29 #include "content/public/common/resource_type.h" |
| 29 #include "content/public/test/test_browser_context.h" | 30 #include "content/public/test/test_browser_context.h" |
| 30 #include "content/public/test/test_browser_thread_bundle.h" | 31 #include "content/public/test/test_browser_thread_bundle.h" |
| 31 #include "ipc/ipc_param_traits.h" | 32 #include "ipc/ipc_param_traits.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 request.allow_download = true; | 264 request.allow_download = true; |
| 264 return request; | 265 return request; |
| 265 } | 266 } |
| 266 | 267 |
| 267 class AsyncRevalidationManagerTest : public ::testing::Test { | 268 class AsyncRevalidationManagerTest : public ::testing::Test { |
| 268 protected: | 269 protected: |
| 269 AsyncRevalidationManagerTest( | 270 AsyncRevalidationManagerTest( |
| 270 std::unique_ptr<net::TestNetworkDelegate> network_delegate) | 271 std::unique_ptr<net::TestNetworkDelegate> network_delegate) |
| 271 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), | 272 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 272 network_delegate_(std::move(network_delegate)) { | 273 network_delegate_(std::move(network_delegate)) { |
| 274 host_.SetLoaderDelegate(&loader_delegate_); |
| 273 browser_context_.reset(new TestBrowserContext()); | 275 browser_context_.reset(new TestBrowserContext()); |
| 274 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); | 276 BrowserContext::EnsureResourceContextInitialized(browser_context_.get()); |
| 275 base::RunLoop().RunUntilIdle(); | 277 base::RunLoop().RunUntilIdle(); |
| 276 ResourceContext* resource_context = browser_context_->GetResourceContext(); | 278 ResourceContext* resource_context = browser_context_->GetResourceContext(); |
| 277 filter_ = new BlackholeFilter(resource_context); | 279 filter_ = new BlackholeFilter(resource_context); |
| 278 net::URLRequestContext* request_context = | 280 net::URLRequestContext* request_context = |
| 279 resource_context->GetRequestContext(); | 281 resource_context->GetRequestContext(); |
| 280 job_factory_.reset(new TestURLRequestJobFactory); | 282 job_factory_.reset(new TestURLRequestJobFactory); |
| 281 request_context->set_job_factory(job_factory_.get()); | 283 request_context->set_job_factory(job_factory_.get()); |
| 282 request_context->set_network_delegate(network_delegate_.get()); | 284 request_context->set_network_delegate(network_delegate_.get()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 ChildProcessSecurityPolicyImpl::GetInstance(); | 316 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 315 if (!policy->IsWebSafeScheme(scheme)) | 317 if (!policy->IsWebSafeScheme(scheme)) |
| 316 policy->RegisterWebSafeScheme(scheme); | 318 policy->RegisterWebSafeScheme(scheme); |
| 317 } | 319 } |
| 318 | 320 |
| 319 content::TestBrowserThreadBundle thread_bundle_; | 321 content::TestBrowserThreadBundle thread_bundle_; |
| 320 std::unique_ptr<TestBrowserContext> browser_context_; | 322 std::unique_ptr<TestBrowserContext> browser_context_; |
| 321 std::unique_ptr<TestURLRequestJobFactory> job_factory_; | 323 std::unique_ptr<TestURLRequestJobFactory> job_factory_; |
| 322 scoped_refptr<BlackholeFilter> filter_; | 324 scoped_refptr<BlackholeFilter> filter_; |
| 323 std::unique_ptr<net::TestNetworkDelegate> network_delegate_; | 325 std::unique_ptr<net::TestNetworkDelegate> network_delegate_; |
| 326 LoaderDelegateImpl loader_delegate_; |
| 324 ResourceDispatcherHostImpl host_; | 327 ResourceDispatcherHostImpl host_; |
| 325 }; | 328 }; |
| 326 | 329 |
| 327 TEST_F(AsyncRevalidationManagerTest, SupportsAsyncRevalidation) { | 330 TEST_F(AsyncRevalidationManagerTest, SupportsAsyncRevalidation) { |
| 328 SetResponse(net::URLRequestTestJob::test_headers(), "delay complete"); | 331 SetResponse(net::URLRequestTestJob::test_headers(), "delay complete"); |
| 329 MakeTestRequest(0, 1, GURL("http://example.com/baz")); | 332 MakeTestRequest(0, 1, GURL("http://example.com/baz")); |
| 330 | 333 |
| 331 net::URLRequest* url_request( | 334 net::URLRequest* url_request( |
| 332 host_.GetURLRequest(GlobalRequestID(filter_->child_id(), 1))); | 335 host_.GetURLRequest(GlobalRequestID(filter_->child_id(), 1))); |
| 333 ASSERT_TRUE(url_request); | 336 ASSERT_TRUE(url_request); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // already completed. | 550 // already completed. |
| 548 EXPECT_TRUE(NextRequestWasDestroyed()); | 551 EXPECT_TRUE(NextRequestWasDestroyed()); |
| 549 | 552 |
| 550 // But no others. | 553 // But no others. |
| 551 EXPECT_TRUE(IsEmpty()); | 554 EXPECT_TRUE(IsEmpty()); |
| 552 } | 555 } |
| 553 | 556 |
| 554 } // namespace | 557 } // namespace |
| 555 | 558 |
| 556 } // namespace content | 559 } // namespace content |
| OLD | NEW |