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

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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/callback.h"
8 #include "base/files/file.h"
9 #include "ppapi/c/private/ppb_nacl_private.h"
10 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
11
12 namespace blink {
13 struct WebURLError;
14 class WebURLLoader;
15 class WebURLResponse;
16 }
17
18 namespace nacl {
19
20 // Downloads a file and writes the contents to a specified file open for
21 // writing.
22 class FileDownloader : public blink::WebURLLoaderClient {
23 public:
24 enum Status {
25 SUCCESS,
26 ACCESS_DENIED, // Access denied
bbudge 2014/05/16 17:20:51 nit: comments seem redundant
27 FAILED // Generic failure
28 };
29
30 // Provides a FileDownloader status and the HTTP status code.
bbudge 2014/05/16 17:20:51 nit s/a/the
31 typedef base::Callback<void(Status, int)> StatusCallback;
32
33 // Provides the bytes received so far, and the total bytes received to be
34 // expected.
bbudge 2014/05/16 17:20:51 nit: how about? // Provides the bytes received so
35 typedef base::Callback<void(int64_t, int64_t)> ProgressCallback;
36
37 // Creates a FileDownloader that notifies the caller about download progress.
bbudge 2014/05/16 17:20:51 optionally notifies?
38 FileDownloader(scoped_ptr<blink::WebURLLoader> url_loader,
39 base::PlatformFile file,
40 StatusCallback cb,
bbudge 2014/05/16 17:20:51 s/cb/status_cb
41 ProgressCallback progress_cb);
42
43 virtual ~FileDownloader();
44
45 void Load(const blink::WebURLRequest& request);
46
47 private:
48 // WebURLLoaderClient implementation.
49 virtual void didReceiveResponse(blink::WebURLLoader* loader,
50 const blink::WebURLResponse& response);
51 virtual void didReceiveData(blink::WebURLLoader* loader,
52 const char* data,
53 int data_length,
54 int encoded_data_length);
55 virtual void didFinishLoading(blink::WebURLLoader* loader,
56 double finish_time,
57 int64_t total_encoded_data_length);
58 virtual void didFail(blink::WebURLLoader* loader,
59 const blink::WebURLError& error);
60
61 scoped_ptr<blink::WebURLLoader> url_loader_;
62 base::PlatformFile file_;
63 StatusCallback status_cb_;
64 ProgressCallback progress_cb_;
65 int http_status_code_;
66 int64_t total_bytes_received_;
67 int64_t total_bytes_to_be_received_;
68 Status status_;
69 };
70
71 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698