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

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

Issue 2623383004: Update InterceptingResourceHandler tests to use MockResourceLoader. (Closed)
Patch Set: Response to comments Created 3 years, 11 months 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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
14 #include "content/browser/loader/resource_handler.h" 15 #include "content/browser/loader/resource_handler.h"
15 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
17 #include "net/url_request/url_request_status.h" 18 #include "net/url_request/url_request_status.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
19 20
20 namespace net { 21 namespace net {
21 class URLRequestStatus; 22 class URLRequestStatus;
22 } 23 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 int call_depth() const { return call_depth_; } 151 int call_depth() const { return call_depth_; }
151 152
152 // Spins the message loop until the request is deferred. Using this is 153 // Spins the message loop until the request is deferred. Using this is
153 // optional, but if used, must use it exclusively to wait for the request. If 154 // optional, but if used, must use it exclusively to wait for the request. If
154 // the request was deferred and then resumed/canceled without calling this 155 // the request was deferred and then resumed/canceled without calling this
155 // method, behavior is undefined. 156 // method, behavior is undefined.
156 void WaitUntilDeferred(); 157 void WaitUntilDeferred();
157 158
158 void WaitUntilResponseComplete(); 159 void WaitUntilResponseComplete();
159 160
161 // Returns a weak pointer to |this|. Allows testing object lifetime.
162 base::WeakPtr<TestResourceHandler> GetWeakPtr();
163
160 private: 164 private:
161 // TODO(mmenke): Remove these, in favor of final_status_ and body_. 165 // TODO(mmenke): Remove these, in favor of final_status_ and body_.
162 net::URLRequestStatus* request_status_ptr_; 166 net::URLRequestStatus* request_status_ptr_;
163 std::string* body_ptr_; 167 std::string* body_ptr_;
164 168
165 scoped_refptr<net::IOBuffer> buffer_; 169 scoped_refptr<net::IOBuffer> buffer_;
166 size_t buffer_size_; 170 size_t buffer_size_;
167 171
168 ResourceController* controller_; 172 ResourceController* controller_;
169 173
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 net::URLRequestStatus::FromError(net::ERR_UNEXPECTED); 205 net::URLRequestStatus::FromError(net::ERR_UNEXPECTED);
202 bool canceled_ = false; 206 bool canceled_ = false;
203 207
204 // Tracks recursive calls, which aren't allowed. 208 // Tracks recursive calls, which aren't allowed.
205 int call_depth_ = 0; 209 int call_depth_ = 0;
206 210
207 std::unique_ptr<base::RunLoop> deferred_run_loop_; 211 std::unique_ptr<base::RunLoop> deferred_run_loop_;
208 212
209 base::RunLoop response_complete_run_loop_; 213 base::RunLoop response_complete_run_loop_;
210 214
215 base::WeakPtrFactory<TestResourceHandler> weak_ptr_factory_;
216
211 DISALLOW_COPY_AND_ASSIGN(TestResourceHandler); 217 DISALLOW_COPY_AND_ASSIGN(TestResourceHandler);
212 }; 218 };
213 219
214 } // namespace content 220 } // namespace content
215 221
216 #endif // CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_ 222 #endif // CONTENT_BROWSER_LOADER_TEST_RESOURCE_HANDLER_H_
OLDNEW
« no previous file with comments | « content/browser/loader/mock_resource_loader.cc ('k') | content/browser/loader/test_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698