| 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> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // NavigationURLLoaderDelegate implementation. | 102 // NavigationURLLoaderDelegate implementation. |
| 103 void OnRequestRedirected( | 103 void OnRequestRedirected( |
| 104 const net::RedirectInfo& redirect_info, | 104 const net::RedirectInfo& redirect_info, |
| 105 const scoped_refptr<ResourceResponse>& response) override { | 105 const scoped_refptr<ResourceResponse>& response) override { |
| 106 redirect_info_ = redirect_info; | 106 redirect_info_ = redirect_info; |
| 107 redirect_response_ = response; | 107 redirect_response_ = response; |
| 108 ASSERT_TRUE(request_redirected_); | 108 ASSERT_TRUE(request_redirected_); |
| 109 request_redirected_->Quit(); | 109 request_redirected_->Quit(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void OnResponseStarted(const scoped_refptr<ResourceResponse>& response, | 112 void OnResponseStarted( |
| 113 scoped_ptr<StreamHandle> body) override { | 113 const scoped_refptr<ResourceResponse>& response, |
| 114 scoped_ptr<StreamHandle> body, |
| 115 mojo::ScopedDataPipeConsumerHandle data_consumer_handle) override { |
| 114 response_ = response; | 116 response_ = response; |
| 115 body_ = std::move(body); | 117 body_ = std::move(body); |
| 118 data_consumer_handle_ = std::move(data_consumer_handle); |
| 116 ASSERT_TRUE(response_started_); | 119 ASSERT_TRUE(response_started_); |
| 117 response_started_->Quit(); | 120 response_started_->Quit(); |
| 118 } | 121 } |
| 119 | 122 |
| 120 void OnRequestFailed(bool in_cache, int net_error) override { | 123 void OnRequestFailed(bool in_cache, int net_error) override { |
| 121 net_error_ = net_error; | 124 net_error_ = net_error; |
| 122 ASSERT_TRUE(request_failed_); | 125 ASSERT_TRUE(request_failed_); |
| 123 request_failed_->Quit(); | 126 request_failed_->Quit(); |
| 124 } | 127 } |
| 125 | 128 |
| 126 void OnRequestStarted(base::TimeTicks timestamp) override { | 129 void OnRequestStarted(base::TimeTicks timestamp) override { |
| 127 ASSERT_FALSE(timestamp.is_null()); | 130 ASSERT_FALSE(timestamp.is_null()); |
| 128 ++on_request_handled_counter_; | 131 ++on_request_handled_counter_; |
| 129 } | 132 } |
| 130 | 133 |
| 131 private: | 134 private: |
| 132 net::RedirectInfo redirect_info_; | 135 net::RedirectInfo redirect_info_; |
| 133 scoped_refptr<ResourceResponse> redirect_response_; | 136 scoped_refptr<ResourceResponse> redirect_response_; |
| 134 scoped_refptr<ResourceResponse> response_; | 137 scoped_refptr<ResourceResponse> response_; |
| 135 scoped_ptr<StreamHandle> body_; | 138 scoped_ptr<StreamHandle> body_; |
| 139 mojo::ScopedDataPipeConsumerHandle data_consumer_handle_; |
| 136 int net_error_; | 140 int net_error_; |
| 137 int on_request_handled_counter_; | 141 int on_request_handled_counter_; |
| 138 | 142 |
| 139 scoped_ptr<base::RunLoop> request_redirected_; | 143 scoped_ptr<base::RunLoop> request_redirected_; |
| 140 scoped_ptr<base::RunLoop> response_started_; | 144 scoped_ptr<base::RunLoop> response_started_; |
| 141 scoped_ptr<base::RunLoop> request_failed_; | 145 scoped_ptr<base::RunLoop> request_failed_; |
| 142 }; | 146 }; |
| 143 | 147 |
| 144 class RequestBlockingResourceDispatcherHostDelegate | 148 class RequestBlockingResourceDispatcherHostDelegate |
| 145 : public ResourceDispatcherHostDelegate { | 149 : public ResourceDispatcherHostDelegate { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 401 |
| 398 // Release the body. | 402 // Release the body. |
| 399 delegate.ReleaseBody(); | 403 delegate.ReleaseBody(); |
| 400 base::RunLoop().RunUntilIdle(); | 404 base::RunLoop().RunUntilIdle(); |
| 401 | 405 |
| 402 // Verify that URLRequestTestJob no longer has anything paused. | 406 // Verify that URLRequestTestJob no longer has anything paused. |
| 403 EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); | 407 EXPECT_FALSE(net::URLRequestTestJob::ProcessOnePendingMessage()); |
| 404 } | 408 } |
| 405 | 409 |
| 406 } // namespace content | 410 } // namespace content |
| OLD | NEW |