| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <utility> |
| 6 |
| 5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 8 #include "base/macros.h" |
| 7 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 10 #include "content/browser/frame_host/navigation_request_info.h" | 12 #include "content/browser/frame_host/navigation_request_info.h" |
| 11 #include "content/browser/loader/navigation_url_loader_delegate.h" | 13 #include "content/browser/loader/navigation_url_loader_delegate.h" |
| 12 #include "content/browser/loader/navigation_url_loader_impl.h" | 14 #include "content/browser/loader/navigation_url_loader_impl.h" |
| 13 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 15 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 14 #include "content/browser/streams/stream.h" | 16 #include "content/browser/streams/stream.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 const scoped_refptr<ResourceResponse>& response) override { | 104 const scoped_refptr<ResourceResponse>& response) override { |
| 103 redirect_info_ = redirect_info; | 105 redirect_info_ = redirect_info; |
| 104 redirect_response_ = response; | 106 redirect_response_ = response; |
| 105 ASSERT_TRUE(request_redirected_); | 107 ASSERT_TRUE(request_redirected_); |
| 106 request_redirected_->Quit(); | 108 request_redirected_->Quit(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, | 111 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, |
| 110 scoped_ptr<StreamHandle> body) override { | 112 scoped_ptr<StreamHandle> body) override { |
| 111 response_ = response; | 113 response_ = response; |
| 112 body_ = body.Pass(); | 114 body_ = std::move(body); |
| 113 ASSERT_TRUE(response_started_); | 115 ASSERT_TRUE(response_started_); |
| 114 response_started_->Quit(); | 116 response_started_->Quit(); |
| 115 } | 117 } |
| 116 | 118 |
| 117 void OnRequestFailed(bool in_cache, int net_error) override { | 119 void OnRequestFailed(bool in_cache, int net_error) override { |
| 118 net_error_ = net_error; | 120 net_error_ = net_error; |
| 119 ASSERT_TRUE(request_failed_); | 121 ASSERT_TRUE(request_failed_); |
| 120 request_failed_->Quit(); | 122 request_failed_->Quit(); |
| 121 } | 123 } |
| 122 | 124 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 NavigationURLLoaderDelegate* delegate) { | 182 NavigationURLLoaderDelegate* delegate) { |
| 181 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL, | 183 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL, |
| 182 false, false, | 184 false, false, |
| 183 REQUEST_CONTEXT_TYPE_LOCATION); | 185 REQUEST_CONTEXT_TYPE_LOCATION); |
| 184 CommonNavigationParams common_params; | 186 CommonNavigationParams common_params; |
| 185 common_params.url = url; | 187 common_params.url = url; |
| 186 scoped_ptr<NavigationRequestInfo> request_info( | 188 scoped_ptr<NavigationRequestInfo> request_info( |
| 187 new NavigationRequestInfo(common_params, begin_params, url, true, false, | 189 new NavigationRequestInfo(common_params, begin_params, url, true, false, |
| 188 -1, scoped_refptr<ResourceRequestBody>())); | 190 -1, scoped_refptr<ResourceRequestBody>())); |
| 189 | 191 |
| 190 return NavigationURLLoader::Create(browser_context_.get(), | 192 return NavigationURLLoader::Create( |
| 191 request_info.Pass(), nullptr, delegate); | 193 browser_context_.get(), std::move(request_info), nullptr, delegate); |
| 192 } | 194 } |
| 193 | 195 |
| 194 // Helper function for fetching the body of a URL to a string. | 196 // Helper function for fetching the body of a URL to a string. |
| 195 std::string FetchURL(const GURL& url) { | 197 std::string FetchURL(const GURL& url) { |
| 196 net::TestDelegate delegate; | 198 net::TestDelegate delegate; |
| 197 net::URLRequestContext* request_context = | 199 net::URLRequestContext* request_context = |
| 198 browser_context_->GetResourceContext()->GetRequestContext(); | 200 browser_context_->GetResourceContext()->GetRequestContext(); |
| 199 scoped_ptr<net::URLRequest> request(request_context->CreateRequest( | 201 scoped_ptr<net::URLRequest> request(request_context->CreateRequest( |
| 200 url, net::DEFAULT_PRIORITY, &delegate)); | 202 url, net::DEFAULT_PRIORITY, &delegate)); |
| 201 request->Start(); | 203 request->Start(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 397 |
| 396 // Release the body. | 398 // Release the body. |
| 397 delegate.ReleaseBody(); | 399 delegate.ReleaseBody(); |
| 398 base::RunLoop().RunUntilIdle(); | 400 base::RunLoop().RunUntilIdle(); |
| 399 | 401 |
| 400 // Verify that URLRequestTestJob no longer has anything paused. | 402 // Verify that URLRequestTestJob no longer has anything paused. |
| 401 EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); | 403 EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); |
| 402 } | 404 } |
| 403 | 405 |
| 404 } // namespace content | 406 } // namespace content |
| OLD | NEW |