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

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

Issue 11417145: Provide a safer URLLoader ReadResponseBody API (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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
« no previous file with comments | « ppapi/thunk/ppb_url_loader_thunk.cc ('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"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, 50 virtual PP_Bool GetUploadProgress(int64_t* bytes_sent,
51 int64_t* total_bytes_to_be_sent) OVERRIDE; 51 int64_t* total_bytes_to_be_sent) OVERRIDE;
52 virtual PP_Bool GetDownloadProgress( 52 virtual PP_Bool GetDownloadProgress(
53 int64_t* bytes_received, 53 int64_t* bytes_received,
54 int64_t* total_bytes_to_be_received) OVERRIDE; 54 int64_t* total_bytes_to_be_received) OVERRIDE;
55 virtual PP_Resource GetResponseInfo() OVERRIDE; 55 virtual PP_Resource GetResponseInfo() OVERRIDE;
56 virtual int32_t ReadResponseBody( 56 virtual int32_t ReadResponseBody(
57 void* buffer, 57 void* buffer,
58 int32_t bytes_to_read, 58 int32_t bytes_to_read,
59 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; 59 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
60 virtual int32_t ReadResponseBodyToArray(
61 int32_t max_read_length,
62 PP_ArrayOutput* array_output,
63 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
60 virtual int32_t FinishStreamingToFile( 64 virtual int32_t FinishStreamingToFile(
61 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; 65 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE;
62 virtual void Close() OVERRIDE; 66 virtual void Close() OVERRIDE;
63 virtual void GrantUniversalAccess() OVERRIDE; 67 virtual void GrantUniversalAccess() OVERRIDE;
64 virtual void SetStatusCallback( 68 virtual void SetStatusCallback(
65 PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE; 69 PP_URLLoaderTrusted_StatusCallback cb) OVERRIDE;
66 virtual bool GetResponseInfoData( 70 virtual bool GetResponseInfoData(
67 ::ppapi::URLResponseInfoData* data) OVERRIDE; 71 ::ppapi::URLResponseInfoData* data) OVERRIDE;
68 72
73 int32_t ReadResponseBodyInternal(
74 int32_t max_read_length,
75 const PP_ArrayOutput& array_output,
76 scoped_refptr< ::ppapi::TrackedCallback> callback);
77
69 // WebKit::WebURLLoaderClient implementation. 78 // WebKit::WebURLLoaderClient implementation.
70 virtual void willSendRequest(WebKit::WebURLLoader* loader, 79 virtual void willSendRequest(WebKit::WebURLLoader* loader,
71 WebKit::WebURLRequest& new_request, 80 WebKit::WebURLRequest& new_request,
72 const WebKit::WebURLResponse& redir_response); 81 const WebKit::WebURLResponse& redir_response);
73 virtual void didSendData(WebKit::WebURLLoader* loader, 82 virtual void didSendData(WebKit::WebURLLoader* loader,
74 unsigned long long bytes_sent, 83 unsigned long long bytes_sent,
75 unsigned long long total_bytes_to_be_sent); 84 unsigned long long total_bytes_to_be_sent);
76 virtual void didReceiveResponse(WebKit::WebURLLoader* loader, 85 virtual void didReceiveResponse(WebKit::WebURLLoader* loader,
77 const WebKit::WebURLResponse& response); 86 const WebKit::WebURLResponse& response);
78 virtual void didDownloadData(WebKit::WebURLLoader* loader, 87 virtual void didDownloadData(WebKit::WebURLLoader* loader,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // document load, you would call the functions on the document to cancel the 153 // document load, you would call the functions on the document to cancel the
145 // load, etc. since there is no loader. 154 // load, etc. since there is no loader.
146 scoped_ptr<WebKit::WebURLLoader> loader_; 155 scoped_ptr<WebKit::WebURLLoader> loader_;
147 156
148 scoped_refptr< ::ppapi::TrackedCallback> pending_callback_; 157 scoped_refptr< ::ppapi::TrackedCallback> pending_callback_;
149 std::deque<char> buffer_; 158 std::deque<char> buffer_;
150 int64_t bytes_sent_; 159 int64_t bytes_sent_;
151 int64_t total_bytes_to_be_sent_; 160 int64_t total_bytes_to_be_sent_;
152 int64_t bytes_received_; 161 int64_t bytes_received_;
153 int64_t total_bytes_to_be_received_; 162 int64_t total_bytes_to_be_received_;
154 char* user_buffer_; 163 scoped_ptr<PP_ArrayOutput> user_buffer_;
155 size_t user_buffer_size_; 164 size_t user_buffer_size_;
156 int32_t done_status_; 165 int32_t done_status_;
157 bool is_streaming_to_file_; 166 bool is_streaming_to_file_;
158 bool is_asynchronous_load_suspended_; 167 bool is_asynchronous_load_suspended_;
159 168
160 bool has_universal_access_; 169 bool has_universal_access_;
161 170
162 PP_URLLoaderTrusted_StatusCallback status_callback_; 171 PP_URLLoaderTrusted_StatusCallback status_callback_;
163 172
164 // When the response info is received, this stores the data. The 173 // When the response info is received, this stores the data. The
165 // ScopedResource maintains the reference to the file ref (if any) in the 174 // ScopedResource maintains the reference to the file ref (if any) in the
166 // data object so we don't forget to dereference it. 175 // data object so we don't forget to dereference it.
167 scoped_ptr< ::ppapi::URLResponseInfoData > response_info_; 176 scoped_ptr< ::ppapi::URLResponseInfoData > response_info_;
168 ::ppapi::ScopedPPResource response_info_file_ref_; 177 ::ppapi::ScopedPPResource response_info_file_ref_;
169 178
170 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl); 179 DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl);
171 }; 180 };
172 181
173 } // namespace ppapi 182 } // namespace ppapi
174 } // namespace webkit 183 } // namespace webkit
175 184
176 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_ 185 #endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_url_loader_thunk.cc ('k') | webkit/plugins/ppapi/ppb_url_loader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698