| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "components/navigation_interception/intercept_navigation_resource_throt
tle.h" | 10 #include "components/navigation_interception/intercept_navigation_resource_throt
tle.h" |
| 11 #include "components/navigation_interception/navigation_params.h" | 11 #include "components/navigation_interception/navigation_params.h" |
| 12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/browser/resource_context.h" | 14 #include "content/public/browser/resource_context.h" |
| 15 #include "content/public/browser/resource_controller.h" | 15 #include "content/public/browser/resource_controller.h" |
| 16 #include "content/public/browser/resource_dispatcher_host.h" | 16 #include "content/public/browser/resource_dispatcher_host.h" |
| 17 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 17 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 18 #include "content/public/browser/resource_request_info.h" | 18 #include "content/public/browser/resource_request_info.h" |
| 19 #include "content/public/browser/resource_throttle.h" | 19 #include "content/public/browser/resource_throttle.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_contents_delegate.h" | 21 #include "content/public/browser/web_contents_delegate.h" |
| 22 #include "content/public/common/page_transition_types.h" | 22 #include "content/public/common/page_transition_types.h" |
| 23 #include "content/public/test/mock_resource_context.h" | 23 #include "content/public/test/mock_resource_context.h" |
| 24 #include "content/public/test/test_renderer_host.h" | 24 #include "content/public/test/test_renderer_host.h" |
| 25 #include "net/base/request_priority.h" |
| 25 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| 26 #include "net/http/http_response_info.h" | 27 #include "net/http/http_response_info.h" |
| 27 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
| 28 #include "net/url_request/url_request_test_util.h" | 29 #include "net/url_request/url_request_test_util.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 | 32 |
| 32 using testing::_; | 33 using testing::_; |
| 33 using testing::Eq; | 34 using testing::Eq; |
| 34 using testing::Ne; | 35 using testing::Ne; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 112 |
| 112 class TestIOThreadState { | 113 class TestIOThreadState { |
| 113 public: | 114 public: |
| 114 TestIOThreadState(const GURL& url, | 115 TestIOThreadState(const GURL& url, |
| 115 int render_process_id, | 116 int render_process_id, |
| 116 int render_view_id, | 117 int render_view_id, |
| 117 const std::string& request_method, | 118 const std::string& request_method, |
| 118 RedirectMode redirect_mode, | 119 RedirectMode redirect_mode, |
| 119 MockInterceptCallbackReceiver* callback_receiver) | 120 MockInterceptCallbackReceiver* callback_receiver) |
| 120 : resource_context_(&test_url_request_context_), | 121 : resource_context_(&test_url_request_context_), |
| 121 request_(url, NULL, resource_context_.GetRequestContext()) { | 122 request_(url, |
| 123 net::DEFAULT_PRIORITY, |
| 124 NULL, |
| 125 resource_context_.GetRequestContext()) { |
| 122 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 126 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 123 if (render_process_id != MSG_ROUTING_NONE && | 127 if (render_process_id != MSG_ROUTING_NONE && |
| 124 render_view_id != MSG_ROUTING_NONE) { | 128 render_view_id != MSG_ROUTING_NONE) { |
| 125 content::ResourceRequestInfo::AllocateForTesting( | 129 content::ResourceRequestInfo::AllocateForTesting( |
| 126 &request_, | 130 &request_, |
| 127 ResourceType::MAIN_FRAME, | 131 ResourceType::MAIN_FRAME, |
| 128 &resource_context_, | 132 &resource_context_, |
| 129 render_process_id, | 133 render_process_id, |
| 130 render_view_id, | 134 render_view_id, |
| 131 false); | 135 false); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 REDIRECT_MODE_302, | 467 REDIRECT_MODE_302, |
| 464 web_contents()->GetRenderViewHost()->GetProcess()->GetID(), | 468 web_contents()->GetRenderViewHost()->GetProcess()->GetID(), |
| 465 web_contents()->GetRenderViewHost()->GetRoutingID(), | 469 web_contents()->GetRenderViewHost()->GetRoutingID(), |
| 466 base::Unretained(&defer))); | 470 base::Unretained(&defer))); |
| 467 | 471 |
| 468 // Wait for the request to finish processing. | 472 // Wait for the request to finish processing. |
| 469 base::RunLoop().RunUntilIdle(); | 473 base::RunLoop().RunUntilIdle(); |
| 470 } | 474 } |
| 471 | 475 |
| 472 } // namespace navigation_interception | 476 } // namespace navigation_interception |
| OLD | NEW |