Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: webkit/plugins/ppapi/ppb_url_request_info_impl.cc

Issue 7618039: PPB_URLRequestInfo::AppendFileToBody using sync ipc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_system_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 while (it.GetNext()) { 152 while (it.GetNext()) {
151 if (!IsValidHeaderField(it.name())) 153 if (!IsValidHeaderField(it.name()))
152 return false; 154 return false;
153 } 155 }
154 return true; 156 return true;
155 } 157 }
156 158
157 } // namespace 159 } // namespace
158 160
159 struct PPB_URLRequestInfo_Impl::BodyItem { 161 struct PPB_URLRequestInfo_Impl::BodyItem {
160 BodyItem(const std::string& data) 162 explicit BodyItem(const std::string& data)
161 : data(data), 163 : data(data),
162 start_offset(0), 164 start_offset(0),
163 number_of_bytes(-1), 165 number_of_bytes(-1),
164 expected_last_modified_time(0.0) { 166 expected_last_modified_time(0.0) {
165 } 167 }
166 168
167 BodyItem(PPB_FileRef_Impl* file_ref, 169 BodyItem(PPB_FileRef_Impl* file_ref,
168 int64_t start_offset, 170 int64_t start_offset,
169 int64_t number_of_bytes, 171 int64_t number_of_bytes,
170 PP_Time expected_last_modified_time) 172 PP_Time expected_last_modified_time)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 WebString::fromUTF8(it.name()), 282 WebString::fromUTF8(it.name()),
281 WebString::fromUTF8(it.values())); 283 WebString::fromUTF8(it.values()));
282 } 284 }
283 } 285 }
284 286
285 if (!body_.empty()) { 287 if (!body_.empty()) {
286 WebHTTPBody http_body; 288 WebHTTPBody http_body;
287 http_body.initialize(); 289 http_body.initialize();
288 for (size_t i = 0; i < body_.size(); ++i) { 290 for (size_t i = 0; i < body_.size(); ++i) {
289 if (body_[i].file_ref) { 291 if (body_[i].file_ref) {
292 FilePath platform_path;
293 switch (body_[i].file_ref->file_system()->type()) {
294 case PP_FILESYSTEMTYPE_LOCALTEMPORARY:
295 case PP_FILESYSTEMTYPE_LOCALPERSISTENT:
296 // TODO(kinuko): remove this sync IPC when we add more generic
297 // AppendURLRange solution that works for both Blob/FileSystem URL.
298 instance()->delegate()->SyncGetFileSystemPlatformPath(
299 body_[i].file_ref->GetFileSystemURL(),
300 &platform_path);
301 break;
302 case PP_FILESYSTEMTYPE_EXTERNAL:
303 platform_path = body_[i].file_ref->GetSystemPath();
304 break;
305 default:
306 NOTREACHED();
307 }
290 http_body.appendFileRange( 308 http_body.appendFileRange(
291 webkit_glue::FilePathToWebString( 309 webkit_glue::FilePathToWebString(platform_path),
292 body_[i].file_ref->GetSystemPath()),
293 body_[i].start_offset, 310 body_[i].start_offset,
294 body_[i].number_of_bytes, 311 body_[i].number_of_bytes,
295 body_[i].expected_last_modified_time); 312 body_[i].expected_last_modified_time);
296 } else { 313 } else {
297 DCHECK(!body_[i].data.empty()); 314 DCHECK(!body_[i].data.empty());
298 http_body.appendData(WebData(body_[i].data)); 315 http_body.appendData(WebData(body_[i].data));
299 } 316 }
300 } 317 }
301 web_request.setHTTPBody(http_body); 318 web_request.setHTTPBody(http_body);
302 } 319 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 has_custom_content_transfer_encoding_ = true; 426 has_custom_content_transfer_encoding_ = true;
410 custom_content_transfer_encoding_ = value; 427 custom_content_transfer_encoding_ = value;
411 return true; 428 return true;
412 default: 429 default:
413 return false; 430 return false;
414 } 431 }
415 } 432 }
416 433
417 } // namespace ppapi 434 } // namespace ppapi
418 } // namespace webkit 435 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppb_file_system_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698