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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class FileDownloader { | 42 class FileDownloader { |
43 public: | 43 public: |
44 // Ctor initializes |instance_| to NULL, be sure to call Initialize() before | 44 // Ctor initializes |instance_| to NULL, be sure to call Initialize() before |
45 // calling Open(), or Open() will fail. | 45 // calling Open(), or Open() will fail. |
46 FileDownloader() | 46 FileDownloader() |
47 : instance_(NULL), | 47 : instance_(NULL), |
48 file_open_notify_callback_(pp::BlockUntilComplete()), | 48 file_open_notify_callback_(pp::BlockUntilComplete()), |
49 file_io_trusted_interface_(NULL), | 49 file_io_trusted_interface_(NULL), |
50 url_loader_trusted_interface_(NULL), | 50 url_loader_trusted_interface_(NULL), |
51 open_time_(-1), | 51 open_time_(-1), |
| 52 mode_(DOWNLOAD_TO_FILE), |
| 53 url_scheme_(SCHEME_OTHER), |
52 data_stream_callback_source_(NULL) {} | 54 data_stream_callback_source_(NULL) {} |
53 ~FileDownloader() {} | 55 ~FileDownloader() {} |
54 | 56 |
55 // Initialize() can only be called once during the lifetime of this instance. | 57 // Initialize() can only be called once during the lifetime of this instance. |
56 void Initialize(Plugin* instance); | 58 void Initialize(Plugin* instance); |
57 | 59 |
58 // Issues a GET on |url| downloading the response into a file. The file is | 60 // Issues a GET on |url| downloading the response into a file. The file is |
59 // then opened and a file descriptor is made available. | 61 // then opened and a file descriptor is made available. |
60 // Returns true when callback is scheduled to be called on success or failure. | 62 // Returns true when callback is scheduled to be called on success or failure. |
61 // Returns false if callback is NULL, Initialize() has not been called or if | 63 // Returns false if callback is NULL, Initialize() has not been called or if |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 int64_t open_time_; | 139 int64_t open_time_; |
138 DownloadMode mode_; | 140 DownloadMode mode_; |
139 static const uint32_t kTempBufferSize = 2048; | 141 static const uint32_t kTempBufferSize = 2048; |
140 std::vector<char> temp_buffer_; | 142 std::vector<char> temp_buffer_; |
141 std::deque<char> buffer_; | 143 std::deque<char> buffer_; |
142 UrlSchemeType url_scheme_; | 144 UrlSchemeType url_scheme_; |
143 StreamCallbackSource* data_stream_callback_source_; | 145 StreamCallbackSource* data_stream_callback_source_; |
144 }; | 146 }; |
145 } // namespace plugin; | 147 } // namespace plugin; |
146 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ | 148 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_FILE_DOWNLOADER_H_ |
OLD | NEW |