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

Side by Side Diff: content/test/net/url_request_failed_job.cc

Issue 10534100: Decouple URLRequestJob from URLRequestContext; access NetworkDelegate as a contructor parameter. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merged with latest sync Created 8 years, 5 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 "content/test/net/url_request_failed_job.h" 5 #include "content/test/net/url_request_failed_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
13 #include "net/url_request/url_request_context.h"
13 #include "net/url_request/url_request_filter.h" 14 #include "net/url_request/url_request_filter.h"
14 15
15 namespace { 16 namespace {
16 17
17 const char kMockHostname[] = "mock.failed.request"; 18 const char kMockHostname[] = "mock.failed.request";
18 19
19 // Gets the numeric net error code from URL of the form: 20 // Gets the numeric net error code from URL of the form:
20 // scheme://kMockHostname/error_code. The error code must be a valid 21 // scheme://kMockHostname/error_code. The error code must be a valid
21 // net error code, and not net::OK or net::ERR_IO_PENDING. 22 // net error code, and not net::OK or net::ERR_IO_PENDING.
22 int GetErrorCode(net::URLRequest* request) { 23 int GetErrorCode(net::URLRequest* request) {
(...skipping 12 matching lines...) Expand all
35 CHECK_LT(net_error, 0); 36 CHECK_LT(net_error, 0);
36 CHECK_NE(net_error, net::ERR_IO_PENDING); 37 CHECK_NE(net_error, net::ERR_IO_PENDING);
37 return GURL(scheme + "://" + kMockHostname + "/" + 38 return GURL(scheme + "://" + kMockHostname + "/" +
38 base::IntToString(net_error)); 39 base::IntToString(net_error));
39 } 40 }
40 41
41 } // namespace 42 } // namespace
42 43
43 URLRequestFailedJob::URLRequestFailedJob(net::URLRequest* request, 44 URLRequestFailedJob::URLRequestFailedJob(net::URLRequest* request,
44 int net_error) 45 int net_error)
45 : net::URLRequestJob(request), 46 : net::URLRequestJob(request, request->context()->network_delegate()),
46 net_error_(net_error), 47 net_error_(net_error),
47 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} 48 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
48 49
49 URLRequestFailedJob::~URLRequestFailedJob() {} 50 URLRequestFailedJob::~URLRequestFailedJob() {}
50 51
51 void URLRequestFailedJob::Start() { 52 void URLRequestFailedJob::Start() {
52 MessageLoop::current()->PostTask( 53 MessageLoop::current()->PostTask(
53 FROM_HERE, 54 FROM_HERE,
54 base::Bind(&URLRequestFailedJob::StartAsync, 55 base::Bind(&URLRequestFailedJob::StartAsync,
55 weak_factory_.GetWeakPtr())); 56 weak_factory_.GetWeakPtr()));
(...skipping 22 matching lines...) Expand all
78 // static 79 // static
79 net::URLRequestJob* URLRequestFailedJob::Factory(net::URLRequest* request, 80 net::URLRequestJob* URLRequestFailedJob::Factory(net::URLRequest* request,
80 const std::string& scheme) { 81 const std::string& scheme) {
81 return new URLRequestFailedJob(request, GetErrorCode(request)); 82 return new URLRequestFailedJob(request, GetErrorCode(request));
82 } 83 }
83 84
84 void URLRequestFailedJob::StartAsync() { 85 void URLRequestFailedJob::StartAsync() {
85 NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, 86 NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
86 net_error_)); 87 net_error_));
87 } 88 }
OLDNEW
« no previous file with comments | « content/test/net/url_request_abort_on_end_job.cc ('k') | content/test/net/url_request_slow_download_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698