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 // Simple implementation of a data: protocol handler. | 5 // Simple implementation of a data: protocol handler. |
6 | 6 |
7 #include "net/url_request/url_request_data_job.h" | 7 #include "net/url_request/url_request_data_job.h" |
8 | 8 |
9 #include "net/base/data_url.h" | 9 #include "net/base/data_url.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 #include "net/url_request/url_request_context.h" | |
mmenke
2012/08/21 15:28:49
Don't think this is needed.
shalev
2012/08/22 20:34:10
Done.
| |
11 | 12 |
12 namespace net { | 13 namespace net { |
13 | 14 |
14 URLRequestDataJob::URLRequestDataJob(URLRequest* request) | 15 URLRequestDataJob::URLRequestDataJob( |
15 : URLRequestSimpleJob(request) { | 16 URLRequest* request, NetworkDelegate* network_delegate) |
17 : URLRequestSimpleJob(request, network_delegate) { | |
16 } | 18 } |
17 | 19 |
18 // static | 20 // static |
19 URLRequestJob* URLRequestDataJob::Factory(URLRequest* request, | 21 URLRequestJob* URLRequestDataJob::Factory(URLRequest* request, |
22 NetworkDelegate* network_delegate, | |
20 const std::string& scheme) { | 23 const std::string& scheme) { |
21 return new URLRequestDataJob(request); | 24 return new URLRequestDataJob(request, network_delegate); |
22 } | 25 } |
23 | 26 |
24 int URLRequestDataJob::GetData(std::string* mime_type, | 27 int URLRequestDataJob::GetData(std::string* mime_type, |
25 std::string* charset, | 28 std::string* charset, |
26 std::string* data, | 29 std::string* data, |
27 const CompletionCallback& callback) const { | 30 const CompletionCallback& callback) const { |
28 // Check if data URL is valid. If not, don't bother to try to extract data. | 31 // Check if data URL is valid. If not, don't bother to try to extract data. |
29 // Otherwise, parse the data from the data URL. | 32 // Otherwise, parse the data from the data URL. |
30 const GURL& url = request_->url(); | 33 const GURL& url = request_->url(); |
31 if (!url.is_valid()) | 34 if (!url.is_valid()) |
32 return ERR_INVALID_URL; | 35 return ERR_INVALID_URL; |
33 return DataURL::Parse(url, mime_type, charset, data)? OK: ERR_INVALID_URL; | 36 return DataURL::Parse(url, mime_type, charset, data)? OK: ERR_INVALID_URL; |
34 } | 37 } |
35 | 38 |
36 URLRequestDataJob::~URLRequestDataJob() { | 39 URLRequestDataJob::~URLRequestDataJob() { |
37 } | 40 } |
38 | 41 |
39 } // namespace net | 42 } // namespace net |
OLD | NEW |