| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ppb_url_request_info_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.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" |
| 11 #include "net/http/http_util.h" | 11 #include "net/http/http_util.h" |
| 12 #include "ppapi/c/pp_var.h" | 12 #include "ppapi/c/pp_var.h" |
| 13 #include "ppapi/shared_impl/var.h" | 13 #include "ppapi/shared_impl/var.h" |
| 14 #include "ppapi/thunk/enter.h" | 14 #include "ppapi/thunk/enter.h" |
| 15 #include "ppapi/thunk/ppb_file_ref_api.h" | 15 #include "ppapi/thunk/ppb_file_ref_api.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebData.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHTTPBody.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHTTPBody.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
| 22 #include "webkit/glue/webkit_glue.h" | 22 #include "webkit/glue/webkit_glue.h" |
| 23 #include "webkit/plugins/ppapi/common.h" | 23 #include "webkit/plugins/ppapi/common.h" |
| 24 #include "webkit/plugins/ppapi/plugin_module.h" | 24 #include "webkit/plugins/ppapi/plugin_module.h" |
| 25 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 25 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 26 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 26 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
| 27 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" | 27 #include "webkit/plugins/ppapi/ppb_file_system_impl.h" |
| 28 #include "webkit/plugins/ppapi/resource_helper.h" |
| 28 #include "webkit/plugins/ppapi/string.h" | 29 #include "webkit/plugins/ppapi/string.h" |
| 29 | 30 |
| 30 using ppapi::StringVar; | 31 using ppapi::StringVar; |
| 31 using ppapi::thunk::EnterResourceNoLock; | 32 using ppapi::thunk::EnterResourceNoLock; |
| 32 using ppapi::thunk::PPB_FileRef_API; | 33 using ppapi::thunk::PPB_FileRef_API; |
| 33 using ppapi::thunk::PPB_URLRequestInfo_API; | 34 using ppapi::thunk::PPB_URLRequestInfo_API; |
| 34 using WebKit::WebData; | 35 using WebKit::WebData; |
| 35 using WebKit::WebHTTPBody; | 36 using WebKit::WebHTTPBody; |
| 36 using WebKit::WebString; | 37 using WebKit::WebString; |
| 37 using WebKit::WebFrame; | 38 using WebKit::WebFrame; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 expected_last_modified_time(expected_last_modified_time) { | 177 expected_last_modified_time(expected_last_modified_time) { |
| 177 } | 178 } |
| 178 | 179 |
| 179 std::string data; | 180 std::string data; |
| 180 scoped_refptr<PPB_FileRef_Impl> file_ref; | 181 scoped_refptr<PPB_FileRef_Impl> file_ref; |
| 181 int64_t start_offset; | 182 int64_t start_offset; |
| 182 int64_t number_of_bytes; | 183 int64_t number_of_bytes; |
| 183 PP_Time expected_last_modified_time; | 184 PP_Time expected_last_modified_time; |
| 184 }; | 185 }; |
| 185 | 186 |
| 186 PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginInstance* instance) | 187 PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PP_Instance instance) |
| 187 : Resource(instance), | 188 : Resource(instance), |
| 188 stream_to_file_(false), | 189 stream_to_file_(false), |
| 189 follow_redirects_(true), | 190 follow_redirects_(true), |
| 190 record_download_progress_(false), | 191 record_download_progress_(false), |
| 191 record_upload_progress_(false), | 192 record_upload_progress_(false), |
| 192 has_custom_referrer_url_(false), | 193 has_custom_referrer_url_(false), |
| 193 allow_cross_origin_requests_(false), | 194 allow_cross_origin_requests_(false), |
| 194 allow_credentials_(false), | 195 allow_credentials_(false), |
| 195 has_custom_content_transfer_encoding_(false), | 196 has_custom_content_transfer_encoding_(false), |
| 196 prefetch_buffer_upper_threshold_(kDefaultPrefetchBufferUpperThreshold), | 197 prefetch_buffer_upper_threshold_(kDefaultPrefetchBufferUpperThreshold), |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 WebHTTPBody http_body; | 289 WebHTTPBody http_body; |
| 289 http_body.initialize(); | 290 http_body.initialize(); |
| 290 for (size_t i = 0; i < body_.size(); ++i) { | 291 for (size_t i = 0; i < body_.size(); ++i) { |
| 291 if (body_[i].file_ref) { | 292 if (body_[i].file_ref) { |
| 292 FilePath platform_path; | 293 FilePath platform_path; |
| 293 switch (body_[i].file_ref->file_system()->type()) { | 294 switch (body_[i].file_ref->file_system()->type()) { |
| 294 case PP_FILESYSTEMTYPE_LOCALTEMPORARY: | 295 case PP_FILESYSTEMTYPE_LOCALTEMPORARY: |
| 295 case PP_FILESYSTEMTYPE_LOCALPERSISTENT: | 296 case PP_FILESYSTEMTYPE_LOCALPERSISTENT: |
| 296 // TODO(kinuko): remove this sync IPC when we add more generic | 297 // TODO(kinuko): remove this sync IPC when we add more generic |
| 297 // AppendURLRange solution that works for both Blob/FileSystem URL. | 298 // AppendURLRange solution that works for both Blob/FileSystem URL. |
| 298 instance()->delegate()->SyncGetFileSystemPlatformPath( | 299 ResourceHelper::GetPluginDelegate(this)-> |
| 299 body_[i].file_ref->GetFileSystemURL(), | 300 SyncGetFileSystemPlatformPath( |
| 300 &platform_path); | 301 body_[i].file_ref->GetFileSystemURL(), &platform_path); |
| 301 break; | 302 break; |
| 302 case PP_FILESYSTEMTYPE_EXTERNAL: | 303 case PP_FILESYSTEMTYPE_EXTERNAL: |
| 303 platform_path = body_[i].file_ref->GetSystemPath(); | 304 platform_path = body_[i].file_ref->GetSystemPath(); |
| 304 break; | 305 break; |
| 305 default: | 306 default: |
| 306 NOTREACHED(); | 307 NOTREACHED(); |
| 307 } | 308 } |
| 308 http_body.appendFileRange( | 309 http_body.appendFileRange( |
| 309 webkit_glue::FilePathToWebString(platform_path), | 310 webkit_glue::FilePathToWebString(platform_path), |
| 310 body_[i].start_offset, | 311 body_[i].start_offset, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 has_custom_content_transfer_encoding_ = true; | 427 has_custom_content_transfer_encoding_ = true; |
| 427 custom_content_transfer_encoding_ = value; | 428 custom_content_transfer_encoding_ = value; |
| 428 return true; | 429 return true; |
| 429 default: | 430 default: |
| 430 return false; | 431 return false; |
| 431 } | 432 } |
| 432 } | 433 } |
| 433 | 434 |
| 434 } // namespace ppapi | 435 } // namespace ppapi |
| 435 } // namespace webkit | 436 } // namespace webkit |
| OLD | NEW |