| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_ | 6 #define CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // URL passed to OnResponseStarted, if it was called. | 139 // URL passed to OnResponseStarted, if it was called. |
| 140 const GURL& start_url() const { return start_url_; } | 140 const GURL& start_url() const { return start_url_; } |
| 141 | 141 |
| 142 ResourceResponse* resource_response() { return resource_response_.get(); }; | 142 ResourceResponse* resource_response() { return resource_response_.get(); }; |
| 143 | 143 |
| 144 int total_bytes_downloaded() const { return total_bytes_downloaded_; } | 144 int total_bytes_downloaded() const { return total_bytes_downloaded_; } |
| 145 | 145 |
| 146 const std::string& body() const { return body_; } | 146 const std::string& body() const { return body_; } |
| 147 net::URLRequestStatus final_status() const { return final_status_; } | 147 net::URLRequestStatus final_status() const { return final_status_; } |
| 148 | 148 |
| 149 // Returns the current number of |this|'s methods on the callstack. |
| 150 int call_depth() const { return call_depth_; } |
| 151 |
| 149 // Spins the message loop until the request is deferred. Using this is | 152 // Spins the message loop until the request is deferred. Using this is |
| 150 // optional, but if used, must use it exclusively to wait for the request. If | 153 // optional, but if used, must use it exclusively to wait for the request. If |
| 151 // the request was deferred and then resumed/canceled without calling this | 154 // the request was deferred and then resumed/canceled without calling this |
| 152 // method, behavior is undefined. | 155 // method, behavior is undefined. |
| 153 void WaitUntilDeferred(); | 156 void WaitUntilDeferred(); |
| 154 | 157 |
| 155 void WaitUntilResponseComplete(); | 158 void WaitUntilResponseComplete(); |
| 156 | 159 |
| 157 private: | 160 private: |
| 158 // TODO(mmenke): Remove these, in favor of final_status_ and body_. | 161 // TODO(mmenke): Remove these, in favor of final_status_ and body_. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 int on_response_completed_called_ = 0; | 194 int on_response_completed_called_ = 0; |
| 192 | 195 |
| 193 GURL start_url_; | 196 GURL start_url_; |
| 194 scoped_refptr<ResourceResponse> resource_response_; | 197 scoped_refptr<ResourceResponse> resource_response_; |
| 195 int total_bytes_downloaded_ = 0; | 198 int total_bytes_downloaded_ = 0; |
| 196 std::string body_; | 199 std::string body_; |
| 197 net::URLRequestStatus final_status_ = | 200 net::URLRequestStatus final_status_ = |
| 198 net::URLRequestStatus::FromError(net::ERR_UNEXPECTED); | 201 net::URLRequestStatus::FromError(net::ERR_UNEXPECTED); |
| 199 bool canceled_ = false; | 202 bool canceled_ = false; |
| 200 | 203 |
| 204 // Tracks recursive calls, which aren't allowed. |
| 205 int call_depth_ = 0; |
| 206 |
| 201 std::unique_ptr<base::RunLoop> deferred_run_loop_; | 207 std::unique_ptr<base::RunLoop> deferred_run_loop_; |
| 202 | 208 |
| 203 base::RunLoop response_complete_run_loop_; | 209 base::RunLoop response_complete_run_loop_; |
| 204 | 210 |
| 205 DISALLOW_COPY_AND_ASSIGN(TestResourceHandler); | 211 DISALLOW_COPY_AND_ASSIGN(TestResourceHandler); |
| 206 }; | 212 }; |
| 207 | 213 |
| 208 } // namespace content | 214 } // namespace content |
| 209 | 215 |
| 210 #endif // CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_ | 216 #endif // CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_ |
| OLD | NEW |