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

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

Issue 10993031: Refactor the URLResponseInfo to use new design (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « webkit/glue/webkit_glue.gypi ('k') | webkit/plugins/ppapi/ppb_url_loader_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ 6 #define WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "ppapi/c/pp_completion_callback.h" 12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/trusted/ppb_url_loader_trusted.h" 13 #include "ppapi/c/trusted/ppb_url_loader_trusted.h"
14 #include "ppapi/shared_impl/resource.h" 14 #include "ppapi/shared_impl/resource.h"
15 #include "ppapi/shared_impl/scoped_pp_resource.h"
15 #include "ppapi/shared_impl/tracked_callback.h" 16 #include "ppapi/shared_impl/tracked_callback.h"
16 #include "ppapi/shared_impl/url_request_info_data.h" 17 #include "ppapi/shared_impl/url_request_info_data.h"
17 #include "ppapi/thunk/ppb_url_loader_api.h" 18 #include "ppapi/thunk/ppb_url_loader_api.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader Client.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader Client.h"
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
20 21
21 namespace WebKit { 22 namespace WebKit {
22 class WebURL; 23 class WebURL;
23 } 24 }
24 25
25 namespace webkit { 26 namespace webkit {
26 namespace ppapi { 27 namespace ppapi {
27 28
28 class PPB_URLResponseInfo_Impl;
29
30 class PPB_URLLoader_Impl : public ::ppapi::Resource, 29 class PPB_URLLoader_Impl : public ::ppapi::Resource,
31 public ::ppapi::thunk::PPB_URLLoader_API, 30 public ::ppapi::thunk::PPB_URLLoader_API,
32 public WebKit::WebURLLoaderClient { 31 public WebKit::WebURLLoaderClient {
33 public: 32 public:
34 PPB_URLLoader_Impl(PP_Instance instance, bool main_document_loader); 33 PPB_URLLoader_Impl(PP_Instance instance, bool main_document_loader);
35 virtual ~PPB_URLLoader_Impl(); 34 virtual ~PPB_URLLoader_Impl();
36 35
37 // Resource overrides. 36 // Resource overrides.
38 virtual ::ppapi::thunk::PPB_URLLoader_API* AsPPB_URLLoader_API() OVERRIDE; 37 virtual ::ppapi::thunk::PPB_URLLoader_API* AsPPB_URLLoader_API() OVERRIDE;
39 virtual void InstanceWasDeleted() OVERRIDE; 38 virtual void InstanceWasDeleted() OVERRIDE;
(...skipping 17 matching lines...) Expand all
57 virtual int32_t ReadResponseBody( 56 virtual int32_t ReadResponseBody(
58 void* buffer, 57 void* buffer,
59 int32_t bytes_to_read, 58 int32_t bytes_to_read,
60 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; 59 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
61 virtual int32_t FinishStreamingToFile( 60 virtual int32_t FinishStreamingToFile(
62 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; 61 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
63 virtual void Close() OVERRIDE; 62 virtual void Close() OVERRIDE;
64 virtual void GrantUniversalAccess() OVERRIDE; 63 virtual void GrantUniversalAccess() OVERRIDE;
65 virtual void SetStatusCallback( 64 virtual void SetStatusCallback(
66 PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE; 65 PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE;
66 virtual bool GetResponseInfoData(
67 ::ppapi::URLResponseInfoData* data) OVERRIDE;
67 68
68 // WebKit::WebURLLoaderClient implementation. 69 // WebKit::WebURLLoaderClient implementation.
69 virtual void willSendRequest(WebKit::WebURLLoader* loader, 70 virtual void willSendRequest(WebKit::WebURLLoader* loader,
70 WebKit::WebURLRequest& new_request, 71 WebKit::WebURLRequest& new_request,
71 const WebKit::WebURLResponse& redir_response); 72 const WebKit::WebURLResponse& redir_response);
72 virtual void didSendData(WebKit::WebURLLoader* loader, 73 virtual void didSendData(WebKit::WebURLLoader* loader,
73 unsigned long long bytes_sent, 74 unsigned long long bytes_sent,
74 unsigned long long total_bytes_to_be_sent); 75 unsigned long long total_bytes_to_be_sent);
75 virtual void didReceiveResponse(WebKit::WebURLLoader* loader, 76 virtual void didReceiveResponse(WebKit::WebURLLoader* loader,
76 const WebKit::WebURLResponse& response); 77 const WebKit::WebURLResponse& response);
77 virtual void didDownloadData(WebKit::WebURLLoader* loader, 78 virtual void didDownloadData(WebKit::WebURLLoader* loader,
78 int data_length); 79 int data_length);
79 80
80 virtual void didReceiveData(WebKit::WebURLLoader* loader, 81 virtual void didReceiveData(WebKit::WebURLLoader* loader,
81 const char* data, 82 const char* data,
82 int data_length, 83 int data_length,
83 int encoded_data_length); 84 int encoded_data_length);
84 virtual void didFinishLoading(WebKit::WebURLLoader* loader, 85 virtual void didFinishLoading(WebKit::WebURLLoader* loader,
85 double finish_time); 86 double finish_time);
86 virtual void didFail(WebKit::WebURLLoader* loader, 87 virtual void didFail(WebKit::WebURLLoader* loader,
87 const WebKit::WebURLError& error); 88 const WebKit::WebURLError& error);
88 89
89 PPB_URLResponseInfo_Impl* response_info() const { return response_info_; }
90
91 // Returns the number of bytes currently available for synchronous reading 90 // Returns the number of bytes currently available for synchronous reading
92 // in the loader. 91 // in the loader.
93 int32_t buffer_size() const { return buffer_.size(); } 92 int32_t buffer_size() const { return buffer_.size(); }
94 93
95 private: 94 private:
96 // Check that |callback| is valid (only non-blocking operation is supported) 95 // Check that |callback| is valid (only non-blocking operation is supported)
97 // and that no callback is already pending. Returns |PP_OK| if okay, else 96 // and that no callback is already pending. Returns |PP_OK| if okay, else
98 // |PP_ERROR_...| to be returned to the plugin. 97 // |PP_ERROR_...| to be returned to the plugin.
99 int32_t ValidateCallback(scoped_refptr< ::ppapi::TrackedCallback> callback); 98 int32_t ValidateCallback(scoped_refptr< ::ppapi::TrackedCallback> callback);
100 99
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 138
140 // The loader associated with this request. MAY BE NULL. 139 // The loader associated with this request. MAY BE NULL.
141 // 140 //
142 // This will be NULL if the load hasn't been opened yet, or if this is a main 141 // This will be NULL if the load hasn't been opened yet, or if this is a main
143 // document loader (when registered as a mime type). Therefore, you should 142 // document loader (when registered as a mime type). Therefore, you should
144 // always NULL check this value before using it. In the case of a main 143 // always NULL check this value before using it. In the case of a main
145 // document load, you would call the functions on the document to cancel the 144 // document load, you would call the functions on the document to cancel the
146 // load, etc. since there is no loader. 145 // load, etc. since there is no loader.
147 scoped_ptr<WebKit::WebURLLoader> loader_; 146 scoped_ptr<WebKit::WebURLLoader> loader_;
148 147
149 scoped_refptr<PPB_URLResponseInfo_Impl> response_info_;
150 scoped_refptr< ::ppapi::TrackedCallback> pending_callback_; 148 scoped_refptr< ::ppapi::TrackedCallback> pending_callback_;
151 std::deque<char> buffer_; 149 std::deque<char> buffer_;
152 int64_t bytes_sent_; 150 int64_t bytes_sent_;
153 int64_t total_bytes_to_be_sent_; 151 int64_t total_bytes_to_be_sent_;
154 int64_t bytes_received_; 152 int64_t bytes_received_;
155 int64_t total_bytes_to_be_received_; 153 int64_t total_bytes_to_be_received_;
156 char* user_buffer_; 154 char* user_buffer_;
157 size_t user_buffer_size_; 155 size_t user_buffer_size_;
158 int32_t done_status_; 156 int32_t done_status_;
159 bool is_streaming_to_file_; 157 bool is_streaming_to_file_;
160 bool is_asynchronous_load_suspended_; 158 bool is_asynchronous_load_suspended_;
161 159
162 bool has_universal_access_; 160 bool has_universal_access_;
163 161
164 PP_URLLoaderTrusted_StatusCallback status_callback_; 162 PP_URLLoaderTrusted_StatusCallback status_callback_;
165 163
164 // When the response info is received, this stores the data. The
165 // ScopedResource maintains the reference to the file ref (if any) in the
166 // data object so we don't forget to dereference it.
167 scoped_ptr< ::ppapi::URLResponseInfoData > response_info_;
168 ::ppapi::ScopedPPResource response_info_file_ref_;
169
166 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl); 170 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl);
167 }; 171 };
168 172
169 } // namespace ppapi 173 } // namespace ppapi
170 } // namespace webkit 174 } // namespace webkit
171 175
172 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ 176 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.gypi ('k') | webkit/plugins/ppapi/ppb_url_loader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698