Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: content/browser/loader/test_resource_handler.h

Issue 2476163003: Refactor ResourceHandler API. (Closed)
Patch Set: Minor cleanups, one real fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 22 matching lines...) Expand all
33 public: 33 public:
34 // If non-null, |request_status| will be updated when the response is complete 34 // If non-null, |request_status| will be updated when the response is complete
35 // with the final status of the request received by the handler and |body| 35 // with the final status of the request received by the handler and |body|
36 // will be updated on each OnReadCompleted call. 36 // will be updated on each OnReadCompleted call.
37 TestResourceHandler(net::URLRequestStatus* request_status, std::string* body); 37 TestResourceHandler(net::URLRequestStatus* request_status, std::string* body);
38 TestResourceHandler(); 38 TestResourceHandler();
39 ~TestResourceHandler() override; 39 ~TestResourceHandler() override;
40 40
41 // ResourceHandler implementation: 41 // ResourceHandler implementation:
42 void SetController(ResourceController* controller) override; 42 void SetController(ResourceController* controller) override;
43 bool OnRequestRedirected(const net::RedirectInfo& redirect_info, 43 void OnRequestRedirected(const net::RedirectInfo& redirect_info,
44 ResourceResponse* response, 44 ResourceResponse* response,
45 bool* defer) override; 45 bool* defer_or_cancel) override;
46 bool OnResponseStarted(ResourceResponse* response, bool* defer) override; 46 void OnResponseStarted(ResourceResponse* response,
47 bool OnWillStart(const GURL& url, bool* defer) override; 47 bool* defer_or_cancel) override;
48 void OnWillStart(const GURL& url, bool* defer_or_cancel) override;
48 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, 49 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf,
49 int* buf_size, 50 int* buf_size,
50 int min_size) override; 51 int min_size) override;
51 bool OnReadCompleted(int bytes_read, bool* defer) override; 52 void OnReadCompleted(int bytes_read, bool* defer_or_cancel) override;
52 void OnResponseCompleted(const net::URLRequestStatus& status, 53 void OnResponseCompleted(const net::URLRequestStatus& status,
53 bool* defer) override; 54 bool* defer) override;
54 void OnDataDownloaded(int bytes_downloaded) override; 55 void OnDataDownloaded(int bytes_downloaded) override;
55 56
56 // Sets the size of the read buffer returned by OnWillRead. Releases reference 57 // Sets the size of the read buffer returned by OnWillRead. Releases reference
57 // to previous read buffer. Default size is 2048 bytes. 58 // to previous read buffer. Default size is 2048 bytes.
58 void SetBufferSize(int buffer_size); 59 void SetBufferSize(int buffer_size);
59 60
60 scoped_refptr<net::IOBuffer> buffer() const { return buffer_; } 61 scoped_refptr<net::IOBuffer> buffer() const { return buffer_; }
61 62
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 int on_response_completed_called() const { 102 int on_response_completed_called() const {
102 return on_response_completed_called_; 103 return on_response_completed_called_;
103 } 104 }
104 105
105 private: 106 private:
106 net::URLRequestStatus* request_status_; 107 net::URLRequestStatus* request_status_;
107 std::string* body_; 108 std::string* body_;
108 scoped_refptr<net::IOBuffer> buffer_; 109 scoped_refptr<net::IOBuffer> buffer_;
109 size_t buffer_size_; 110 size_t buffer_size_;
110 111
112 ResourceController* controller_ = nullptr;
113
111 bool on_will_start_result_ = true; 114 bool on_will_start_result_ = true;
112 bool on_response_started_result_ = true; 115 bool on_response_started_result_ = true;
113 bool on_will_read_result_ = true; 116 bool on_will_read_result_ = true;
114 bool on_read_completed_result_ = true; 117 bool on_read_completed_result_ = true;
115 118
116 bool defer_on_will_start_ = false; 119 bool defer_on_will_start_ = false;
117 bool defer_on_response_started_ = false; 120 bool defer_on_response_started_ = false;
118 bool defer_on_read_completed_ = false; 121 bool defer_on_read_completed_ = false;
119 bool defer_on_response_completed_ = false; 122 bool defer_on_response_completed_ = false;
120 123
121 int on_will_start_called_ = 0; 124 int on_will_start_called_ = 0;
122 int on_response_started_called_ = 0; 125 int on_response_started_called_ = 0;
123 int on_will_read_called_ = 0; 126 int on_will_read_called_ = 0;
124 int on_read_completed_called_ = 0; 127 int on_read_completed_called_ = 0;
125 int on_response_completed_called_ = 0; 128 int on_response_completed_called_ = 0;
126 129
127 DISALLOW_COPY_AND_ASSIGN(TestResourceHandler); 130 DISALLOW_COPY_AND_ASSIGN(TestResourceHandler);
128 }; 131 };
129 132
130 } // namespace content 133 } // namespace content
131 134
132 #endif // CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_ 135 #endif // CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/loader/sync_resource_handler.cc ('k') | content/browser/loader/test_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698