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

Side by Side Diff: content/renderer/pepper/pepper_url_loader_host.h

Issue 11416363: Implementation of URLLoader using PluginResource/ResourceHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_
7
8 #include <vector>
9
10 #include "content/common/content_export.h"
11 #include "ppapi/host/resource_host.h"
12 #include "ppapi/proxy/resource_message_params.h"
13 #include "ppapi/shared_impl/url_request_info_data.h"
14 #include "ppapi/shared_impl/url_response_info_data.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader Client.h"
16
17 namespace WebKit {
18 class WebFrame;
19 class WebURLLoader;
20 }
21
22 namespace content {
23
24 class RendererPpapiHost;
25
26 class PepperURLLoaderHost
27 : public ppapi::host::ResourceHost,
28 public WebKit::WebURLLoaderClient {
29 public:
30 // If main_document_loader is true, PP_Resource must be 0 since it will be
31 // pending until the plugin resource attaches to it.
32 PepperURLLoaderHost(RendererPpapiHost* host,
33 bool main_document_loader,
34 PP_Instance instance,
35 PP_Resource resource);
36 virtual ~PepperURLLoaderHost();
37
38 // ResourceHost implementation.
39 virtual int32_t OnResourceMessageReceived(
40 const IPC::Message& msg,
41 ppapi::host::HostMessageContext* context) OVERRIDE;
42
43 // WebKit::WebURLLoaderClient implementation.
44 virtual void willSendRequest(WebKit::WebURLLoader* loader,
45 WebKit::WebURLRequest& new_request,
46 const WebKit::WebURLResponse& redir_response);
47 virtual void didSendData(WebKit::WebURLLoader* loader,
48 unsigned long long bytes_sent,
49 unsigned long long total_bytes_to_be_sent);
50 virtual void didReceiveResponse(WebKit::WebURLLoader* loader,
51 const WebKit::WebURLResponse& response);
52 virtual void didDownloadData(WebKit::WebURLLoader* loader,
53 int data_length);
54 virtual void didReceiveData(WebKit::WebURLLoader* loader,
55 const char* data,
56 int data_length,
57 int encoded_data_length);
58 virtual void didFinishLoading(WebKit::WebURLLoader* loader,
59 double finish_time);
60 virtual void didFail(WebKit::WebURLLoader* loader,
61 const WebKit::WebURLError& error);
62
63 private:
64 // ResourceHost protected overrides.
65 virtual void DidConnectPendingHostToResource() OVERRIDE;
66
67 // IPC messages
68 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context,
69 const ppapi::URLRequestInfoData& request_data);
70 int32_t InternalOnHostMsgOpen(ppapi::host::HostMessageContext* context,
71 const ppapi::URLRequestInfoData& request_data);
72 int32_t OnHostMsgSetDeferLoading(ppapi::host::HostMessageContext* context,
73 bool defers_loading);
74 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context);
75 int32_t OnHostMsgGrantUniversalAccess(
76 ppapi::host::HostMessageContext* context);
77
78 // Sends or queues an unsolicited message to the plugin resource. This
79 // handles the case where we have created a pending host resource and the
80 // plugin has not connected to us yet. Such messages will be queued until the
81 // plugin resource connects.
82 //
83 // Takes ownership of the given pointer.
84 void SendUpdateToPlugin(IPC::Message* msg);
85
86 void Close();
87
88 // Returns the frame for the current request.
89 WebKit::WebFrame* GetFrame();
90
91 // Calls SetDefersLoading on the current load. This encapsulates the logic
92 // differences between document loads and regular ones.
93 void SetDefersLoading(bool defers_loading);
94
95 // Converts a WebURLResponse to a URLResponseInfo and saves it.
96 void SaveResponse(const WebKit::WebURLResponse& response);
97
98 // Sends the UpdateProgress message (if necessary) to the plugin.
99 void UpdateProgress();
100
101 // Non-owning pointer.
102 RendererPpapiHost* renderer_ppapi_host_;
103
104 // If true, then the plugin instance is a full-frame plugin and we're just
105 // wrapping the main document's loader (i.e. loader_ is null).
106 bool main_document_loader_;
107
108 // The data that generated the request.
109 ppapi::URLRequestInfoData request_data_;
110
111 // Set to true when this loader can ignore same originl policy.
112 bool has_universal_access_;
113
114 // The loader associated with this request. MAY BE NULL.
115 //
116 // This will be NULL if the load hasn't been opened yet, or if this is a main
117 // document loader (when registered as a mime type). Therefore, you should
118 // always NULL check this value before using it. In the case of a main
119 // document load, you would call the functions on the document to cancel the
120 // load, etc. since there is no loader.
121 scoped_ptr<WebKit::WebURLLoader> loader_;
122
123 int64_t bytes_sent_;
124 int64_t total_bytes_to_be_sent_;
125 int64_t bytes_received_;
126 int64_t total_bytes_to_be_received_;
127
128 // Messages sent while the resource host is pending. These will be forwarded
129 // to the plugin when the plugin side connects. The pointers are owned by
130 // this object and must be deleted.
131 std::vector<IPC::Message*> pending_replies_;
132
133 DISALLOW_COPY_AND_ASSIGN(PepperURLLoaderHost);
134 };
135
136 } // namespace content
137
138 #endif // CONTENT_RENDERER_PEPPER_PEPPER_URL_LOADER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698