OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This class simulates what wininet does when a dns lookup fails. | 4 // This class simulates what wininet does when a dns lookup fails. |
5 | 5 |
6 #include <algorithm> | 6 #include <algorithm> |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
12 #include "content/test/net/url_request_abort_on_end_job.h" | 12 #include "content/test/net/url_request_abort_on_end_job.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/http/http_response_headers.h" | 15 #include "net/http/http_response_headers.h" |
| 16 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_context.h" |
16 #include "net/url_request/url_request_filter.h" | 18 #include "net/url_request/url_request_filter.h" |
17 #include "net/url_request/url_request_status.h" | 19 #include "net/url_request/url_request_status.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 const char kPageContent[] = "some data\r\n"; | 22 const char kPageContent[] = "some data\r\n"; |
21 } | 23 } |
22 | 24 |
23 const char URLRequestAbortOnEndJob::k400AbortOnEndUrl[] = | 25 const char URLRequestAbortOnEndJob::k400AbortOnEndUrl[] = |
24 "http://url.handled.by.abort.on.end/400"; | 26 "http://url.handled.by.abort.on.end/400"; |
25 | 27 |
(...skipping 24 matching lines...) Expand all Loading... |
50 "Content-type: text/plain\n"); | 52 "Content-type: text/plain\n"); |
51 } else { | 53 } else { |
52 NOTREACHED(); | 54 NOTREACHED(); |
53 } | 55 } |
54 // ParseRawHeaders expects \0 to end each header line. | 56 // ParseRawHeaders expects \0 to end each header line. |
55 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); | 57 ReplaceSubstringsAfterOffset(&raw_headers, 0, "\n", std::string("\0", 1)); |
56 info->headers = new net::HttpResponseHeaders(raw_headers); | 58 info->headers = new net::HttpResponseHeaders(raw_headers); |
57 } | 59 } |
58 | 60 |
59 URLRequestAbortOnEndJob::URLRequestAbortOnEndJob(net::URLRequest* request) | 61 URLRequestAbortOnEndJob::URLRequestAbortOnEndJob(net::URLRequest* request) |
60 : URLRequestJob(request), sent_data_(false), | 62 : URLRequestJob(request, request->context()->network_delegate()), |
| 63 sent_data_(false), |
61 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 64 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
62 } | 65 } |
63 | 66 |
64 URLRequestAbortOnEndJob::~URLRequestAbortOnEndJob() { | 67 URLRequestAbortOnEndJob::~URLRequestAbortOnEndJob() { |
65 } | 68 } |
66 | 69 |
67 void URLRequestAbortOnEndJob::GetResponseInfo(net::HttpResponseInfo* info) { | 70 void URLRequestAbortOnEndJob::GetResponseInfo(net::HttpResponseInfo* info) { |
68 GetResponseInfoConst(info); | 71 GetResponseInfoConst(info); |
69 } | 72 } |
70 | 73 |
(...skipping 24 matching lines...) Expand all Loading... |
95 return true; | 98 return true; |
96 } | 99 } |
97 | 100 |
98 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, | 101 SetStatus(net::URLRequestStatus(net::URLRequestStatus::FAILED, |
99 net::ERR_CONNECTION_ABORTED)); | 102 net::ERR_CONNECTION_ABORTED)); |
100 *bytes_read = -1; | 103 *bytes_read = -1; |
101 return false; | 104 return false; |
102 } | 105 } |
103 | 106 |
104 | 107 |
OLD | NEW |