| 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_OBJECT_H_ | 5 #ifndef LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ |
| 6 #define LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ | 6 #define LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ |
| 7 | 7 |
| 8 #include <pthread.h> | 8 #include <pthread.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "nacl_io/error.h" | 14 #include "nacl_io/error.h" |
| 15 #include "nacl_io/kernel_handle.h" | 15 #include "nacl_io/kernel_handle.h" |
| 16 #include "nacl_io/mount.h" | 16 #include "nacl_io/mount.h" |
| 17 #include "nacl_io/mount_node.h" | 17 #include "nacl_io/mount_node.h" |
| 18 #include "nacl_io/path.h" | 18 #include "nacl_io/path.h" |
| 19 | 19 |
| 20 #include "sdk_util/simple_lock.h" |
| 21 |
| 20 | 22 |
| 21 // KernelObject provides basic functionality for threadsafe access to kernel | 23 // KernelObject provides basic functionality for threadsafe access to kernel |
| 22 // objects such as the CWD, mount points, file descriptors and file handles. | 24 // objects such as the CWD, mount points, file descriptors and file handles. |
| 23 // All Kernel locks are private to ensure the lock order. | 25 // All Kernel locks are private to ensure the lock order. |
| 24 // | 26 // |
| 25 // All calls are assumed to be a relative path. | 27 // All calls are assumed to be a relative path. |
| 26 class KernelObject { | 28 class KernelObject { |
| 27 public: | 29 public: |
| 28 typedef std::vector<ScopedKernelHandle> HandleMap_t; | 30 typedef std::vector<ScopedKernelHandle> HandleMap_t; |
| 29 typedef std::map<std::string, ScopedMount> MountMap_t; | 31 typedef std::map<std::string, ScopedMount> MountMap_t; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Returns parts of the absolute path for the given relative path | 74 // Returns parts of the absolute path for the given relative path |
| 73 Path GetAbsParts(const std::string& path); | 75 Path GetAbsParts(const std::string& path); |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 std::string cwd_; | 78 std::string cwd_; |
| 77 std::vector<int> free_fds_; | 79 std::vector<int> free_fds_; |
| 78 HandleMap_t handle_map_; | 80 HandleMap_t handle_map_; |
| 79 MountMap_t mounts_; | 81 MountMap_t mounts_; |
| 80 | 82 |
| 81 // Lock to protect free_fds_ and handle_map_. | 83 // Lock to protect free_fds_ and handle_map_. |
| 82 pthread_mutex_t handle_lock_; | 84 SimpleLock handle_lock_; |
| 83 | 85 |
| 84 // Lock to protect handle_map_. | 86 // Lock to protect handle_map_. |
| 85 pthread_mutex_t mount_lock_; | 87 SimpleLock mount_lock_; |
| 86 | 88 |
| 87 // Lock to protect cwd_. | 89 // Lock to protect cwd_. |
| 88 pthread_mutex_t cwd_lock_; | 90 SimpleLock cwd_lock_; |
| 89 | 91 |
| 90 DISALLOW_COPY_AND_ASSIGN(KernelObject); | 92 DISALLOW_COPY_AND_ASSIGN(KernelObject); |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 #endif // LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ | 95 #endif // LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ |
| OLD | NEW |