| 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 "webkit/plugins/ppapi/url_request_info_util.h" | 5 #include "webkit/plugins/ppapi/url_request_info_util.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 #include "googleurl/src/url_util.h" | 10 #include "googleurl/src/url_util.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 | 101 |
| 102 // Ensures that the file_ref members of the given request info data are | 102 // Ensures that the file_ref members of the given request info data are |
| 103 // populated from the resource IDs. Returns true on success. | 103 // populated from the resource IDs. Returns true on success. |
| 104 bool EnsureFileRefObjectsPopulated(::ppapi::URLRequestInfoData* data) { | 104 bool EnsureFileRefObjectsPopulated(::ppapi::URLRequestInfoData* data) { |
| 105 // Get the Resource objects for any file refs with only host resource (this | 105 // Get the Resource objects for any file refs with only host resource (this |
| 106 // is the state of the request as it comes off IPC). | 106 // is the state of the request as it comes off IPC). |
| 107 for (size_t i = 0; i < data->body.size(); ++i) { | 107 for (size_t i = 0; i < data->body.size(); ++i) { |
| 108 URLRequestInfoData::BodyItem& item = data->body[i]; | 108 URLRequestInfoData::BodyItem& item = data->body[i]; |
| 109 if (item.is_file && !item.file_ref) { | 109 if (item.is_file && !item.file_ref.get()) { |
| 110 EnterResourceNoLock<PPB_FileRef_API> enter( | 110 EnterResourceNoLock<PPB_FileRef_API> enter( |
| 111 item.file_ref_host_resource.host_resource(), false); | 111 item.file_ref_host_resource.host_resource(), false); |
| 112 if (!enter.succeeded()) | 112 if (!enter.succeeded()) |
| 113 return false; | 113 return false; |
| 114 item.file_ref = enter.resource(); | 114 item.file_ref = enter.resource(); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Append the upload data. | 153 // Append the upload data. |
| 154 if (!data->body.empty()) { | 154 if (!data->body.empty()) { |
| 155 WebHTTPBody http_body; | 155 WebHTTPBody http_body; |
| 156 http_body.initialize(); | 156 http_body.initialize(); |
| 157 for (size_t i = 0; i < data->body.size(); ++i) { | 157 for (size_t i = 0; i < data->body.size(); ++i) { |
| 158 const URLRequestInfoData::BodyItem& item = data->body[i]; | 158 const URLRequestInfoData::BodyItem& item = data->body[i]; |
| 159 if (item.is_file) { | 159 if (item.is_file) { |
| 160 if (!AppendFileRefToBody(item.file_ref, | 160 if (!AppendFileRefToBody(item.file_ref.get(), |
| 161 item.start_offset, | 161 item.start_offset, |
| 162 item.number_of_bytes, | 162 item.number_of_bytes, |
| 163 item.expected_last_modified_time, | 163 item.expected_last_modified_time, |
| 164 &http_body)) | 164 &http_body)) |
| 165 return false; | 165 return false; |
| 166 } else { | 166 } else { |
| 167 DCHECK(!item.data.empty()); | 167 DCHECK(!item.data.empty()); |
| 168 http_body.appendData(WebData(item.data)); | 168 http_body.appendData(WebData(item.data)); |
| 169 } | 169 } |
| 170 } | 170 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 197 const ::ppapi::URLRequestInfoData& data) { | 197 const ::ppapi::URLRequestInfoData& data) { |
| 198 return | 198 return |
| 199 data.has_custom_referrer_url || | 199 data.has_custom_referrer_url || |
| 200 data.has_custom_content_transfer_encoding || | 200 data.has_custom_content_transfer_encoding || |
| 201 data.has_custom_user_agent || | 201 data.has_custom_user_agent || |
| 202 url_util::FindAndCompareScheme(data.url, "javascript", NULL); | 202 url_util::FindAndCompareScheme(data.url, "javascript", NULL); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace ppapi | 205 } // namespace ppapi |
| 206 } // namespace webkit | 206 } // namespace webkit |
| OLD | NEW |