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

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
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, // Access denied
27 FAILED // Generic failure
28 };
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.
29 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.
30 typedef base::Callback<void(int64_t, int64_t)> ProgressCallback;
25 31
26 ManifestDownloader(bool is_installed, ManifestDownloaderCallback cb); 32 // Creates a FileDownloader that notifies the caller about download progress.
27 virtual ~ManifestDownloader(); 33 FileDownloader(scoped_ptr<blink::WebURLLoader> url_loader,
34 base::PlatformFile file,
35 StatusCallback cb,
36 ProgressCallback progress_cb);
37
38 virtual ~FileDownloader();
39
40 void Load(const blink::WebURLRequest& request);
28 41
29 private: 42 private:
30 // WebURLLoaderClient implementation. 43 // WebURLLoaderClient implementation.
31 virtual void didReceiveResponse(blink::WebURLLoader* loader, 44 virtual void didReceiveResponse(blink::WebURLLoader* loader,
32 const blink::WebURLResponse& response); 45 const blink::WebURLResponse& response);
33 virtual void didReceiveData(blink::WebURLLoader* loader, 46 virtual void didReceiveData(blink::WebURLLoader* loader,
34 const char* data, 47 const char* data,
35 int data_length, 48 int data_length,
36 int encoded_data_length); 49 int encoded_data_length);
37 virtual void didFinishLoading(blink::WebURLLoader* loader, 50 virtual void didFinishLoading(blink::WebURLLoader* loader,
38 double finish_time, 51 double finish_time,
39 int64_t total_encoded_data_length); 52 int64_t total_encoded_data_length);
40 virtual void didFail(blink::WebURLLoader* loader, 53 virtual void didFail(blink::WebURLLoader* loader,
41 const blink::WebURLError& error); 54 const blink::WebURLError& error);
42 55
43 bool is_installed_; 56 scoped_ptr<blink::WebURLLoader> url_loader_;
44 ManifestDownloaderCallback cb_; 57 base::PlatformFile file_;
45 std::string buffer_; 58 StatusCallback cb_;
bbudge 2014/05/14 21:46:18 s/cb_/status_cb_ ?
teravest 2014/05/15 19:12:21 Done.
59 ProgressCallback progress_cb_;
46 int status_code_; 60 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.
47 PP_NaClError pp_nacl_error_; 61 int64_t total_bytes_received_;
62 int64_t total_bytes_to_be_received_;
63 Status status_;
48 }; 64 };
49 65
50 } // namespace nacl 66 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698