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

Side by Side Diff: content/browser/renderer_host/resource_dispatcher_host_unittest.cc

Issue 9348109: Add extra data to BrowserContext so that content layer and other embedders can stash data with it t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/resource_dispatcher_host.h" 5 #include "content/browser/renderer_host/resource_dispatcher_host.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 263 }
264 264
265 static URLRequestTestDelayedStartJob* list_head_; 265 static URLRequestTestDelayedStartJob* list_head_;
266 URLRequestTestDelayedStartJob* next_; 266 URLRequestTestDelayedStartJob* next_;
267 }; 267 };
268 268
269 URLRequestTestDelayedStartJob* 269 URLRequestTestDelayedStartJob*
270 URLRequestTestDelayedStartJob::list_head_ = NULL; 270 URLRequestTestDelayedStartJob::list_head_ = NULL;
271 271
272 // Associated with an URLRequest to determine if the URLRequest gets deleted. 272 // Associated with an URLRequest to determine if the URLRequest gets deleted.
273 class TestUserData : public net::URLRequest::UserData { 273 class TestUserData : public base::SupportsUserData::Data {
274 public: 274 public:
275 explicit TestUserData(bool* was_deleted) 275 explicit TestUserData(bool* was_deleted)
276 : was_deleted_(was_deleted) { 276 : was_deleted_(was_deleted) {
277 } 277 }
278 278
279 ~TestUserData() { 279 ~TestUserData() {
280 *was_deleted_ = true; 280 *was_deleted_ = true;
281 } 281 }
282 282
283 private: 283 private:
284 bool* was_deleted_; 284 bool* was_deleted_;
285 }; 285 };
286 286
287 class TestResourceDispatcherHostDelegate 287 class TestResourceDispatcherHostDelegate
288 : public content::ResourceDispatcherHostDelegate { 288 : public content::ResourceDispatcherHostDelegate {
289 public: 289 public:
290 TestResourceDispatcherHostDelegate() 290 TestResourceDispatcherHostDelegate()
291 : defer_start_(false) { 291 : defer_start_(false) {
292 } 292 }
293 293
294 void set_url_request_user_data(net::URLRequest::UserData* user_data) { 294 void set_url_request_user_data(base::SupportsUserData::Data* user_data) {
darin (slow to review) 2012/02/15 06:19:05 shouldn't net::URLRequest::UserData still work eve
jam 2012/02/15 15:44:43 I removed the net::URLRequest::UserData class, sin
295 user_data_.reset(user_data); 295 user_data_.reset(user_data);
296 } 296 }
297 297
298 void set_defer_start(bool value) { 298 void set_defer_start(bool value) {
299 defer_start_ = value; 299 defer_start_ = value;
300 } 300 }
301 301
302 // ResourceDispatcherHostDelegate implementation: 302 // ResourceDispatcherHostDelegate implementation:
303 303
304 virtual void RequestBeginning( 304 virtual void RequestBeginning(
305 net::URLRequest* request, 305 net::URLRequest* request,
306 content::ResourceContext* resource_context, 306 content::ResourceContext* resource_context,
307 ResourceType::Type resource_type, 307 ResourceType::Type resource_type,
308 int child_id, 308 int child_id,
309 int route_id, 309 int route_id,
310 bool is_continuation_of_transferred_request, 310 bool is_continuation_of_transferred_request,
311 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE { 311 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE {
312 const void* key = user_data_.get(); 312 const void* key = user_data_.get();
313 request->SetUserData(key, user_data_.release()); 313 request->SetUserData(key, user_data_.release());
314 } 314 }
315 315
316 virtual bool ShouldDeferStart( 316 virtual bool ShouldDeferStart(
317 net::URLRequest* request, 317 net::URLRequest* request,
318 content::ResourceContext* resource_context) OVERRIDE { 318 content::ResourceContext* resource_context) OVERRIDE {
319 return defer_start_; 319 return defer_start_;
320 } 320 }
321 321
322 private: 322 private:
323 bool defer_start_; 323 bool defer_start_;
324 scoped_ptr<net::URLRequest::UserData> user_data_; 324 scoped_ptr<base::SupportsUserData::Data> user_data_;
325 }; 325 };
326 326
327 class ResourceDispatcherHostTest : public testing::Test, 327 class ResourceDispatcherHostTest : public testing::Test,
328 public IPC::Message::Sender { 328 public IPC::Message::Sender {
329 public: 329 public:
330 ResourceDispatcherHostTest() 330 ResourceDispatcherHostTest()
331 : ui_thread_(BrowserThread::UI, &message_loop_), 331 : ui_thread_(BrowserThread::UI, &message_loop_),
332 io_thread_(BrowserThread::IO, &message_loop_), 332 io_thread_(BrowserThread::IO, &message_loop_),
333 ALLOW_THIS_IN_INITIALIZER_LIST(filter_(new ForwardingFilter(this))), 333 ALLOW_THIS_IN_INITIALIZER_LIST(filter_(new ForwardingFilter(this))),
334 old_factory_(NULL), 334 old_factory_(NULL),
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 net::URLRequestStatus status; 1371 net::URLRequestStatus status;
1372 1372
1373 void* iter = NULL; 1373 void* iter = NULL;
1374 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); 1374 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id));
1375 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); 1375 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status));
1376 1376
1377 EXPECT_EQ(1, request_id); 1377 EXPECT_EQ(1, request_id);
1378 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); 1378 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status());
1379 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); 1379 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error());
1380 } 1380 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698