OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 | 5 |
6 #ifndef LIBRARIES_NACL_IO_MOUNT_HTTP_H_ | 6 #ifndef LIBRARIES_NACL_IO_MOUNT_HTTP_H_ |
7 #define LIBRARIES_NACL_IO_MOUNT_HTTP_H_ | 7 #define LIBRARIES_NACL_IO_MOUNT_HTTP_H_ |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include "nacl_io/mount.h" | 10 #include "nacl_io/mount.h" |
11 #include "nacl_io/pepper_interface.h" | 11 #include "nacl_io/pepper_interface.h" |
12 | 12 |
13 class MountNode; | 13 class MountNode; |
14 class MountNodeDir; | 14 class MountNodeDir; |
15 class MountNodeHttp; | 15 class MountNodeHttp; |
16 class MountHttpMock; | 16 class MountHttpMock; |
17 | 17 |
| 18 std::string NormalizeHeaderKey(const std::string& s); |
| 19 |
18 class MountHttp : public Mount { | 20 class MountHttp : public Mount { |
19 public: | 21 public: |
20 typedef std::map<std::string, MountNode*> NodeMap_t; | 22 typedef std::map<std::string, MountNode*> NodeMap_t; |
21 | 23 |
22 virtual MountNode *Open(const Path& path, int mode); | 24 virtual Error Open(const Path& path, int mode, MountNode** out_node); |
23 virtual int Unlink(const Path& path); | 25 virtual Error Unlink(const Path& path); |
24 virtual int Mkdir(const Path& path, int permissions); | 26 virtual Error Mkdir(const Path& path, int permissions); |
25 virtual int Rmdir(const Path& path); | 27 virtual Error Rmdir(const Path& path); |
26 virtual int Remove(const Path& path); | 28 virtual Error Remove(const Path& path); |
27 | 29 |
28 PP_Resource MakeUrlRequestInfo(const std::string& url, | 30 PP_Resource MakeUrlRequestInfo(const std::string& url, |
29 const char* method, | 31 const char* method, |
30 StringMap_t* additional_headers); | 32 StringMap_t* additional_headers); |
31 | 33 |
32 protected: | 34 protected: |
33 MountHttp(); | 35 MountHttp(); |
34 | 36 |
35 virtual bool Init(int dev, StringMap_t& args, PepperInterface* ppapi); | 37 virtual Error Init(int dev, StringMap_t& args, PepperInterface* ppapi); |
36 virtual void Destroy(); | 38 virtual void Destroy(); |
37 MountNodeDir* FindOrCreateDir(const Path& path); | 39 Error FindOrCreateDir(const Path& path, MountNodeDir** out_node); |
38 char *LoadManifest(const std::string& path); | 40 Error LoadManifest(const std::string& path, char** out_manifest); |
39 bool ParseManifest(char *text); | 41 Error ParseManifest(char *text); |
40 | 42 |
41 private: | 43 private: |
42 std::string url_root_; | 44 std::string url_root_; |
43 StringMap_t headers_; | 45 StringMap_t headers_; |
44 NodeMap_t node_cache_; | 46 NodeMap_t node_cache_; |
45 bool allow_cors_; | 47 bool allow_cors_; |
46 bool allow_credentials_; | 48 bool allow_credentials_; |
47 bool cache_stat_; | 49 bool cache_stat_; |
48 bool cache_content_; | 50 bool cache_content_; |
49 | 51 |
50 friend class Mount; | 52 friend class Mount; |
51 friend class MountNodeHttp; | 53 friend class MountNodeHttp; |
52 friend class MountHttpMock; | 54 friend class MountHttpMock; |
53 }; | 55 }; |
54 | 56 |
55 #endif // LIBRARIES_NACL_IO_MOUNT_HTTP_H_ | 57 #endif // LIBRARIES_NACL_IO_MOUNT_HTTP_H_ |
OLD | NEW |