OLD | NEW |
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_mock_http_job.h" | 5 #include "content/test/net/url_request_mock_http_job.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" |
11 #include "base/threading/thread_restrictions.h" | 12 #include "base/threading/thread_restrictions.h" |
| 13 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
13 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
14 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
15 #include "net/url_request/url_request_filter.h" | 17 #include "net/url_request/url_request_filter.h" |
16 | 18 |
17 const char kMockHostname[] = "mock.http"; | 19 const char kMockHostname[] = "mock.http"; |
18 const base::FilePath::CharType kMockHeaderFileSuffix[] = | 20 const base::FilePath::CharType kMockHeaderFileSuffix[] = |
19 FILE_PATH_LITERAL(".mock-http-headers"); | 21 FILE_PATH_LITERAL(".mock-http-headers"); |
20 | 22 |
21 namespace content { | 23 namespace content { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 104 } |
103 | 105 |
104 // static | 106 // static |
105 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> | 107 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> |
106 URLRequestMockHTTPJob::CreateProtocolHandler(const base::FilePath& base_path) { | 108 URLRequestMockHTTPJob::CreateProtocolHandler(const base::FilePath& base_path) { |
107 return scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( | 109 return scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>( |
108 new ProtocolHandler(base_path, false)); | 110 new ProtocolHandler(base_path, false)); |
109 } | 111 } |
110 | 112 |
111 URLRequestMockHTTPJob::URLRequestMockHTTPJob( | 113 URLRequestMockHTTPJob::URLRequestMockHTTPJob( |
112 net::URLRequest* request, | 114 net::URLRequest* request, net::NetworkDelegate* network_delegate, |
113 net::NetworkDelegate* network_delegate, | |
114 const base::FilePath& file_path) | 115 const base::FilePath& file_path) |
115 : net::URLRequestFileJob(request, network_delegate, file_path) { } | 116 : net::URLRequestFileJob( |
| 117 request, network_delegate, file_path, |
| 118 content::BrowserThread::GetBlockingPool()-> |
| 119 GetTaskRunnerWithShutdownBehavior( |
| 120 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)) {} |
116 | 121 |
117 URLRequestMockHTTPJob::~URLRequestMockHTTPJob() { } | 122 URLRequestMockHTTPJob::~URLRequestMockHTTPJob() { } |
118 | 123 |
119 // Public virtual version. | 124 // Public virtual version. |
120 void URLRequestMockHTTPJob::GetResponseInfo(net::HttpResponseInfo* info) { | 125 void URLRequestMockHTTPJob::GetResponseInfo(net::HttpResponseInfo* info) { |
121 // Forward to private const version. | 126 // Forward to private const version. |
122 GetResponseInfoConst(info); | 127 GetResponseInfoConst(info); |
123 } | 128 } |
124 | 129 |
125 bool URLRequestMockHTTPJob::IsRedirectResponse(GURL* location, | 130 bool URLRequestMockHTTPJob::IsRedirectResponse(GURL* location, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return net::URLRequestJob::GetResponseCode(); | 167 return net::URLRequestJob::GetResponseCode(); |
163 } | 168 } |
164 | 169 |
165 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { | 170 bool URLRequestMockHTTPJob::GetCharset(std::string* charset) { |
166 net::HttpResponseInfo info; | 171 net::HttpResponseInfo info; |
167 GetResponseInfo(&info); | 172 GetResponseInfo(&info); |
168 return info.headers.get() && info.headers->GetCharset(charset); | 173 return info.headers.get() && info.headers->GetCharset(charset); |
169 } | 174 } |
170 | 175 |
171 } // namespace content | 176 } // namespace content |
OLD | NEW |