Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / httpfs / http_fs.h
blobb481cc4821ec407141fad95672a8a86f7b675a05
1 // Copyright 2013 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 #ifndef LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_
6 #define LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_
8 #include <string>
9 #include "nacl_io/filesystem.h"
10 #include "nacl_io/pepper_interface.h"
11 #include "nacl_io/typed_fs_factory.h"
13 namespace nacl_io {
15 std::string NormalizeHeaderKey(const std::string& s);
17 class HttpFs : public Filesystem {
18 public:
19 typedef std::map<std::string, ScopedNode> NodeMap_t;
21 virtual Error OpenWithMode(const Path& path, int open_flags, mode_t mode,
22 ScopedNode* out_node);
23 virtual Error Unlink(const Path& path);
24 virtual Error Mkdir(const Path& path, int permissions);
25 virtual Error Rmdir(const Path& path);
26 virtual Error Remove(const Path& path);
27 virtual Error Rename(const Path& path, const Path& newpath);
29 PP_Resource MakeUrlRequestInfo(const std::string& url,
30 const char* method,
31 StringMap_t* additional_headers);
33 protected:
34 HttpFs();
36 virtual Error Init(const FsInitArgs& args);
37 virtual void Destroy();
38 ScopedNode FindExistingNode(const Path& path);
39 Error FindOrCreateDir(const Path& path, ScopedNode* out_node);
40 Error LoadManifest(const std::string& path, char** out_manifest);
41 Error ParseManifest(const char* text);
43 NodeMap_t* GetNodeCacheForTesting() { return &node_cache_; }
45 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);
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 bool is_blob_url_;
60 friend class TypedFsFactory<HttpFs>;
61 friend class HttpFsNode;
64 } // namespace nacl_io
66 #endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_H_