Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / components / nacl / renderer / manifest_downloader.h
blob1dd6cb6ee44a2405a252ad397e6b23f03960cf27
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 // WebURLLoaderClient implementation.
41 virtual void didReceiveResponse(blink::WebURLLoader* loader,
42 const blink::WebURLResponse& response);
43 virtual void didReceiveData(blink::WebURLLoader* loader,
44 const char* data,
45 int data_length,
46 int encoded_data_length);
47 virtual void didFinishLoading(blink::WebURLLoader* loader,
48 double finish_time,
49 int64_t total_encoded_data_length);
50 virtual void didFail(blink::WebURLLoader* loader,
51 const blink::WebURLError& error);
53 scoped_ptr<blink::WebURLLoader> url_loader_;
54 bool is_installed_;
55 Callback cb_;
56 std::string buffer_;
57 int status_code_;
58 PP_NaClError pp_nacl_error_;
61 } // namespace nacl