Chromium Code Reviews| 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/plugins/ppapi/common.h" | 23 #include "webkit/plugins/ppapi/common.h" |
| 23 #include "webkit/plugins/ppapi/plugin_module.h" | 24 #include "webkit/plugins/ppapi/plugin_module.h" |
| 25 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | |
| 24 #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" | |
| 25 #include "webkit/plugins/ppapi/string.h" | 28 #include "webkit/plugins/ppapi/string.h" |
| 26 #include "webkit/glue/webkit_glue.h" | |
| 27 | 29 |
| 28 using ppapi::StringVar; | 30 using ppapi::StringVar; |
| 29 using ppapi::thunk::EnterResourceNoLock; | 31 using ppapi::thunk::EnterResourceNoLock; |
| 30 using ppapi::thunk::PPB_FileRef_API; | 32 using ppapi::thunk::PPB_FileRef_API; |
| 31 using ppapi::thunk::PPB_URLRequestInfo_API; | 33 using ppapi::thunk::PPB_URLRequestInfo_API; |
| 32 using WebKit::WebData; | 34 using WebKit::WebData; |
| 33 using WebKit::WebHTTPBody; | 35 using WebKit::WebHTTPBody; |
| 34 using WebKit::WebString; | 36 using WebKit::WebString; |
| 35 using WebKit::WebFrame; | 37 using WebKit::WebFrame; |
| 36 using WebKit::WebURL; | 38 using WebKit::WebURL; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 while (it.GetNext()) { | 89 while (it.GetNext()) { |
| 88 if (!IsValidHeaderField(it.name())) | 90 if (!IsValidHeaderField(it.name())) |
| 89 return false; | 91 return false; |
| 90 } | 92 } |
| 91 return true; | 93 return true; |
| 92 } | 94 } |
| 93 | 95 |
| 94 } // namespace | 96 } // namespace |
| 95 | 97 |
| 96 struct PPB_URLRequestInfo_Impl::BodyItem { | 98 struct PPB_URLRequestInfo_Impl::BodyItem { |
| 97 BodyItem(const std::string& data) | 99 explicit BodyItem(const std::string& data) |
| 98 : data(data), | 100 : data(data), |
| 99 start_offset(0), | 101 start_offset(0), |
| 100 number_of_bytes(-1), | 102 number_of_bytes(-1), |
| 101 expected_last_modified_time(0.0) { | 103 expected_last_modified_time(0.0) { |
| 102 } | 104 } |
| 103 | 105 |
| 104 BodyItem(PPB_FileRef_Impl* file_ref, | 106 BodyItem(PPB_FileRef_Impl* file_ref, |
| 105 int64_t start_offset, | 107 int64_t start_offset, |
| 106 int64_t number_of_bytes, | 108 int64_t number_of_bytes, |
| 107 PP_Time expected_last_modified_time) | 109 PP_Time expected_last_modified_time) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 WebString::fromUTF8(it.name()), | 219 WebString::fromUTF8(it.name()), |
| 218 WebString::fromUTF8(it.values())); | 220 WebString::fromUTF8(it.values())); |
| 219 } | 221 } |
| 220 } | 222 } |
| 221 | 223 |
| 222 if (!body_.empty()) { | 224 if (!body_.empty()) { |
| 223 WebHTTPBody http_body; | 225 WebHTTPBody http_body; |
| 224 http_body.initialize(); | 226 http_body.initialize(); |
| 225 for (size_t i = 0; i < body_.size(); ++i) { | 227 for (size_t i = 0; i < body_.size(); ++i) { |
| 226 if (body_[i].file_ref) { | 228 if (body_[i].file_ref) { |
| 229 FilePath platform_path; | |
| 230 switch (body_[i].file_ref->file_system()->type()) { | |
| 231 case PP_FILESYSTEMTYPE_LOCALTEMPORARY: | |
| 232 case PP_FILESYSTEMTYPE_LOCALPERSISTENT: | |
| 233 instance()->delegate()->SyncGetFileSystemPlatformPath( | |
|
darin (slow to review)
2011/08/16 17:28:36
can you insert a TODO(kinuko) here about switching
kinuko
2011/08/17 07:55:28
Done.
| |
| 234 body_[i].file_ref->GetFileSystemURL(), | |
| 235 &platform_path); | |
| 236 break; | |
| 237 case PP_FILESYSTEMTYPE_EXTERNAL: | |
| 238 platform_path = body_[i].file_ref->GetSystemPath(); | |
| 239 break; | |
| 240 default: | |
| 241 NOTREACHED(); | |
| 242 } | |
| 227 http_body.appendFileRange( | 243 http_body.appendFileRange( |
| 228 webkit_glue::FilePathToWebString( | 244 webkit_glue::FilePathToWebString(platform_path), |
| 229 body_[i].file_ref->GetSystemPath()), | |
| 230 body_[i].start_offset, | 245 body_[i].start_offset, |
| 231 body_[i].number_of_bytes, | 246 body_[i].number_of_bytes, |
| 232 body_[i].expected_last_modified_time); | 247 body_[i].expected_last_modified_time); |
| 233 } else { | 248 } else { |
| 234 DCHECK(!body_[i].data.empty()); | 249 DCHECK(!body_[i].data.empty()); |
| 235 http_body.appendData(WebData(body_[i].data)); | 250 http_body.appendData(WebData(body_[i].data)); |
| 236 } | 251 } |
| 237 } | 252 } |
| 238 web_request.setHTTPBody(http_body); | 253 web_request.setHTTPBody(http_body); |
| 239 } | 254 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 has_custom_content_transfer_encoding_ = true; | 359 has_custom_content_transfer_encoding_ = true; |
| 345 custom_content_transfer_encoding_ = value; | 360 custom_content_transfer_encoding_ = value; |
| 346 return true; | 361 return true; |
| 347 default: | 362 default: |
| 348 return false; | 363 return false; |
| 349 } | 364 } |
| 350 } | 365 } |
| 351 | 366 |
| 352 } // namespace ppapi | 367 } // namespace ppapi |
| 353 } // namespace webkit | 368 } // namespace webkit |
| OLD | NEW |