OLD | NEW |
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 NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ | 5 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ |
6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ | 6 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "native_client/src/include/nacl_macros.h" | 10 #include "native_client/src/include/nacl_macros.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // Return a structure describing the file opened, including a file desc. | 135 // Return a structure describing the file opened, including a file desc. |
136 // If downloading and opening succeeded, this returns a valid read-only | 136 // If downloading and opening succeeded, this returns a valid read-only |
137 // POSIX file descriptor. On failure, the return value is an invalid | 137 // POSIX file descriptor. On failure, the return value is an invalid |
138 // descriptor. The file descriptor is owned by this instance, so the | 138 // descriptor. The file descriptor is owned by this instance, so the |
139 // delegate does not have to close it. | 139 // delegate does not have to close it. |
140 struct NaClFileInfo GetFileInfo(); | 140 struct NaClFileInfo GetFileInfo(); |
141 | 141 |
142 // Returns the time delta between the call to Open() and this function. | 142 // Returns the time delta between the call to Open() and this function. |
143 int64_t TimeSinceOpenMilliseconds() const; | 143 int64_t TimeSinceOpenMilliseconds() const; |
144 | 144 |
145 // The value of |url_| changes over the life of this instance. When the file | 145 // Returns the url passed to Open(). |
146 // is first opened, |url_| is a copy of the URL used to open the file, which | |
147 // can be a relative URL. Once the GET request has finished, and the contents | |
148 // of the file represented by |url_| are available, |url_| is the full URL | |
149 // including the scheme, host and full path. | |
150 const nacl::string& url() const { return url_; } | 146 const nacl::string& url() const { return url_; } |
151 | 147 |
152 // Returns the url passed to Open(). | 148 // Once the GET request has finished, and the contents of the file |
153 const nacl::string& url_to_open() const { return url_to_open_; } | 149 // represented by |url_| are available, |full_url_| is the full URL including |
| 150 // the scheme, host and full path. |
| 151 // Returns an empty string before the GET request has finished. |
| 152 const nacl::string& full_url() const { return full_url_; } |
154 | 153 |
155 // Returns the PP_Resource of the active URL loader, or kInvalidResource. | 154 // Returns the PP_Resource of the active URL loader, or kInvalidResource. |
156 PP_Resource url_loader() const { return url_loader_.pp_resource(); } | 155 PP_Resource url_loader() const { return url_loader_.pp_resource(); } |
157 | 156 |
158 // GetDownloadProgress() returns the current download progress, which is | 157 // GetDownloadProgress() returns the current download progress, which is |
159 // meaningful after Open() has been called. Progress only refers to the | 158 // meaningful after Open() has been called. Progress only refers to the |
160 // response body and does not include the headers. | 159 // response body and does not include the headers. |
161 // | 160 // |
162 // This data is only available if the |record_progress| true in the | 161 // This data is only available if the |record_progress| true in the |
163 // Open() call. If progress is being recorded, then |bytes_received| | 162 // Open() call. If progress is being recorded, then |bytes_received| |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // The public Open*() functions start step 1), and the public FinishStreaming | 200 // The public Open*() functions start step 1), and the public FinishStreaming |
202 // function proceeds to step 2) and 3). | 201 // function proceeds to step 2) and 3). |
203 bool InitialResponseIsValid(); | 202 bool InitialResponseIsValid(); |
204 void URLLoadStartNotify(int32_t pp_error); | 203 void URLLoadStartNotify(int32_t pp_error); |
205 void URLLoadFinishNotify(int32_t pp_error); | 204 void URLLoadFinishNotify(int32_t pp_error); |
206 void URLReadBodyNotify(int32_t pp_error); | 205 void URLReadBodyNotify(int32_t pp_error); |
207 void StreamFinishNotify(int32_t pp_error); | 206 void StreamFinishNotify(int32_t pp_error); |
208 void GotFileHandleNotify(int32_t pp_error, PP_FileHandle handle); | 207 void GotFileHandleNotify(int32_t pp_error, PP_FileHandle handle); |
209 | 208 |
210 Plugin* instance_; | 209 Plugin* instance_; |
211 nacl::string url_to_open_; | |
212 nacl::string url_; | 210 nacl::string url_; |
| 211 nacl::string full_url_; |
| 212 |
213 nacl::string extra_request_headers_; | 213 nacl::string extra_request_headers_; |
214 pp::URLResponseInfo url_response_; | 214 pp::URLResponseInfo url_response_; |
215 pp::CompletionCallback file_open_notify_callback_; | 215 pp::CompletionCallback file_open_notify_callback_; |
216 pp::CompletionCallback stream_finish_callback_; | 216 pp::CompletionCallback stream_finish_callback_; |
217 pp::FileIO file_reader_; | 217 pp::FileIO file_reader_; |
218 const PPB_FileIO_Private* file_io_private_interface_; | 218 const PPB_FileIO_Private* file_io_private_interface_; |
219 const PPB_URLLoaderTrusted* url_loader_trusted_interface_; | 219 const PPB_URLLoaderTrusted* url_loader_trusted_interface_; |
220 pp::URLLoader url_loader_; | 220 pp::URLLoader url_loader_; |
221 pp::CompletionCallbackFactory<FileDownloader> callback_factory_; | 221 pp::CompletionCallbackFactory<FileDownloader> callback_factory_; |
222 int64_t open_time_; | 222 int64_t open_time_; |
223 int32_t status_code_; | 223 int32_t status_code_; |
224 DownloadMode mode_; | 224 DownloadMode mode_; |
225 bool open_and_stream_; | 225 bool open_and_stream_; |
226 static const uint32_t kTempBufferSize = 2048; | 226 static const uint32_t kTempBufferSize = 2048; |
227 std::vector<char> temp_buffer_; | 227 std::vector<char> temp_buffer_; |
228 std::deque<char> buffer_; | 228 std::deque<char> buffer_; |
229 UrlSchemeType url_scheme_; | 229 UrlSchemeType url_scheme_; |
230 StreamCallbackSource* data_stream_callback_source_; | 230 StreamCallbackSource* data_stream_callback_source_; |
231 NaClFileInfoAutoCloser file_info_; | 231 NaClFileInfoAutoCloser file_info_; |
232 }; | 232 }; |
233 } // namespace plugin; | 233 } // namespace plugin; |
234 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ | 234 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ |
OLD | NEW |