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

Unified Diff: webkit/plugins/ppapi/ppb_url_loader_impl.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/plugins/ppapi/ppb_url_loader_impl.h ('k') | webkit/plugins/ppapi/ppb_url_request_info_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/plugins/ppapi/ppb_url_loader_impl.cc
===================================================================
--- webkit/plugins/ppapi/ppb_url_loader_impl.cc (revision 0)
+++ webkit/plugins/ppapi/ppb_url_loader_impl.cc (working copy)
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "webkit/glue/plugins/pepper_url_loader.h"
+#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "base/logging.h"
#include "ppapi/c/pp_completion_callback.h"
@@ -20,10 +20,10 @@
#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
#include "webkit/appcache/web_application_cache_host_impl.h"
-#include "webkit/glue/plugins/pepper_common.h"
-#include "webkit/glue/plugins/pepper_plugin_instance.h"
-#include "webkit/glue/plugins/pepper_url_request_info.h"
-#include "webkit/glue/plugins/pepper_url_response_info.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/plugin_instance.h"
+#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
+#include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
using appcache::WebApplicationCacheHostImpl;
using WebKit::WebFrame;
@@ -39,7 +39,8 @@
#pragma warning(disable : 4996)
#endif
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
@@ -48,23 +49,24 @@
if (!instance)
return 0;
- URLLoader* loader = new URLLoader(instance, false);
+ PPB_URLLoader_Impl* loader = new PPB_URLLoader_Impl(instance, false);
return loader->GetReference();
}
PP_Bool IsURLLoader(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<URLLoader>(resource));
+ return BoolToPPBool(!!Resource::GetAs<PPB_URLLoader_Impl>(resource));
}
int32_t Open(PP_Resource loader_id,
PP_Resource request_id,
PP_CompletionCallback callback) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_ERROR_BADRESOURCE;
- scoped_refptr<URLRequestInfo> request(
- Resource::GetAs<URLRequestInfo>(request_id));
+ scoped_refptr<PPB_URLRequestInfo_Impl> request(
+ Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id));
if (!request)
return PP_ERROR_BADRESOURCE;
@@ -73,7 +75,8 @@
int32_t FollowRedirect(PP_Resource loader_id,
PP_CompletionCallback callback) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_ERROR_BADRESOURCE;
@@ -81,9 +84,10 @@
}
PP_Bool GetUploadProgress(PP_Resource loader_id,
- int64_t* bytes_sent,
- int64_t* total_bytes_to_be_sent) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ int64_t* bytes_sent,
+ int64_t* total_bytes_to_be_sent) {
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_FALSE;
@@ -94,7 +98,8 @@
PP_Bool GetDownloadProgress(PP_Resource loader_id,
int64_t* bytes_received,
int64_t* total_bytes_to_be_received) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_FALSE;
@@ -103,11 +108,12 @@
}
PP_Resource GetResponseInfo(PP_Resource loader_id) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return 0;
- URLResponseInfo* response_info = loader->response_info();
+ PPB_URLResponseInfo_Impl* response_info = loader->response_info();
if (!response_info)
return 0;
@@ -118,7 +124,8 @@
char* buffer,
int32_t bytes_to_read,
PP_CompletionCallback callback) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_ERROR_BADRESOURCE;
@@ -127,7 +134,8 @@
int32_t FinishStreamingToFile(PP_Resource loader_id,
PP_CompletionCallback callback) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_ERROR_BADRESOURCE;
@@ -135,7 +143,8 @@
}
void Close(PP_Resource loader_id) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return;
@@ -156,7 +165,8 @@
};
void GrantUniversalAccess(PP_Resource loader_id) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return;
@@ -165,7 +175,8 @@
void SetStatusCallback(PP_Resource loader_id,
PP_URLLoaderTrusted_StatusCallback cb) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return;
loader->SetStatusCallback(cb);
@@ -182,7 +193,8 @@
} // namespace
-URLLoader::URLLoader(PluginInstance* instance, bool main_document_loader)
+PPB_URLLoader_Impl::PPB_URLLoader_Impl(PluginInstance* instance,
+ bool main_document_loader)
: Resource(instance->module()),
instance_(instance),
main_document_loader_(main_document_loader),
@@ -199,27 +211,27 @@
instance->AddObserver(this);
}
-URLLoader::~URLLoader() {
+PPB_URLLoader_Impl::~PPB_URLLoader_Impl() {
if (instance_)
instance_->RemoveObserver(this);
}
// static
-const PPB_URLLoader* URLLoader::GetInterface() {
+const PPB_URLLoader* PPB_URLLoader_Impl::GetInterface() {
return &ppb_urlloader;
}
// static
-const PPB_URLLoaderTrusted* URLLoader::GetTrustedInterface() {
+const PPB_URLLoaderTrusted* PPB_URLLoader_Impl::GetTrustedInterface() {
return &ppb_urlloadertrusted;
}
-URLLoader* URLLoader::AsURLLoader() {
+PPB_URLLoader_Impl* PPB_URLLoader_Impl::AsPPB_URLLoader_Impl() {
return this;
}
-int32_t URLLoader::Open(URLRequestInfo* request,
- PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::Open(PPB_URLRequestInfo_Impl* request,
+ PP_CompletionCallback callback) {
if (loader_.get())
return PP_ERROR_INPROGRESS;
@@ -250,14 +262,14 @@
loader_->loadAsynchronously(web_request, this);
- request_info_ = scoped_refptr<URLRequestInfo>(request);
+ request_info_ = scoped_refptr<PPB_URLRequestInfo_Impl>(request);
pending_callback_ = callback;
// Notify completion when we receive a redirect or response headers.
return PP_ERROR_WOULDBLOCK;
}
-int32_t URLLoader::FollowRedirect(PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) {
if (pending_callback_.func)
return PP_ERROR_INPROGRESS;
@@ -276,8 +288,8 @@
return PP_ERROR_WOULDBLOCK;
}
-bool URLLoader::GetUploadProgress(int64_t* bytes_sent,
- int64_t* total_bytes_to_be_sent) {
+bool PPB_URLLoader_Impl::GetUploadProgress(int64_t* bytes_sent,
+ int64_t* total_bytes_to_be_sent) {
if (!RecordUploadProgress()) {
*bytes_sent = 0;
*total_bytes_to_be_sent = 0;
@@ -288,8 +300,9 @@
return true;
}
-bool URLLoader::GetDownloadProgress(int64_t* bytes_received,
- int64_t* total_bytes_to_be_received) {
+bool PPB_URLLoader_Impl::GetDownloadProgress(
+ int64_t* bytes_received,
+ int64_t* total_bytes_to_be_received) {
if (!RecordDownloadProgress()) {
*bytes_received = 0;
*total_bytes_to_be_received = 0;
@@ -300,8 +313,9 @@
return true;
}
-int32_t URLLoader::ReadResponseBody(char* buffer, int32_t bytes_to_read,
- PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::ReadResponseBody(char* buffer,
+ int32_t bytes_to_read,
+ PP_CompletionCallback callback) {
if (!response_info_ || response_info_->body())
return PP_ERROR_FAILED;
if (bytes_to_read <= 0 || !buffer)
@@ -330,7 +344,8 @@
return PP_ERROR_WOULDBLOCK;
}
-int32_t URLLoader::FinishStreamingToFile(PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::FinishStreamingToFile(
+ PP_CompletionCallback callback) {
if (!response_info_ || !response_info_->body())
return PP_ERROR_FAILED;
if (pending_callback_.func)
@@ -345,7 +360,7 @@
return PP_ERROR_WOULDBLOCK;
}
-void URLLoader::Close() {
+void PPB_URLLoader_Impl::Close() {
if (loader_.get()) {
loader_->cancel();
} else if (main_document_loader_) {
@@ -354,17 +369,19 @@
}
}
-void URLLoader::GrantUniversalAccess() {
+void PPB_URLLoader_Impl::GrantUniversalAccess() {
has_universal_access_ = true;
}
-void URLLoader::SetStatusCallback(PP_URLLoaderTrusted_StatusCallback cb) {
+void PPB_URLLoader_Impl::SetStatusCallback(
+ PP_URLLoaderTrusted_StatusCallback cb) {
status_callback_ = cb;
}
-void URLLoader::willSendRequest(WebURLLoader* loader,
- WebURLRequest& new_request,
- const WebURLResponse& redirect_response) {
+void PPB_URLLoader_Impl::willSendRequest(
+ WebURLLoader* loader,
+ WebURLRequest& new_request,
+ const WebURLResponse& redirect_response) {
if (!request_info_->follow_redirects()) {
SaveResponse(redirect_response);
loader_->setDefersLoading(true);
@@ -378,17 +395,18 @@
}
}
-void URLLoader::didSendData(WebURLLoader* loader,
- unsigned long long bytes_sent,
- unsigned long long total_bytes_to_be_sent) {
+void PPB_URLLoader_Impl::didSendData(
+ WebURLLoader* loader,
+ unsigned long long bytes_sent,
+ unsigned long long total_bytes_to_be_sent) {
// TODO(darin): Bounds check input?
bytes_sent_ = static_cast<int64_t>(bytes_sent);
total_bytes_to_be_sent_ = static_cast<int64_t>(total_bytes_to_be_sent);
UpdateStatus();
}
-void URLLoader::didReceiveResponse(WebURLLoader* loader,
- const WebURLResponse& response) {
+void PPB_URLLoader_Impl::didReceiveResponse(WebURLLoader* loader,
+ const WebURLResponse& response) {
SaveResponse(response);
// Sets -1 if the content length is unknown.
@@ -398,15 +416,15 @@
RunCallback(PP_OK);
}
-void URLLoader::didDownloadData(WebURLLoader* loader,
- int data_length) {
+void PPB_URLLoader_Impl::didDownloadData(WebURLLoader* loader,
+ int data_length) {
bytes_received_ += data_length;
UpdateStatus();
}
-void URLLoader::didReceiveData(WebURLLoader* loader,
- const char* data,
- int data_length) {
+void PPB_URLLoader_Impl::didReceiveData(WebURLLoader* loader,
+ const char* data,
+ int data_length) {
bytes_received_ += data_length;
buffer_.insert(buffer_.end(), data, data + data_length);
@@ -417,18 +435,20 @@
}
}
-void URLLoader::didFinishLoading(WebURLLoader* loader, double finish_time) {
+void PPB_URLLoader_Impl::didFinishLoading(WebURLLoader* loader,
+ double finish_time) {
done_status_ = PP_OK;
RunCallback(done_status_);
}
-void URLLoader::didFail(WebURLLoader* loader, const WebURLError& error) {
+void PPB_URLLoader_Impl::didFail(WebURLLoader* loader,
+ const WebURLError& error) {
// TODO(darin): Provide more detailed error information.
done_status_ = PP_ERROR_FAILED;
RunCallback(done_status_);
}
-void URLLoader::InstanceDestroyed(PluginInstance* instance) {
+void PPB_URLLoader_Impl::InstanceDestroyed(PluginInstance* instance) {
// When the instance is destroyed, we force delete any associated loads.
DCHECK(instance == instance_);
instance_ = NULL;
@@ -436,7 +456,7 @@
// Normally the only ref to this class will be from the plugin which
// ForceDeletePluginResourceRefs will free. We don't want our object to be
// deleted out from under us until the function completes.
- scoped_refptr<URLLoader> death_grip(this);
+ scoped_refptr<PPB_URLLoader_Impl> death_grip(this);
// Force delete any plugin refs to us. If the instance is being deleted, we
// don't want to allow the requests to continue to use bandwidth and send us
@@ -462,7 +482,7 @@
// goes out of scope.
}
-void URLLoader::RunCallback(int32_t result) {
+void PPB_URLLoader_Impl::RunCallback(int32_t result) {
if (!pending_callback_.func)
return;
@@ -471,7 +491,7 @@
PP_RunCompletionCallback(&callback, result);
}
-size_t URLLoader::FillUserBuffer() {
+size_t PPB_URLLoader_Impl::FillUserBuffer() {
DCHECK(user_buffer_);
DCHECK(user_buffer_size_);
@@ -485,14 +505,15 @@
return bytes_to_copy;
}
-void URLLoader::SaveResponse(const WebKit::WebURLResponse& response) {
- scoped_refptr<URLResponseInfo> response_info(new URLResponseInfo(module()));
+void PPB_URLLoader_Impl::SaveResponse(const WebKit::WebURLResponse& response) {
+ scoped_refptr<PPB_URLResponseInfo_Impl> response_info(
+ new PPB_URLResponseInfo_Impl(module()));
if (response_info->Initialize(response))
response_info_ = response_info;
}
// Checks that the client can request the URL. Returns a PPAPI error code.
-int32_t URLLoader::CanRequest(const WebKit::WebFrame* frame,
+int32_t PPB_URLLoader_Impl::CanRequest(const WebKit::WebFrame* frame,
const WebKit::WebURL& url) {
if (!has_universal_access_ &&
!frame->securityOrigin().canRequest(url))
@@ -501,7 +522,7 @@
return PP_OK;
}
-void URLLoader::UpdateStatus() {
+void PPB_URLLoader_Impl::UpdateStatus() {
if (status_callback_ &&
(RecordDownloadProgress() || RecordUploadProgress())) {
PP_Resource pp_resource = GetReferenceNoAddRef();
@@ -525,12 +546,14 @@
}
}
-bool URLLoader::RecordDownloadProgress() const {
+bool PPB_URLLoader_Impl::RecordDownloadProgress() const {
return request_info_ && request_info_->record_download_progress();
}
-bool URLLoader::RecordUploadProgress() const {
+bool PPB_URLLoader_Impl::RecordUploadProgress() const {
return request_info_ && request_info_->record_upload_progress();
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
« no previous file with comments | « webkit/plugins/ppapi/ppb_url_loader_impl.h ('k') | webkit/plugins/ppapi/ppb_url_request_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698