Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: components/nacl/renderer/file_downloader.h

Issue 276423003: Pepper: Nexe downloading out of the trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows fix and stuff for bill Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/nacl/renderer/file_downloader.h
diff --git a/components/nacl/renderer/file_downloader.h b/components/nacl/renderer/file_downloader.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc7126933f93bc9ac81aa58431466e75e271c9ea
--- /dev/null
+++ b/components/nacl/renderer/file_downloader.h
@@ -0,0 +1,71 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#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"
+
+namespace blink {
+struct WebURLError;
+class WebURLLoader;
+class WebURLResponse;
+}
+
+namespace nacl {
+
+// Downloads a file and writes the contents to a specified file open for
+// writing.
+class FileDownloader : public blink::WebURLLoaderClient {
+ public:
+ enum Status {
+ SUCCESS,
+ ACCESS_DENIED, // Access denied
bbudge 2014/05/16 17:20:51 nit: comments seem redundant
+ FAILED // Generic failure
+ };
+
+ // Provides a FileDownloader status and the HTTP status code.
bbudge 2014/05/16 17:20:51 nit s/a/the
+ typedef base::Callback<void(Status, int)> StatusCallback;
+
+ // Provides the bytes received so far, and the total bytes received to be
+ // expected.
bbudge 2014/05/16 17:20:51 nit: how about? // Provides the bytes received so
+ typedef base::Callback<void(int64_t, int64_t)> ProgressCallback;
+
+ // Creates a FileDownloader that notifies the caller about download progress.
bbudge 2014/05/16 17:20:51 optionally notifies?
+ FileDownloader(scoped_ptr<blink::WebURLLoader> url_loader,
+ base::PlatformFile file,
+ StatusCallback cb,
bbudge 2014/05/16 17:20:51 s/cb/status_cb
+ ProgressCallback progress_cb);
+
+ virtual ~FileDownloader();
+
+ void Load(const blink::WebURLRequest& request);
+
+ private:
+ // WebURLLoaderClient implementation.
+ virtual void didReceiveResponse(blink::WebURLLoader* loader,
+ const blink::WebURLResponse& response);
+ virtual void didReceiveData(blink::WebURLLoader* loader,
+ const char* data,
+ int data_length,
+ int encoded_data_length);
+ virtual void didFinishLoading(blink::WebURLLoader* loader,
+ double finish_time,
+ int64_t total_encoded_data_length);
+ virtual void didFail(blink::WebURLLoader* loader,
+ const blink::WebURLError& error);
+
+ scoped_ptr<blink::WebURLLoader> url_loader_;
+ base::PlatformFile file_;
+ StatusCallback status_cb_;
+ ProgressCallback progress_cb_;
+ int http_status_code_;
+ int64_t total_bytes_received_;
+ int64_t total_bytes_to_be_received_;
+ Status status_;
+};
+
+} // namespace nacl

Powered by Google App Engine
This is Rietveld 408576698