Chromium Code Reviews| 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 #ifndef CONTENT_BROWSER_FILEAPI_MOCK_URL_REQUEST_DELEGATE_H_ | 5 #ifndef CONTENT_BROWSER_FILEAPI_MOCK_URL_REQUEST_DELEGATE_H_ |
| 6 #define CONTENT_BROWSER_FILEAPI_MOCK_URL_REQUEST_DELEGATE_H_ | 6 #define CONTENT_BROWSER_FILEAPI_MOCK_URL_REQUEST_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
| 9 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 class IOBuffer; | 12 class IOBuffer; |
| 13 } | 13 } |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 | 16 |
| 17 // A URL request delegate that receives the response body. | 17 // A URL request delegate that receives the response body. |
| 18 class MockURLRequestDelegate : public net::URLRequest::Delegate { | 18 class MockURLRequestDelegate : public net::URLRequest::Delegate { |
|
mattm
2017/03/31 21:52:02
I didn't look over this in too much detail, but th
pwnall
2017/04/04 02:28:21
There was a tiny missing piece of functionality, s
| |
| 19 public: | 19 public: |
| 20 MockURLRequestDelegate(); | 20 MockURLRequestDelegate(); |
| 21 ~MockURLRequestDelegate() override; | 21 ~MockURLRequestDelegate() override; |
| 22 | 22 |
| 23 void OnResponseStarted(net::URLRequest* request, int net_error) override; | 23 void OnResponseStarted(net::URLRequest* request, int net_error) override; |
| 24 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | 24 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
| 25 const std::string& response_data() const { return response_data_; } | 25 const std::string& response_data() const { return response_data_; } |
| 26 const net::IOBufferWithSize* metadata() const { return metadata_.get(); } | 26 const net::IOBufferWithSize* metadata() const { return metadata_.get(); } |
| 27 int request_status() { return request_status_; } | 27 int request_status() { return request_status_; } |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 void ReadSome(net::URLRequest* request); | 30 void ReadSome(net::URLRequest* request); |
| 31 void ReceiveData(net::URLRequest* request, int bytes_read); | 31 void ReceiveData(net::URLRequest* request, int bytes_read); |
| 32 void RequestComplete(); | 32 void RequestComplete(); |
| 33 | 33 |
| 34 scoped_refptr<net::IOBuffer> io_buffer_; | 34 scoped_refptr<net::IOBuffer> io_buffer_; |
| 35 std::string response_data_; | 35 std::string response_data_; |
| 36 scoped_refptr<net::IOBufferWithSize> metadata_; | 36 scoped_refptr<net::IOBufferWithSize> metadata_; |
| 37 | 37 |
| 38 int request_status_; | 38 int request_status_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 } // namespace content | 41 } // namespace content |
| 42 | 42 |
| 43 #endif // CONTENT_BROWSER_FILEAPI_MOCK_URL_REQUEST_DELEGATE_H_ | 43 #endif // CONTENT_BROWSER_FILEAPI_MOCK_URL_REQUEST_DELEGATE_H_ |
| OLD | NEW |