QUIC - cleanup changes to sync chromium tree with internal source.
[chromium-blink-merge.git] / components / nacl / renderer / manifest_downloader.h
blob0e36203bc92836d5c283a3c4803e1ece2f7dbbde
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.
5 #include <string>
7 #include "base/callback.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "components/nacl/renderer/ppb_nacl_private.h"
10 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
12 namespace blink {
13 struct WebURLError;
14 class WebURLLoader;
15 class WebURLResponse;
18 namespace nacl {
20 // Downloads a NaCl manifest (.nmf) and returns the contents of the file to
21 // caller through a callback.
22 class ManifestDownloader : public blink::WebURLLoaderClient {
23 public:
24 typedef base::Callback<void(PP_NaClError, const std::string&)> Callback;
26 // This is a pretty arbitrary limit on the byte size of the NaCl manifest
27 // file.
28 // Note that the resulting string object has to have at least one byte extra
29 // for the null termination character.
30 static const size_t kNaClManifestMaxFileBytes = 1024 * 1024;
32 ManifestDownloader(scoped_ptr<blink::WebURLLoader> url_loader,
33 bool is_installed,
34 Callback cb);
35 virtual ~ManifestDownloader();
37 void Load(const blink::WebURLRequest& request);
39 private:
40 void Close();
42 // WebURLLoaderClient implementation.
43 virtual void didReceiveResponse(blink::WebURLLoader* loader,
44 const blink::WebURLResponse& response);
45 virtual void didReceiveData(blink::WebURLLoader* loader,
46 const char* data,
47 int data_length,
48 int encoded_data_length);
49 virtual void didFinishLoading(blink::WebURLLoader* loader,
50 double finish_time,
51 int64_t total_encoded_data_length);
52 virtual void didFail(blink::WebURLLoader* loader,
53 const blink::WebURLError& error);
55 scoped_ptr<blink::WebURLLoader> url_loader_;
56 bool is_installed_;
57 Callback cb_;
58 std::string buffer_;
59 int status_code_;
60 PP_NaClError pp_nacl_error_;
63 } // namespace nacl