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 #ifndef LIBRARIES_NACL_IO_KERNEL_PROXY_H_ | 5 #ifndef LIBRARIES_NACL_IO_KERNEL_PROXY_H_ |
6 #define LIBRARIES_NACL_IO_KERNEL_PROXY_H_ | 6 #define LIBRARIES_NACL_IO_KERNEL_PROXY_H_ |
7 | 7 |
8 #include <ppapi/c/pp_instance.h> | 8 #include <ppapi/c/pp_instance.h> |
9 #include <ppapi/c/ppb.h> | 9 #include <ppapi/c/ppb.h> |
10 #include <pthread.h> | 10 #include <pthread.h> |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "nacl_io/kernel_object.h" | 15 #include "nacl_io/kernel_object.h" |
16 #include "nacl_io/mount.h" | 16 #include "nacl_io/mount.h" |
17 #include "nacl_io/ostypes.h" | 17 #include "nacl_io/ostypes.h" |
18 #include "nacl_io/path.h" | 18 #include "nacl_io/path.h" |
19 | 19 |
20 class KernelHandle; | 20 class KernelHandle; |
21 class Mount; | 21 class Mount; |
22 class MountNode; | 22 class MountNode; |
23 class PepperInterface; | 23 class PepperInterface; |
24 | 24 |
25 // KernelProxy provide one-to-one mapping for libc kernel calls. Calls to the | 25 // KernelProxy provide one-to-one mapping for libc kernel calls. Calls to the |
26 // proxy will result in IO access to the provided Mount and MountNode objects. | 26 // proxy will result in IO access to the provided Mount and MountNode objects. |
| 27 // |
| 28 // NOTE: The KernelProxy is the only class that should be setting errno. All |
| 29 // other classes should return Error (as defined by nacl_io/error.h). |
27 class KernelProxy : protected KernelObject { | 30 class KernelProxy : protected KernelObject { |
28 public: | 31 public: |
29 typedef Mount* (*MountFactory_t)(int, StringMap_t&, PepperInterface*); | 32 typedef Error (*MountFactory_t)(int, StringMap_t&, PepperInterface*, Mount**); |
30 typedef std::map<std::string, std::string> StringMap_t; | 33 typedef std::map<std::string, std::string> StringMap_t; |
31 typedef std::map<std::string, MountFactory_t> MountFactoryMap_t; | 34 typedef std::map<std::string, MountFactory_t> MountFactoryMap_t; |
32 | 35 |
33 KernelProxy(); | 36 KernelProxy(); |
34 virtual ~KernelProxy(); | 37 virtual ~KernelProxy(); |
35 // Takes ownership of |ppapi|. | 38 // Takes ownership of |ppapi|. |
36 // |ppapi| may be NULL. If so, no mount that uses pepper calls can be mounted. | 39 // |ppapi| may be NULL. If so, no mount that uses pepper calls can be mounted. |
37 virtual void Init(PepperInterface* ppapi); | 40 virtual void Init(PepperInterface* ppapi); |
38 | 41 |
39 // KernelHandle and FD allocation and manipulation functions. | 42 // KernelHandle and FD allocation and manipulation functions. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 MountFactoryMap_t factories_; | 104 MountFactoryMap_t factories_; |
102 int dev_; | 105 int dev_; |
103 PepperInterface* ppapi_; | 106 PepperInterface* ppapi_; |
104 | 107 |
105 static KernelProxy *s_instance_; | 108 static KernelProxy *s_instance_; |
106 | 109 |
107 DISALLOW_COPY_AND_ASSIGN(KernelProxy); | 110 DISALLOW_COPY_AND_ASSIGN(KernelProxy); |
108 }; | 111 }; |
109 | 112 |
110 #endif // LIBRARIES_NACL_IO_KERNEL_PROXY_H_ | 113 #endif // LIBRARIES_NACL_IO_KERNEL_PROXY_H_ |
OLD | NEW |