Chromium Code Reviews| Index: ppapi/native_client/src/trusted/plugin/file_downloader.cc |
| diff --git a/ppapi/native_client/src/trusted/plugin/file_downloader.cc b/ppapi/native_client/src/trusted/plugin/file_downloader.cc |
| index ce7fe30b2046f58b4348926d3560e0e40673ccfd..96211f0634b9bf1f9ea03eaf4a839520ceabbff2 100644 |
| --- a/ppapi/native_client/src/trusted/plugin/file_downloader.cc |
| +++ b/ppapi/native_client/src/trusted/plugin/file_downloader.cc |
| @@ -5,6 +5,7 @@ |
| #include "native_client/src/trusted/plugin/file_downloader.h" |
| #include <stdio.h> |
| +#include <string.h> |
| #include <string> |
| #include "native_client/src/include/portability_io.h" |
| @@ -23,6 +24,14 @@ |
| namespace { |
|
Mark Seaborn
2013/05/16 23:01:47
Add empty line after this
Nick Bray (chromium)
2013/05/21 20:09:06
Done.
|
| const int32_t kExtensionUrlRequestStatusOk = 200; |
| const int32_t kDataUriRequestStatusOk = 0; |
| + |
| +struct NaClFileInfo NoFileInfo() { |
|
Mark Seaborn
2013/05/16 23:01:47
'struct NaClFileInfo' -> 'NaClFileInfo' in C++? S
Nick Bray (chromium)
2013/05/21 20:09:06
Staying consistent with the C code base.
|
| + struct NaClFileInfo info; |
| + memset(&info, 0, sizeof(info)); |
| + info.desc = -1; |
| + return info; |
| +} |
| + |
| } |
| namespace plugin { |
| @@ -145,7 +154,8 @@ bool FileDownloader::Open( |
| } |
| void FileDownloader::OpenFast(const nacl::string& url, |
| - PP_FileHandle file_handle) { |
| + PP_FileHandle file_handle, |
| + uint64_t nonce) { |
| PLUGIN_PRINTF(("FileDownloader::OpenFast (url=%s)\n", url.c_str())); |
| CHECK(instance_ != NULL); |
| open_time_ = NaClGetTimeOfDayMicroseconds(); |
| @@ -154,9 +164,11 @@ void FileDownloader::OpenFast(const nacl::string& url, |
| url_ = url; |
| mode_ = DOWNLOAD_NONE; |
| file_handle_ = file_handle; |
| + nonce_ = nonce; |
| } |
| -int32_t FileDownloader::GetPOSIXFileDescriptor() { |
| +struct NaClFileInfo FileDownloader::GetFileInfo() { |
| + struct NaClFileInfo info = NoFileInfo(); |
| int32_t file_desc = NACL_NO_FILE_DESC; |
| if (not_streaming() && file_handle_ != PP_kInvalidFileHandle) { |
| #if NACL_WINDOWS |
| @@ -165,13 +177,14 @@ int32_t FileDownloader::GetPOSIXFileDescriptor() { |
| #else |
| file_desc = file_handle_; |
| #endif |
| + info.nonce = nonce_; |
| } else { |
| if (!streaming_to_file()) { |
| - return NACL_NO_FILE_DESC; |
| + return NoFileInfo(); |
| } |
| // Use the trusted interface to get the file descriptor. |
| if (file_io_trusted_interface_ == NULL) { |
| - return NACL_NO_FILE_DESC; |
| + return NoFileInfo(); |
| } |
| file_desc = file_io_trusted_interface_->GetOSFileDescriptor( |
| file_reader_.pp_resource()); |
| @@ -183,12 +196,13 @@ int32_t FileDownloader::GetPOSIXFileDescriptor() { |
| if (posix_desc == -1) { |
| // Close the Windows HANDLE if it can't be converted. |
| CloseHandle(reinterpret_cast<HANDLE>(file_desc)); |
| - return NACL_NO_FILE_DESC; |
| + return NoFileInfo(); |
| } |
| file_desc = posix_desc; |
| #endif |
| - return file_desc; |
| + info.desc = file_desc; |
| + return info; |
| } |
| int64_t FileDownloader::TimeSinceOpenMilliseconds() const { |