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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 const pp::CompletionCallback& callback, | 111 const pp::CompletionCallback& callback, |
112 StreamCallbackSource* stream_callback_source); | 112 StreamCallbackSource* stream_callback_source); |
113 | 113 |
114 // Finish streaming the response body for a URL request started by either | 114 // Finish streaming the response body for a URL request started by either |
115 // Open() or OpenStream(). If DownloadMode is DOWNLOAD_TO_FILE, | 115 // Open() or OpenStream(). If DownloadMode is DOWNLOAD_TO_FILE, |
116 // then the response body is streamed to a file, the file is opened and | 116 // then the response body is streamed to a file, the file is opened and |
117 // a file descriptor is made available. Runs the given |callback| when | 117 // a file descriptor is made available. Runs the given |callback| when |
118 // streaming is done. | 118 // streaming is done. |
119 void FinishStreaming(const pp::CompletionCallback& callback); | 119 void FinishStreaming(const pp::CompletionCallback& callback); |
120 | 120 |
121 // Bypasses downloading and takes a handle to the open file. To get the fd, | |
122 // call GetFileInfo(). | |
123 void OpenFast(const nacl::string& url, PP_FileHandle file_handle, | |
124 uint64_t file_token_lo, uint64_t file_token_hi); | |
125 | |
126 // Return a structure describing the file opened, including a file desc. | |
127 // If downloading and opening succeeded, this returns a valid read-only | |
128 // POSIX file descriptor. On failure, the return value is an invalid | |
129 // descriptor. The file descriptor is owned by this instance, so the | |
130 // delegate does not have to close it. | |
131 struct NaClFileInfo GetFileInfo(); | |
132 | |
133 // Returns the url passed to Open(). | 121 // Returns the url passed to Open(). |
134 const nacl::string& url() const { return url_; } | 122 const nacl::string& url() const { return url_; } |
135 | 123 |
136 // Once the GET request has finished, and the contents of the file | 124 // Once the GET request has finished, and the contents of the file |
137 // represented by |url_| are available, |full_url_| is the full URL including | 125 // represented by |url_| are available, |full_url_| is the full URL including |
138 // the scheme, host and full path. | 126 // the scheme, host and full path. |
139 // Returns an empty string before the GET request has finished. | 127 // Returns an empty string before the GET request has finished. |
140 const nacl::string& full_url() const { return full_url_; } | 128 const nacl::string& full_url() const { return full_url_; } |
141 | 129 |
142 // Returns the PP_Resource of the active URL loader, or kInvalidResource. | 130 // Returns the PP_Resource of the active URL loader, or kInvalidResource. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 pp::CompletionCallbackFactory<FileDownloader> callback_factory_; | 187 pp::CompletionCallbackFactory<FileDownloader> callback_factory_; |
200 int32_t status_code_; | 188 int32_t status_code_; |
201 DownloadMode mode_; | 189 DownloadMode mode_; |
202 static const uint32_t kTempBufferSize = 16384; | 190 static const uint32_t kTempBufferSize = 16384; |
203 std::vector<char> temp_buffer_; | 191 std::vector<char> temp_buffer_; |
204 StreamCallbackSource* data_stream_callback_source_; | 192 StreamCallbackSource* data_stream_callback_source_; |
205 NaClFileInfoAutoCloser file_info_; | 193 NaClFileInfoAutoCloser file_info_; |
206 }; | 194 }; |
207 } // namespace plugin; | 195 } // namespace plugin; |
208 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ | 196 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ |
OLD | NEW |