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

Side by Side Diff: webkit/glue/plugins/pepper_url_loader.cc

Issue 3053009: Pepper stream-to-file plumbing.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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/glue/plugins/pepper_url_loader.h ('k') | webkit/glue/plugins/pepper_url_request_info.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/glue/plugins/pepper_url_loader.h" 5 #include "webkit/glue/plugins/pepper_url_loader.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/ppapi/c/pp_completion_callback.h" 8 #include "third_party/ppapi/c/pp_completion_callback.h"
9 #include "third_party/ppapi/c/pp_errors.h" 9 #include "third_party/ppapi/c/pp_errors.h"
10 #include "third_party/ppapi/c/ppb_url_loader.h" 10 #include "third_party/ppapi/c/ppb_url_loader.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
14 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" 14 #include "third_party/WebKit/WebKit/chromium/public/WebKit.h"
15 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" 15 #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" 17 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
18 #include "webkit/glue/plugins/pepper_plugin_instance.h" 19 #include "webkit/glue/plugins/pepper_plugin_instance.h"
19 #include "webkit/glue/plugins/pepper_url_request_info.h" 20 #include "webkit/glue/plugins/pepper_url_request_info.h"
20 #include "webkit/glue/plugins/pepper_url_response_info.h" 21 #include "webkit/glue/plugins/pepper_url_response_info.h"
21 22
22 using WebKit::WebFrame; 23 using WebKit::WebFrame;
23 using WebKit::WebString; 24 using WebKit::WebString;
24 using WebKit::WebURL; 25 using WebKit::WebURL;
25 using WebKit::WebURLError; 26 using WebKit::WebURLError;
26 using WebKit::WebURLLoader; 27 using WebKit::WebURLLoader;
27 using WebKit::WebURLRequest; 28 using WebKit::WebURLRequest;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 &Close 142 &Close
142 }; 143 };
143 144
144 } // namespace 145 } // namespace
145 146
146 URLLoader::URLLoader(PluginInstance* instance) 147 URLLoader::URLLoader(PluginInstance* instance)
147 : Resource(instance->module()), 148 : Resource(instance->module()),
148 instance_(instance), 149 instance_(instance),
149 pending_callback_(), 150 pending_callback_(),
150 bytes_sent_(0), 151 bytes_sent_(0),
151 total_bytes_to_be_sent_(0), 152 total_bytes_to_be_sent_(-1),
152 bytes_received_(0), 153 bytes_received_(0),
153 total_bytes_to_be_received_(0), 154 total_bytes_to_be_received_(-1),
154 user_buffer_(NULL), 155 user_buffer_(NULL),
155 user_buffer_size_(0), 156 user_buffer_size_(0),
156 done_(false) { 157 done_(false) {
157 } 158 }
158 159
159 URLLoader::~URLLoader() { 160 URLLoader::~URLLoader() {
160 } 161 }
161 162
162 // static 163 // static
163 const PPB_URLLoader* URLLoader::GetInterface() { 164 const PPB_URLLoader* URLLoader::GetInterface() {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 bytes_sent_ = static_cast<int64_t>(bytes_sent); 242 bytes_sent_ = static_cast<int64_t>(bytes_sent);
242 total_bytes_to_be_sent_ = static_cast<int64_t>(total_bytes_to_be_sent); 243 total_bytes_to_be_sent_ = static_cast<int64_t>(total_bytes_to_be_sent);
243 } 244 }
244 245
245 void URLLoader::didReceiveResponse(WebURLLoader* loader, 246 void URLLoader::didReceiveResponse(WebURLLoader* loader,
246 const WebURLResponse& response) { 247 const WebURLResponse& response) {
247 scoped_refptr<URLResponseInfo> response_info(new URLResponseInfo(module())); 248 scoped_refptr<URLResponseInfo> response_info(new URLResponseInfo(module()));
248 if (response_info->Initialize(response)) 249 if (response_info->Initialize(response))
249 response_info_ = response_info; 250 response_info_ = response_info;
250 251
252 // Sets -1 if the content length is unknown.
253 total_bytes_to_be_received_ = response.expectedContentLength();
254
251 RunCallback(PP_OK); 255 RunCallback(PP_OK);
252 } 256 }
253 257
258 void URLLoader::didDownloadData(WebURLLoader* loader,
259 int data_length) {
260 bytes_received_ += data_length;
261 }
262
254 void URLLoader::didReceiveData(WebURLLoader* loader, 263 void URLLoader::didReceiveData(WebURLLoader* loader,
255 const char* data, 264 const char* data,
256 int data_length) { 265 int data_length) {
266 bytes_received_ += data_length;
267
257 buffer_.insert(buffer_.end(), data, data + data_length); 268 buffer_.insert(buffer_.end(), data, data + data_length);
258 if (user_buffer_) { 269 if (user_buffer_) {
259 RunCallback(FillUserBuffer()); 270 RunCallback(FillUserBuffer());
260 } else { 271 } else {
261 DCHECK(!pending_callback_.func); 272 DCHECK(!pending_callback_.func);
262 } 273 }
263 } 274 }
264 275
265 void URLLoader::didFinishLoading(WebURLLoader* loader) { 276 void URLLoader::didFinishLoading(WebURLLoader* loader) {
266 done_ = true; 277 done_ = true;
(...skipping 23 matching lines...) Expand all
290 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_); 301 std::copy(buffer_.begin(), buffer_.begin() + bytes_to_copy, user_buffer_);
291 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy); 302 buffer_.erase(buffer_.begin(), buffer_.begin() + bytes_to_copy);
292 303
293 // Reset for next time. 304 // Reset for next time.
294 user_buffer_ = NULL; 305 user_buffer_ = NULL;
295 user_buffer_size_ = 0; 306 user_buffer_size_ = 0;
296 return bytes_to_copy; 307 return bytes_to_copy;
297 } 308 }
298 309
299 } // namespace pepper 310 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_url_loader.h ('k') | webkit/glue/plugins/pepper_url_request_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698