- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / mount_http.h
1 // Copyright (c) 2012 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
6 #ifndef LIBRARIES_NACL_IO_MOUNT_HTTP_H_
7 #define LIBRARIES_NACL_IO_MOUNT_HTTP_H_
8
9 #include <string>
10 #include "nacl_io/mount.h"
11 #include "nacl_io/pepper_interface.h"
12 #include "nacl_io/typed_mount_factory.h"
13
14 class MountHttpMock;
15
16 namespace nacl_io {
17
18 class MountNode;
19
20 std::string NormalizeHeaderKey(const std::string& s);
21
22 class MountHttp : public Mount {
23  public:
24   typedef std::map<std::string, ScopedMountNode> NodeMap_t;
25
26   virtual Error Access(const Path& path, int a_mode);
27   virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node);
28   virtual Error Unlink(const Path& path);
29   virtual Error Mkdir(const Path& path, int permissions);
30   virtual Error Rmdir(const Path& path);
31   virtual Error Remove(const Path& path);
32
33   PP_Resource MakeUrlRequestInfo(const std::string& url,
34                                  const char* method,
35                                  StringMap_t* additional_headers);
36
37  protected:
38   MountHttp();
39
40   virtual Error Init(int dev, StringMap_t& args, PepperInterface* ppapi);
41   virtual void Destroy();
42   Error FindOrCreateDir(const Path& path, ScopedMountNode* out_node);
43   Error LoadManifest(const std::string& path, char** out_manifest);
44   Error ParseManifest(const char *text);
45
46  private:
47   // Gets the URL to fetch for |path|.
48   // |path| is relative to the mount point for the HTTP filesystem.
49   std::string MakeUrl(const Path& path);
50
51   std::string url_root_;
52   StringMap_t headers_;
53   NodeMap_t node_cache_;
54   bool allow_cors_;
55   bool allow_credentials_;
56   bool cache_stat_;
57   bool cache_content_;
58
59   friend class TypedMountFactory<MountHttp>;
60   friend class MountNodeHttp;
61   friend class ::MountHttpMock;
62 };
63
64 }  // namespace nacl_io
65
66 #endif  // LIBRARIES_NACL_IO_MOUNT_HTTP_H_