Chromium Code Reviews| 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. | 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. |
| 6 | 6 |
| 7 #include "webkit/child/weburlloader_impl.h" | 7 #include "webkit/child/weburlloader_impl.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 std::string mime_type; | 125 std::string mime_type; |
| 126 std::string charset; | 126 std::string charset; |
| 127 if (net::DataURL::Parse(url, &mime_type, &charset, data)) { | 127 if (net::DataURL::Parse(url, &mime_type, &charset, data)) { |
| 128 *error_code = net::OK; | 128 *error_code = net::OK; |
| 129 // Assure same time for all time fields of data: URLs. | 129 // Assure same time for all time fields of data: URLs. |
| 130 Time now = Time::Now(); | 130 Time now = Time::Now(); |
| 131 info->load_timing.request_start = TimeTicks::Now(); | 131 info->load_timing.request_start = TimeTicks::Now(); |
| 132 info->load_timing.request_start_time = now; | 132 info->load_timing.request_start_time = now; |
| 133 info->request_time = now; | 133 info->request_time = now; |
| 134 info->response_time = now; | 134 info->response_time = now; |
| 135 info->headers = NULL; | 135 |
| 136 std::string raw_header = "HTTP/1.1 200 OK"; | |
| 137 raw_header += '\0'; | |
| 138 raw_header += "Content-Type: " + mime_type; | |
| 139 if (!charset.empty()) { | |
| 140 raw_header += ";charset="; | |
| 141 raw_header += charset; | |
| 142 } | |
| 143 raw_header += '\0'; | |
| 144 raw_header += "Access-Control-Allow-Origin: *"; | |
| 145 raw_header.append("\0\0", 2); | |
| 146 | |
| 147 info->headers = new net::HttpResponseHeaders(raw_header); | |
|
abarth-chromium
2013/11/01 16:48:55
It seems like there should be a higher-level API f
| |
| 136 info->mime_type.swap(mime_type); | 148 info->mime_type.swap(mime_type); |
| 137 info->charset.swap(charset); | 149 info->charset.swap(charset); |
| 138 info->security_info.clear(); | 150 info->security_info.clear(); |
| 139 info->content_length = data->length(); | 151 info->content_length = data->length(); |
| 140 info->encoded_data_length = 0; | 152 info->encoded_data_length = 0; |
| 141 | 153 |
| 142 return true; | 154 return true; |
| 143 } | 155 } |
| 144 | 156 |
| 145 *error_code = net::ERR_INVALID_URL; | 157 *error_code = net::ERR_INVALID_URL; |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 | 857 |
| 846 void WebURLLoaderImpl::setDefersLoading(bool value) { | 858 void WebURLLoaderImpl::setDefersLoading(bool value) { |
| 847 context_->SetDefersLoading(value); | 859 context_->SetDefersLoading(value); |
| 848 } | 860 } |
| 849 | 861 |
| 850 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { | 862 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { |
| 851 context_->DidChangePriority(new_priority); | 863 context_->DidChangePriority(new_priority); |
| 852 } | 864 } |
| 853 | 865 |
| 854 } // namespace webkit_glue | 866 } // namespace webkit_glue |
| OLD | NEW |