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

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

Issue 7046091: Fix problems with PPB_URLLoader_Impl and PPAPITests.URLLoader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
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_loader_impl.h" 5 #include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/base/net_errors.h"
8 #include "ppapi/c/pp_completion_callback.h" 9 #include "ppapi/c/pp_completion_callback.h"
9 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/ppb_url_loader.h" 11 #include "ppapi/c/ppb_url_loader.h"
11 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" 12 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKitClient.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h " 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h "
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h"
23 #include "webkit/appcache/web_application_cache_host_impl.h" 25 #include "webkit/appcache/web_application_cache_host_impl.h"
24 #include "webkit/plugins/ppapi/common.h" 26 #include "webkit/plugins/ppapi/common.h"
25 #include "webkit/plugins/ppapi/plugin_module.h" 27 #include "webkit/plugins/ppapi/plugin_module.h"
26 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 28 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
27 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h" 29 #include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
28 #include "webkit/plugins/ppapi/ppb_url_response_info_impl.h" 30 #include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 242 }
241 } 243 }
242 244
243 int32_t PPB_URLLoader_Impl::Open(PPB_URLRequestInfo_Impl* request, 245 int32_t PPB_URLLoader_Impl::Open(PPB_URLRequestInfo_Impl* request,
244 PP_CompletionCallback callback) { 246 PP_CompletionCallback callback) {
245 int32_t rv = ValidateCallback(callback); 247 int32_t rv = ValidateCallback(callback);
246 if (rv != PP_OK) 248 if (rv != PP_OK)
247 return rv; 249 return rv;
248 250
249 if (request->RequiresUniversalAccess() && !has_universal_access_) 251 if (request->RequiresUniversalAccess() && !has_universal_access_)
250 return PP_ERROR_BADARGUMENT; 252 return PP_ERROR_BADARGUMENT;
bbudge 2011/06/15 22:56:56 I'm going to change this to PP_ERROR_NOACCESS per
251 253
252 if (loader_.get()) 254 if (loader_.get())
253 return PP_ERROR_INPROGRESS; 255 return PP_ERROR_INPROGRESS;
254 256
255 WebFrame* frame = GetFrame(instance()); 257 WebFrame* frame = GetFrame(instance());
256 if (!frame) 258 if (!frame)
257 return PP_ERROR_FAILED; 259 return PP_ERROR_FAILED;
258 WebURLRequest web_request(request->ToWebURLRequest(frame)); 260 WebURLRequest web_request(request->ToWebURLRequest(frame));
259 261
260 WebURLLoaderOptions options; 262 WebURLLoaderOptions options;
(...skipping 11 matching lines...) Expand all
272 274
273 is_asynchronous_load_suspended_ = false; 275 is_asynchronous_load_suspended_ = false;
274 loader_.reset(frame->createAssociatedURLLoader(options)); 276 loader_.reset(frame->createAssociatedURLLoader(options));
275 if (!loader_.get()) 277 if (!loader_.get())
276 return PP_ERROR_FAILED; 278 return PP_ERROR_FAILED;
277 279
278 loader_->loadAsynchronously(web_request, this); 280 loader_->loadAsynchronously(web_request, this);
279 // Check for immediate failure; The AssociatedURLLoader will call our 281 // Check for immediate failure; The AssociatedURLLoader will call our
280 // didFail method synchronously for certain kinds of access violations 282 // didFail method synchronously for certain kinds of access violations
281 // so we must return an error to the caller. 283 // so we must return an error to the caller.
282 // TODO(bbudge) Modify the underlying AssociatedURLLoader to only call 284 // TODO(bbudge) Remove this code when AssociatedURLLoader is changed to
283 // back asynchronously. 285 // return errors asynchronously.
284 if (done_status_ == PP_ERROR_FAILED) 286 if (done_status_ == PP_ERROR_FAILED ||
285 return PP_ERROR_NOACCESS; 287 done_status_ == PP_ERROR_NOACCESS)
288 return done_status_;
286 289
287 request_info_ = scoped_refptr<PPB_URLRequestInfo_Impl>(request); 290 request_info_ = scoped_refptr<PPB_URLRequestInfo_Impl>(request);
288 291
289 // Notify completion when we receive a redirect or response headers. 292 // Notify completion when we receive a redirect or response headers.
290 RegisterCallback(callback); 293 RegisterCallback(callback);
291 return PP_OK_COMPLETIONPENDING; 294 return PP_OK_COMPLETIONPENDING;
292 } 295 }
293 296
294 int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) { 297 int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) {
295 int32_t rv = ValidateCallback(callback); 298 int32_t rv = ValidateCallback(callback);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 471 }
469 472
470 void PPB_URLLoader_Impl::didFinishLoading(WebURLLoader* loader, 473 void PPB_URLLoader_Impl::didFinishLoading(WebURLLoader* loader,
471 double finish_time) { 474 double finish_time) {
472 done_status_ = PP_OK; 475 done_status_ = PP_OK;
473 RunCallback(done_status_); 476 RunCallback(done_status_);
474 } 477 }
475 478
476 void PPB_URLLoader_Impl::didFail(WebURLLoader* loader, 479 void PPB_URLLoader_Impl::didFail(WebURLLoader* loader,
477 const WebURLError& error) { 480 const WebURLError& error) {
478 // TODO(darin): Provide more detailed error information. 481 // By default report PP_ERROR_NOACCESS. This assumes that errors from WebKit
479 done_status_ = PP_ERROR_FAILED; 482 // are access errors.
483 done_status_ = PP_ERROR_NOACCESS;
484 // For our 'net' error domain, report all non-access errors as
darin (slow to review) 2011/06/15 23:00:20 nit: these comments just summarize what the code d
bbudge 2011/06/15 23:50:21 Done.
485 // PP_ERROR_FAILED.
486 if (error.domain.equals(WebString::fromUTF8(net::kErrorDomain)) &&
487 error.reason != net::ERR_ACCESS_DENIED &&
488 error.reason != net::ERR_NETWORK_ACCESS_DENIED)
489 done_status_ = PP_ERROR_FAILED;
490
480 RunCallback(done_status_); 491 RunCallback(done_status_);
481 } 492 }
482 493
483 int32_t PPB_URLLoader_Impl::ValidateCallback(PP_CompletionCallback callback) { 494 int32_t PPB_URLLoader_Impl::ValidateCallback(PP_CompletionCallback callback) {
484 // We only support non-blocking calls. 495 // We only support non-blocking calls.
485 if (!callback.func) 496 if (!callback.func)
486 return PP_ERROR_BADARGUMENT; 497 return PP_ERROR_BADARGUMENT;
487 498
488 if (pending_callback_.get() && !pending_callback_->completed()) 499 if (pending_callback_.get() && !pending_callback_->completed())
489 return PP_ERROR_INPROGRESS; 500 return PP_ERROR_INPROGRESS;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 bool PPB_URLLoader_Impl::RecordDownloadProgress() const { 584 bool PPB_URLLoader_Impl::RecordDownloadProgress() const {
574 return request_info_ && request_info_->record_download_progress(); 585 return request_info_ && request_info_->record_download_progress();
575 } 586 }
576 587
577 bool PPB_URLLoader_Impl::RecordUploadProgress() const { 588 bool PPB_URLLoader_Impl::RecordUploadProgress() const {
578 return request_info_ && request_info_->record_upload_progress(); 589 return request_info_ && request_info_->record_upload_progress();
579 } 590 }
580 591
581 } // namespace ppapi 592 } // namespace ppapi
582 } // namespace webkit 593 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698