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

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

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 unified diff | Download patch | Annotate | Revision Log
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 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ 6 #define WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
11 #include "ppapi/c/pp_completion_callback.h" 11 #include "ppapi/c/pp_completion_callback.h"
12 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" 12 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
13 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h"
14 #include "webkit/glue/plugins/pepper_plugin_instance.h" 14 #include "webkit/plugins/ppapi/plugin_instance.h"
15 #include "webkit/glue/plugins/pepper_resource.h" 15 #include "webkit/plugins/ppapi/resource.h"
16 16
17 struct PPB_URLLoader; 17 struct PPB_URLLoader;
18 struct PPB_URLLoaderTrusted; 18 struct PPB_URLLoaderTrusted;
19 19
20 namespace WebKit { 20 namespace WebKit {
21 class WebFrame; 21 class WebFrame;
22 class WebURL; 22 class WebURL;
23 } 23 }
24 24
25 namespace pepper { 25 namespace webkit {
26 namespace plugins {
27 namespace ppapi {
26 28
27 class PluginInstance; 29 class PluginInstance;
28 class URLRequestInfo; 30 class PPB_URLRequestInfo_Impl;
29 class URLResponseInfo; 31 class PPB_URLResponseInfo_Impl;
30 32
31 class URLLoader : public Resource, 33 class PPB_URLLoader_Impl : public Resource,
32 public WebKit::WebURLLoaderClient, 34 public WebKit::WebURLLoaderClient,
33 public PluginInstance::Observer { 35 public PluginInstance::Observer {
34 public: 36 public:
35 URLLoader(PluginInstance* instance, bool main_document_loader); 37 PPB_URLLoader_Impl(PluginInstance* instance, bool main_document_loader);
36 virtual ~URLLoader(); 38 virtual ~PPB_URLLoader_Impl();
37 39
38 // Returns a pointer to the interface implementing PPB_URLLoader that is 40 // Returns a pointer to the interface implementing PPB_URLLoader that is
39 // exposed to the plugin. 41 // exposed to the plugin.
40 static const PPB_URLLoader* GetInterface(); 42 static const PPB_URLLoader* GetInterface();
41 43
42 // Returns a pointer to the interface implementing PPB_URLLoaderTrusted that 44 // Returns a pointer to the interface implementing PPB_URLLoaderTrusted that
43 // is exposed to the plugin. 45 // is exposed to the plugin.
44 static const PPB_URLLoaderTrusted* GetTrustedInterface(); 46 static const PPB_URLLoaderTrusted* GetTrustedInterface();
45 47
46 // Resource overrides. 48 // Resource overrides.
47 virtual URLLoader* AsURLLoader(); 49 virtual PPB_URLLoader_Impl* AsURLLoader();
48 50
49 // PPB_URLLoader implementation. 51 // PPB_URLLoader implementation.
50 int32_t Open(URLRequestInfo* request, PP_CompletionCallback callback); 52 int32_t Open(PPB_URLRequestInfo_Impl* request,
53 PP_CompletionCallback callback);
51 int32_t FollowRedirect(PP_CompletionCallback callback); 54 int32_t FollowRedirect(PP_CompletionCallback callback);
52 bool GetUploadProgress(int64_t* bytes_sent, 55 bool GetUploadProgress(int64_t* bytes_sent,
53 int64_t* total_bytes_to_be_sent); 56 int64_t* total_bytes_to_be_sent);
54 bool GetDownloadProgress(int64_t* bytes_received, 57 bool GetDownloadProgress(int64_t* bytes_received,
55 int64_t* total_bytes_to_be_received); 58 int64_t* total_bytes_to_be_received);
56 int32_t ReadResponseBody(char* buffer, int32_t bytes_to_read, 59 int32_t ReadResponseBody(char* buffer, int32_t bytes_to_read,
57 PP_CompletionCallback callback); 60 PP_CompletionCallback callback);
58 int32_t FinishStreamingToFile(PP_CompletionCallback callback); 61 int32_t FinishStreamingToFile(PP_CompletionCallback callback);
59 void Close(); 62 void Close();
60 63
(...skipping 16 matching lines...) Expand all
77 const char* data, 80 const char* data,
78 int data_length); 81 int data_length);
79 virtual void didFinishLoading(WebKit::WebURLLoader* loader, 82 virtual void didFinishLoading(WebKit::WebURLLoader* loader,
80 double finish_time); 83 double finish_time);
81 virtual void didFail(WebKit::WebURLLoader* loader, 84 virtual void didFail(WebKit::WebURLLoader* loader,
82 const WebKit::WebURLError& error); 85 const WebKit::WebURLError& error);
83 86
84 // PluginInstance::Observer implementation. 87 // PluginInstance::Observer implementation.
85 virtual void InstanceDestroyed(PluginInstance* instance); 88 virtual void InstanceDestroyed(PluginInstance* instance);
86 89
87 URLResponseInfo* response_info() const { return response_info_; } 90 PPB_URLResponseInfo_Impl* response_info() const { return response_info_; }
88 91
89 private: 92 private:
90 void RunCallback(int32_t result); 93 void RunCallback(int32_t result);
91 size_t FillUserBuffer(); 94 size_t FillUserBuffer();
92 95
93 // Converts a WebURLResponse to a URLResponseInfo and saves it. 96 // Converts a WebURLResponse to a URLResponseInfo and saves it.
94 void SaveResponse(const WebKit::WebURLResponse& response); 97 void SaveResponse(const WebKit::WebURLResponse& response);
95 98
96 int32_t CanRequest(const WebKit::WebFrame* frame, const WebKit::WebURL& url); 99 int32_t CanRequest(const WebKit::WebFrame* frame, const WebKit::WebURL& url);
97 100
98 // Calls the status_callback_ (if any) with the current upload and download 101 // Calls the status_callback_ (if any) with the current upload and download
99 // progress. Call this function if you update any of these values to 102 // progress. Call this function if you update any of these values to
100 // synchronize an out-of-process plugin's state. 103 // synchronize an out-of-process plugin's state.
101 void UpdateStatus(); 104 void UpdateStatus();
102 105
103 // Returns true if the plugin has requested we record download or upload 106 // Returns true if the plugin has requested we record download or upload
104 // progress. When false, we don't need to update the counters. We go out of 107 // progress. When false, we don't need to update the counters. We go out of
105 // our way not to allow access to this information unless it's requested, 108 // our way not to allow access to this information unless it's requested,
106 // even when it would be easier just to return it and not check, so that 109 // even when it would be easier just to return it and not check, so that
107 // plugins don't depend on access without setting the flag. 110 // plugins don't depend on access without setting the flag.
108 bool RecordDownloadProgress() const; 111 bool RecordDownloadProgress() const;
109 bool RecordUploadProgress() const; 112 bool RecordUploadProgress() const;
110 113
111 // This will be NULL if the instance has been deleted but this URLLoader was 114 // This will be NULL if the instance has been deleted but this PPB_URLLoader_I mpl was
112 // somehow leaked. In general, you should not need to check this for NULL. 115 // somehow leaked. In general, you should not need to check this for NULL.
113 // However, if you see a NULL pointer crash, that means somebody is holding 116 // However, if you see a NULL pointer crash, that means somebody is holding
114 // a reference to this object longer than the PluginInstance's lifetime. 117 // a reference to this object longer than the PluginInstance's lifetime.
115 PluginInstance* instance_; 118 PluginInstance* instance_;
116 119
117 // If true, then the plugin instance is a full-frame plugin and we're just 120 // If true, then the plugin instance is a full-frame plugin and we're just
118 // wrapping the main document's loader (i.e. loader_ is null). 121 // wrapping the main document's loader (i.e. loader_ is null).
119 bool main_document_loader_; 122 bool main_document_loader_;
120 scoped_ptr<WebKit::WebURLLoader> loader_; 123 scoped_ptr<WebKit::WebURLLoader> loader_;
121 scoped_refptr<URLRequestInfo> request_info_; 124 scoped_refptr<PPB_URLRequestInfo_Impl> request_info_;
122 scoped_refptr<URLResponseInfo> response_info_; 125 scoped_refptr<PPB_URLResponseInfo_Impl> response_info_;
123 PP_CompletionCallback pending_callback_; 126 PP_CompletionCallback pending_callback_;
124 std::deque<char> buffer_; 127 std::deque<char> buffer_;
125 int64_t bytes_sent_; 128 int64_t bytes_sent_;
126 int64_t total_bytes_to_be_sent_; 129 int64_t total_bytes_to_be_sent_;
127 int64_t bytes_received_; 130 int64_t bytes_received_;
128 int64_t total_bytes_to_be_received_; 131 int64_t total_bytes_to_be_received_;
129 char* user_buffer_; 132 char* user_buffer_;
130 size_t user_buffer_size_; 133 size_t user_buffer_size_;
131 int32_t done_status_; 134 int32_t done_status_;
132 135
133 bool has_universal_access_; 136 bool has_universal_access_;
134 137
135 PP_URLLoaderTrusted_StatusCallback status_callback_; 138 PP_URLLoaderTrusted_StatusCallback status_callback_;
139
140 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl);
136 }; 141 };
137 142
138 } // namespace pepper 143 } // namespace ppapi
144 } // namespace plugins
145 } // namespace webkit
139 146
140 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_ 147 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698