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 "base/profiler/scoped_profile.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "net/base/data_url.h" | 10 #include "net/base/data_url.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/http/http_response_headers.h" | 12 #include "net/http/http_response_headers.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 int URLRequestDataJob::BuildResponse(const GURL& url, | 17 int URLRequestDataJob::BuildResponse(const GURL& url, |
18 std::string* mime_type, | 18 std::string* mime_type, |
19 std::string* charset, | 19 std::string* charset, |
(...skipping 26 matching lines...) Expand all Loading... |
46 | 46 |
47 URLRequestDataJob::URLRequestDataJob( | 47 URLRequestDataJob::URLRequestDataJob( |
48 URLRequest* request, NetworkDelegate* network_delegate) | 48 URLRequest* request, NetworkDelegate* network_delegate) |
49 : URLRequestSimpleJob(request, network_delegate) { | 49 : URLRequestSimpleJob(request, network_delegate) { |
50 } | 50 } |
51 | 51 |
52 int URLRequestDataJob::GetData(std::string* mime_type, | 52 int URLRequestDataJob::GetData(std::string* mime_type, |
53 std::string* charset, | 53 std::string* charset, |
54 std::string* data, | 54 std::string* data, |
55 const CompletionCallback& callback) const { | 55 const CompletionCallback& callback) const { |
56 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422489 is fixed. | 56 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422489 is fixed. |
57 tracked_objects::ScopedProfile tracking_profile( | 57 tracked_objects::ScopedTracker tracking_profile( |
58 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 URLRequestDataJob::GetData")); | 58 FROM_HERE_WITH_EXPLICIT_FUNCTION("422489 URLRequestDataJob::GetData")); |
59 | 59 |
60 // Check if data URL is valid. If not, don't bother to try to extract data. | 60 // Check if data URL is valid. If not, don't bother to try to extract data. |
61 // Otherwise, parse the data from the data URL. | 61 // Otherwise, parse the data from the data URL. |
62 const GURL& url = request_->url(); | 62 const GURL& url = request_->url(); |
63 if (!url.is_valid()) | 63 if (!url.is_valid()) |
64 return ERR_INVALID_URL; | 64 return ERR_INVALID_URL; |
65 | 65 |
66 // TODO(tyoshino): Get the headers and export via | 66 // TODO(tyoshino): Get the headers and export via |
67 // URLRequestJob::GetResponseInfo(). | 67 // URLRequestJob::GetResponseInfo(). |
68 return BuildResponse(url, mime_type, charset, data, NULL); | 68 return BuildResponse(url, mime_type, charset, data, NULL); |
69 } | 69 } |
70 | 70 |
71 URLRequestDataJob::~URLRequestDataJob() { | 71 URLRequestDataJob::~URLRequestDataJob() { |
72 } | 72 } |
73 | 73 |
74 } // namespace net | 74 } // namespace net |
OLD | NEW |