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