OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "components/nacl/renderer/ppb_nacl_private.h" | 12 #include "components/nacl/renderer/ppb_nacl_private.h" |
13 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" | 13 #include "third_party/WebKit/public/web/WebAssociatedURLLoaderClient.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
| 16 class WebAssociatedURLLoader; |
16 struct WebURLError; | 17 struct WebURLError; |
17 class WebURLLoader; | 18 class WebURLLoader; |
18 class WebURLResponse; | 19 class WebURLResponse; |
19 } | 20 } |
20 | 21 |
21 namespace nacl { | 22 namespace nacl { |
22 | 23 |
23 // Downloads a NaCl manifest (.nmf) and returns the contents of the file to | 24 // Downloads a NaCl manifest (.nmf) and returns the contents of the file to |
24 // caller through a callback. | 25 // caller through a callback. |
25 class ManifestDownloader : public blink::WebURLLoaderClient { | 26 class ManifestDownloader : public blink::WebAssociatedURLLoaderClient { |
26 public: | 27 public: |
27 typedef base::Callback<void(PP_NaClError, const std::string&)> Callback; | 28 typedef base::Callback<void(PP_NaClError, const std::string&)> Callback; |
28 | 29 |
29 // This is a pretty arbitrary limit on the byte size of the NaCl manifest | 30 // This is a pretty arbitrary limit on the byte size of the NaCl manifest |
30 // file. | 31 // file. |
31 // Note that the resulting string object has to have at least one byte extra | 32 // Note that the resulting string object has to have at least one byte extra |
32 // for the null termination character. | 33 // for the null termination character. |
33 static const size_t kNaClManifestMaxFileBytes = 1024 * 1024; | 34 static const size_t kNaClManifestMaxFileBytes = 1024 * 1024; |
34 | 35 |
35 ManifestDownloader(std::unique_ptr<blink::WebURLLoader> url_loader, | 36 ManifestDownloader(std::unique_ptr<blink::WebAssociatedURLLoader> url_loader, |
36 bool is_installed, | 37 bool is_installed, |
37 Callback cb); | 38 Callback cb); |
38 ~ManifestDownloader() override; | 39 ~ManifestDownloader() override; |
39 | 40 |
40 void Load(const blink::WebURLRequest& request); | 41 void Load(const blink::WebURLRequest& request); |
41 | 42 |
42 private: | 43 private: |
43 void Close(); | 44 void Close(); |
44 | 45 |
45 // WebURLLoaderClient implementation. | 46 // WebAssociatedURLLoaderClient implementation. |
46 void didReceiveResponse(blink::WebURLLoader* loader, | 47 void didReceiveResponse(const blink::WebURLResponse& response) override; |
47 const blink::WebURLResponse& response) override; | 48 void didReceiveData(const char* data, int data_length) override; |
48 void didReceiveData(blink::WebURLLoader* loader, | 49 void didFinishLoading(double finish_time) override; |
49 const char* data, | 50 void didFail(const blink::WebURLError& error) override; |
50 int data_length, | |
51 int encoded_data_length, | |
52 int encoded_body_length) override; | |
53 void didFinishLoading(blink::WebURLLoader* loader, | |
54 double finish_time, | |
55 int64_t total_encoded_data_length) override; | |
56 void didFail(blink::WebURLLoader* loader, | |
57 const blink::WebURLError& error) override; | |
58 | 51 |
59 std::unique_ptr<blink::WebURLLoader> url_loader_; | 52 std::unique_ptr<blink::WebAssociatedURLLoader> url_loader_; |
60 bool is_installed_; | 53 bool is_installed_; |
61 Callback cb_; | 54 Callback cb_; |
62 std::string buffer_; | 55 std::string buffer_; |
63 int status_code_; | 56 int status_code_; |
64 PP_NaClError pp_nacl_error_; | 57 PP_NaClError pp_nacl_error_; |
65 }; | 58 }; |
66 | 59 |
67 } // namespace nacl | 60 } // namespace nacl |
OLD | NEW |