Chromium Code Reviews| 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, |url_| is the full URL including the |
| 150 // scheme, host and full path. | |
|
dmichael (off chromium)
2014/03/05 16:11:35
This comment needs to be updated with the new meth
| |
| 151 const nacl::string& full_url() const { return full_url_; } | |
| 154 | 152 |
| 155 // Returns the PP_Resource of the active URL loader, or kInvalidResource. | 153 // Returns the PP_Resource of the active URL loader, or kInvalidResource. |
| 156 PP_Resource url_loader() const { return url_loader_.pp_resource(); } | 154 PP_Resource url_loader() const { return url_loader_.pp_resource(); } |
| 157 | 155 |
| 158 // GetDownloadProgress() returns the current download progress, which is | 156 // GetDownloadProgress() returns the current download progress, which is |
| 159 // meaningful after Open() has been called. Progress only refers to the | 157 // meaningful after Open() has been called. Progress only refers to the |
| 160 // response body and does not include the headers. | 158 // response body and does not include the headers. |
| 161 // | 159 // |
| 162 // This data is only available if the |record_progress| true in the | 160 // This data is only available if the |record_progress| true in the |
| 163 // Open() call. If progress is being recorded, then |bytes_received| | 161 // 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 | 199 // The public Open*() functions start step 1), and the public FinishStreaming |
| 202 // function proceeds to step 2) and 3). | 200 // function proceeds to step 2) and 3). |
| 203 bool InitialResponseIsValid(); | 201 bool InitialResponseIsValid(); |
| 204 void URLLoadStartNotify(int32_t pp_error); | 202 void URLLoadStartNotify(int32_t pp_error); |
| 205 void URLLoadFinishNotify(int32_t pp_error); | 203 void URLLoadFinishNotify(int32_t pp_error); |
| 206 void URLReadBodyNotify(int32_t pp_error); | 204 void URLReadBodyNotify(int32_t pp_error); |
| 207 void StreamFinishNotify(int32_t pp_error); | 205 void StreamFinishNotify(int32_t pp_error); |
| 208 void GotFileHandleNotify(int32_t pp_error, PP_FileHandle handle); | 206 void GotFileHandleNotify(int32_t pp_error, PP_FileHandle handle); |
| 209 | 207 |
| 210 Plugin* instance_; | 208 Plugin* instance_; |
| 211 nacl::string url_to_open_; | |
| 212 nacl::string url_; | 209 nacl::string url_; |
| 210 nacl::string full_url_; | |
| 211 | |
| 213 nacl::string extra_request_headers_; | 212 nacl::string extra_request_headers_; |
| 214 pp::URLResponseInfo url_response_; | 213 pp::URLResponseInfo url_response_; |
| 215 pp::CompletionCallback file_open_notify_callback_; | 214 pp::CompletionCallback file_open_notify_callback_; |
| 216 pp::CompletionCallback stream_finish_callback_; | 215 pp::CompletionCallback stream_finish_callback_; |
| 217 pp::FileIO file_reader_; | 216 pp::FileIO file_reader_; |
| 218 const PPB_FileIO_Private* file_io_private_interface_; | 217 const PPB_FileIO_Private* file_io_private_interface_; |
| 219 const PPB_URLLoaderTrusted* url_loader_trusted_interface_; | 218 const PPB_URLLoaderTrusted* url_loader_trusted_interface_; |
| 220 pp::URLLoader url_loader_; | 219 pp::URLLoader url_loader_; |
| 221 pp::CompletionCallbackFactory<FileDownloader> callback_factory_; | 220 pp::CompletionCallbackFactory<FileDownloader> callback_factory_; |
| 222 int64_t open_time_; | 221 int64_t open_time_; |
| 223 int32_t status_code_; | 222 int32_t status_code_; |
| 224 DownloadMode mode_; | 223 DownloadMode mode_; |
| 225 bool open_and_stream_; | 224 bool open_and_stream_; |
| 226 static const uint32_t kTempBufferSize = 2048; | 225 static const uint32_t kTempBufferSize = 2048; |
| 227 std::vector<char> temp_buffer_; | 226 std::vector<char> temp_buffer_; |
| 228 std::deque<char> buffer_; | 227 std::deque<char> buffer_; |
| 229 UrlSchemeType url_scheme_; | 228 UrlSchemeType url_scheme_; |
| 230 StreamCallbackSource* data_stream_callback_source_; | 229 StreamCallbackSource* data_stream_callback_source_; |
| 231 NaClFileInfoAutoCloser file_info_; | 230 NaClFileInfoAutoCloser file_info_; |
| 232 }; | 231 }; |
| 233 } // namespace plugin; | 232 } // namespace plugin; |
| 234 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ | 233 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ |
| OLD | NEW |