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

Side by Side 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: rebased 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « components/nacl.gyp ('k') | components/nacl/renderer/file_downloader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <string> 5 #include <string>
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/files/file.h"
8 #include "ppapi/c/private/ppb_nacl_private.h" 9 #include "ppapi/c/private/ppb_nacl_private.h"
9 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 10 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
10 11
11 namespace blink { 12 namespace blink {
12 struct WebURLError; 13 struct WebURLError;
13 class WebURLLoader; 14 class WebURLLoader;
14 class WebURLResponse; 15 class WebURLResponse;
15 } 16 }
16 17
17 namespace nacl { 18 namespace nacl {
18 19
19 // Downloads a NaCl manifest (.nmf) and returns the contents of the file to 20 // Downloads a file and writes the contents to a specified file open for
20 // caller through a callback. 21 // writing.
21 class ManifestDownloader : public blink::WebURLLoaderClient { 22 class FileDownloader : public blink::WebURLLoaderClient {
22 public: 23 public:
23 typedef base::Callback<void(PP_NaClError, const std::string&)> 24 enum Status {
24 ManifestDownloaderCallback; 25 SUCCESS,
26 ACCESS_DENIED,
27 FAILED
28 };
25 29
26 ManifestDownloader(bool is_installed, ManifestDownloaderCallback cb); 30 // Provides the FileDownloader status and the HTTP status code.
27 virtual ~ManifestDownloader(); 31 typedef base::Callback<void(Status, int)> StatusCallback;
28 32
29 // This is a pretty arbitrary limit on the byte size of the NaCl manifest 33 // Provides the bytes received so far, and the total bytes expected to be
30 // file. 34 // received.
31 // Note that the resulting string object has to have at least one byte extra 35 typedef base::Callback<void(int64_t, int64_t)> ProgressCallback;
32 // for the null termination character. 36
33 static const size_t kNaClManifestMaxFileBytes = 1024 * 1024; 37 FileDownloader(scoped_ptr<blink::WebURLLoader> url_loader,
38 base::PlatformFile file,
39 StatusCallback status_cb,
40 ProgressCallback progress_cb);
41
42 virtual ~FileDownloader();
43
44 void Load(const blink::WebURLRequest& request);
34 45
35 private: 46 private:
36 // WebURLLoaderClient implementation. 47 // WebURLLoaderClient implementation.
37 virtual void didReceiveResponse(blink::WebURLLoader* loader, 48 virtual void didReceiveResponse(blink::WebURLLoader* loader,
38 const blink::WebURLResponse& response); 49 const blink::WebURLResponse& response);
39 virtual void didReceiveData(blink::WebURLLoader* loader, 50 virtual void didReceiveData(blink::WebURLLoader* loader,
40 const char* data, 51 const char* data,
41 int data_length, 52 int data_length,
42 int encoded_data_length); 53 int encoded_data_length);
43 virtual void didFinishLoading(blink::WebURLLoader* loader, 54 virtual void didFinishLoading(blink::WebURLLoader* loader,
44 double finish_time, 55 double finish_time,
45 int64_t total_encoded_data_length); 56 int64_t total_encoded_data_length);
46 virtual void didFail(blink::WebURLLoader* loader, 57 virtual void didFail(blink::WebURLLoader* loader,
47 const blink::WebURLError& error); 58 const blink::WebURLError& error);
48 59
49 bool is_installed_; 60 scoped_ptr<blink::WebURLLoader> url_loader_;
50 ManifestDownloaderCallback cb_; 61 base::PlatformFile file_;
51 std::string buffer_; 62 StatusCallback status_cb_;
52 int status_code_; 63 ProgressCallback progress_cb_;
53 PP_NaClError pp_nacl_error_; 64 int http_status_code_;
65 int64_t total_bytes_received_;
66 int64_t total_bytes_to_be_received_;
67 Status status_;
54 }; 68 };
55 69
56 } // namespace nacl 70 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl.gyp ('k') | components/nacl/renderer/file_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698