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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 10919317: Move TestJobInterceptor to url_request_test_util. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix typo Created 8 years, 3 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 (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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 callback_.Reset(); 348 callback_.Reset();
349 auth_callback_.Reset(); 349 auth_callback_.Reset();
350 } 350 }
351 351
352 int block_on_; // Bit mask on which states to block. 352 int block_on_; // Bit mask on which states to block.
353 State state_; 353 State state_;
354 CompletionCallback callback_; 354 CompletionCallback callback_;
355 AuthCallback auth_callback_; 355 AuthCallback auth_callback_;
356 }; 356 };
357 357
358
359 // A simple Interceptor that returns a pre-built URLRequestJob one time.
360 class TestJobInterceptor : public URLRequestJobFactory::Interceptor {
361 public:
362 TestJobInterceptor()
363 : main_intercept_job_(NULL) {
364 }
365
366 virtual URLRequestJob* MaybeIntercept(
367 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE {
368 URLRequestJob* job = main_intercept_job_;
369 main_intercept_job_ = NULL;
370 return job;
371 }
372
373 virtual URLRequestJob* MaybeInterceptRedirect(
374 const GURL& location,
375 URLRequest* request,
376 NetworkDelegate* network_delegate) const OVERRIDE {
377 return NULL;
378 }
379
380 virtual URLRequestJob* MaybeInterceptResponse(
381 URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE {
382 return NULL;
383 }
384
385 void set_main_intercept_job(URLRequestJob* job) {
386 main_intercept_job_ = job;
387 }
388
389 private:
390 mutable URLRequestJob* main_intercept_job_;
391 };
392
393 class TestURLRequestContextWithProxy : public TestURLRequestContext { 358 class TestURLRequestContextWithProxy : public TestURLRequestContext {
394 public: 359 public:
395 // Does not own |delegate|. 360 // Does not own |delegate|.
396 TestURLRequestContextWithProxy(const std::string& proxy, 361 TestURLRequestContextWithProxy(const std::string& proxy,
397 NetworkDelegate* delegate) 362 NetworkDelegate* delegate)
398 : TestURLRequestContext(true) { 363 : TestURLRequestContext(true) {
399 context_storage_.set_proxy_service(ProxyService::CreateFixed(proxy)); 364 context_storage_.set_proxy_service(ProxyService::CreateFixed(proxy));
400 set_network_delegate(delegate); 365 set_network_delegate(delegate);
401 Init(); 366 Init();
402 } 367 }
(...skipping 4283 matching lines...) Expand 10 before | Expand all | Expand 10 after
4686 4651
4687 EXPECT_FALSE(r.is_pending()); 4652 EXPECT_FALSE(r.is_pending());
4688 EXPECT_EQ(1, d->response_started_count()); 4653 EXPECT_EQ(1, d->response_started_count());
4689 EXPECT_FALSE(d->received_data_before_response()); 4654 EXPECT_FALSE(d->received_data_before_response());
4690 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 4655 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
4691 } 4656 }
4692 } 4657 }
4693 #endif // !defined(DISABLE_FTP_SUPPORT) 4658 #endif // !defined(DISABLE_FTP_SUPPORT)
4694 4659
4695 } // namespace net 4660 } // namespace net
OLDNEW
« net/url_request/url_request_test_util.h ('K') | « net/url_request/url_request_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698