Index: components/nacl/renderer/file_downloader.h |
diff --git a/components/nacl/renderer/manifest_downloader.h b/components/nacl/renderer/file_downloader.h |
similarity index 55% |
copy from components/nacl/renderer/manifest_downloader.h |
copy to components/nacl/renderer/file_downloader.h |
index dbdbf8453c6d1a3b200a9fa1bdbc84e9f62a9e4e..b3960e253aba86ae661435aa630eddc8f2d88079 100644 |
--- a/components/nacl/renderer/manifest_downloader.h |
+++ b/components/nacl/renderer/file_downloader.h |
@@ -5,6 +5,7 @@ |
#include <string> |
#include "base/callback.h" |
+#include "base/files/file.h" |
#include "ppapi/c/private/ppb_nacl_private.h" |
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
@@ -16,15 +17,27 @@ class WebURLResponse; |
namespace nacl { |
-// Downloads a NaCl manifest (.nmf) and returns the contents of the file to |
-// caller through a callback. |
-class ManifestDownloader : public blink::WebURLLoaderClient { |
+// Downloads a file and writes the contents to a specified file open for |
+// writing. |
+class FileDownloader : public blink::WebURLLoaderClient { |
public: |
- typedef base::Callback<void(PP_NaClError, const std::string&)> |
- ManifestDownloaderCallback; |
+ enum Status { |
+ SUCCESS, |
+ ACCESS_DENIED, // Access denied |
+ FAILED // Generic failure |
+ }; |
+ typedef base::Callback<void(Status, int)> FileDownloaderCallback; |
bbudge
2014/05/12 22:32:06
name suggestion: Callback or StatusCallback
teravest
2014/05/13 17:05:32
Done.
|
+ typedef base::Callback<void(int64_t, int64_t)> ProgressCallback; |
- ManifestDownloader(bool is_installed, ManifestDownloaderCallback cb); |
- virtual ~ManifestDownloader(); |
+ FileDownloader(base::PlatformFile file, |
+ FileDownloaderCallback cb); |
bbudge
2014/05/12 22:32:06
nit: fits on a single line.
teravest
2014/05/13 17:05:32
Done.
|
+ |
+ // Creates a FileDownloader that notifies the caller about download progress. |
+ FileDownloader(base::PlatformFile file, |
+ FileDownloaderCallback cb, |
+ ProgressCallback progress_cb); |
+ |
+ virtual ~FileDownloader(); |
private: |
// WebURLLoaderClient implementation. |
@@ -40,11 +53,13 @@ class ManifestDownloader : public blink::WebURLLoaderClient { |
virtual void didFail(blink::WebURLLoader* loader, |
const blink::WebURLError& error); |
- bool is_installed_; |
- ManifestDownloaderCallback cb_; |
- std::string buffer_; |
+ base::PlatformFile file_; |
+ FileDownloaderCallback cb_; |
+ ProgressCallback progress_cb_; |
int status_code_; |
- PP_NaClError pp_nacl_error_; |
+ int64_t total_bytes_received_; |
+ int64_t total_bytes_to_be_received_; |
+ Status status_; |
}; |
} // namespace nacl |