summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins/pepper_url_loader.h
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/plugins/pepper_url_loader.h')
-rw-r--r--webkit/glue/plugins/pepper_url_loader.h54
1 files changed, 42 insertions, 12 deletions
diff --git a/webkit/glue/plugins/pepper_url_loader.h b/webkit/glue/plugins/pepper_url_loader.h
index e613475..dd91708 100644
--- a/webkit/glue/plugins/pepper_url_loader.h
+++ b/webkit/glue/plugins/pepper_url_loader.h
@@ -8,21 +8,29 @@
#include <deque>
#include "base/scoped_ptr.h"
-#include "third_party/ppapi/c/pp_completion_callback.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebURLLoader.h"
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/dev/ppb_url_loader_trusted_dev.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h"
+#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_resource.h"
struct PPB_URLLoader_Dev;
struct PPB_URLLoaderTrusted_Dev;
+namespace WebKit {
+class WebFrame;
+class WebURL;
+}
+
namespace pepper {
class PluginInstance;
class URLRequestInfo;
class URLResponseInfo;
-class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
+class URLLoader : public Resource,
+ public WebKit::WebURLLoaderClient,
+ public PluginInstance::Observer {
public:
URLLoader(PluginInstance* instance, bool main_document_loader);
virtual ~URLLoader();
@@ -41,6 +49,10 @@ class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
// PPB_URLLoader implementation.
int32_t Open(URLRequestInfo* request, PP_CompletionCallback callback);
int32_t FollowRedirect(PP_CompletionCallback callback);
+ bool GetUploadProgress(int64_t* bytes_sent,
+ int64_t* total_bytes_to_be_sent);
+ bool GetDownloadProgress(int64_t* bytes_received,
+ int64_t* total_bytes_to_be_received);
int32_t ReadResponseBody(char* buffer, int32_t bytes_to_read,
PP_CompletionCallback callback);
int32_t FinishStreamingToFile(PP_CompletionCallback callback);
@@ -48,6 +60,7 @@ class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
// PPB_URLLoaderTrusted implementation.
void GrantUniversalAccess();
+ void SetStatusCallback(PP_URLLoaderTrusted_StatusCallback cb);
// WebKit::WebURLLoaderClient implementation.
virtual void willSendRequest(WebKit::WebURLLoader* loader,
@@ -68,25 +81,36 @@ class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
virtual void didFail(WebKit::WebURLLoader* loader,
const WebKit::WebURLError& error);
- URLResponseInfo* response_info() const { return response_info_; }
+ // PluginInstance::Observer implementation.
+ void InstanceDestroyed(PluginInstance* instance);
- // Progress counters.
- int64_t bytes_sent() const { return bytes_sent_; }
- int64_t total_bytes_to_be_sent() const { return total_bytes_to_be_sent_; }
- int64_t bytes_received() const { return bytes_received_; }
- int64_t total_bytes_to_be_received() const {
- return total_bytes_to_be_received_;
- }
+ URLResponseInfo* response_info() const { return response_info_; }
private:
void RunCallback(int32_t result);
size_t FillUserBuffer();
- scoped_refptr<PluginInstance> instance_;
+ // Converts a WebURLResponse to a URLResponseInfo and saves it.
+ void SaveResponse(const WebKit::WebURLResponse& response);
+
+ int32_t CanRequest(const WebKit::WebFrame* frame, const WebKit::WebURL& url);
+
+ // Calls the status_callback_ (if any) with the current upload and download
+ // progress. Call this function if you update any of these values to
+ // synchronize an out-of-process plugin's state.
+ void UpdateStatus();
+
+ // This will be NULL if the instance has been deleted but this URLLoader was
+ // somehow leaked. In general, you should not need to check this for NULL.
+ // However, if you see a NULL pointer crash, that means somebody is holding
+ // a reference to this object longer than the PluginInstance's lifetime.
+ PluginInstance* instance_;
+
// If true, then the plugin instance is a full-frame plugin and we're just
// wrapping the main document's loader (i.e. loader_ is null).
bool main_document_loader_;
scoped_ptr<WebKit::WebURLLoader> loader_;
+ scoped_refptr<URLRequestInfo> request_info_;
scoped_refptr<URLResponseInfo> response_info_;
PP_CompletionCallback pending_callback_;
std::deque<char> buffer_;
@@ -97,7 +121,13 @@ class URLLoader : public Resource, public WebKit::WebURLLoaderClient {
char* user_buffer_;
size_t user_buffer_size_;
int32_t done_status_;
+
+ bool record_download_progress_;
+ bool record_upload_progress_;
+
bool has_universal_access_;
+
+ PP_URLLoaderTrusted_StatusCallback status_callback_;
};
} // namespace pepper