Chromium Code Reviews| 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 54% |
| copy from components/nacl/renderer/manifest_downloader.h |
| copy to components/nacl/renderer/file_downloader.h |
| index dbdbf8453c6d1a3b200a9fa1bdbc84e9f62a9e4e..0bd31a84d74ef61451014da640c1c803e205e967 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 |
| + }; |
|
bbudge
2014/05/14 21:46:18
Comment here to say what the 'int' param (http sta
teravest
2014/05/15 19:12:21
Done.
|
| + typedef base::Callback<void(Status, int)> StatusCallback; |
|
bbudge
2014/05/14 21:46:18
Comment here to say what the int64_t's are?
teravest
2014/05/15 19:12:21
Done.
|
| + typedef base::Callback<void(int64_t, int64_t)> ProgressCallback; |
| - ManifestDownloader(bool is_installed, ManifestDownloaderCallback cb); |
| - virtual ~ManifestDownloader(); |
| + // Creates a FileDownloader that notifies the caller about download progress. |
| + FileDownloader(scoped_ptr<blink::WebURLLoader> url_loader, |
| + base::PlatformFile file, |
| + StatusCallback cb, |
| + ProgressCallback progress_cb); |
| + |
| + virtual ~FileDownloader(); |
| + |
| + void Load(const blink::WebURLRequest& request); |
| private: |
| // WebURLLoaderClient implementation. |
| @@ -40,11 +53,14 @@ class ManifestDownloader : public blink::WebURLLoaderClient { |
| virtual void didFail(blink::WebURLLoader* loader, |
| const blink::WebURLError& error); |
| - bool is_installed_; |
| - ManifestDownloaderCallback cb_; |
| - std::string buffer_; |
| + scoped_ptr<blink::WebURLLoader> url_loader_; |
| + base::PlatformFile file_; |
| + StatusCallback cb_; |
|
bbudge
2014/05/14 21:46:18
s/cb_/status_cb_ ?
teravest
2014/05/15 19:12:21
Done.
|
| + ProgressCallback progress_cb_; |
| int status_code_; |
|
bbudge
2014/05/14 21:46:18
Could we rename this to http_status_code_? Differe
teravest
2014/05/15 19:12:21
Done.
|
| - PP_NaClError pp_nacl_error_; |
| + int64_t total_bytes_received_; |
| + int64_t total_bytes_to_be_received_; |
| + Status status_; |
| }; |
| } // namespace nacl |