| 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_HANDLE_H_ | 5 #ifndef LIBRARIES_NACL_IO_KERNEL_HANDLE_H_ |
| 6 #define LIBRARIES_NACL_IO_KERNEL_HANDLE_H_ | 6 #define LIBRARIES_NACL_IO_KERNEL_HANDLE_H_ |
| 7 | 7 |
| 8 #include <pthread.h> | 8 #include <pthread.h> |
| 9 | 9 |
| 10 #include "nacl_io/error.h" | 10 #include "nacl_io/error.h" |
| 11 #include "nacl_io/mount.h" | 11 #include "nacl_io/mount.h" |
| 12 #include "nacl_io/mount_node.h" | 12 #include "nacl_io/mount_node.h" |
| 13 #include "nacl_io/ostypes.h" | 13 #include "nacl_io/ostypes.h" |
| 14 | 14 |
| 15 #include "sdk_util/macros.h" | 15 #include "sdk_util/macros.h" |
| 16 #include "sdk_util/ref_object.h" | 16 #include "sdk_util/ref_object.h" |
| 17 #include "sdk_util/scoped_ref.h" | 17 #include "sdk_util/scoped_ref.h" |
| 18 #include "sdk_util/simple_lock.h" |
| 18 | 19 |
| 19 // KernelHandle provides a reference counted container for the open | 20 // KernelHandle provides a reference counted container for the open |
| 20 // file information, such as it's mount, node, access type and offset. | 21 // file information, such as it's mount, node, access type and offset. |
| 21 // KernelHandle can only be referenced when the KernelProxy lock is held. | 22 // KernelHandle can only be referenced when the KernelProxy lock is held. |
| 22 class KernelHandle : public RefObject { | 23 class KernelHandle : public RefObject { |
| 23 public: | 24 public: |
| 24 KernelHandle(); | 25 KernelHandle(); |
| 25 KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node); | 26 KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node); |
| 26 | 27 |
| 27 Error Init(int open_flags); | 28 Error Init(int open_flags); |
| 28 | 29 |
| 29 // Assumes |out_offset| is non-NULL. | 30 // Assumes |out_offset| is non-NULL. |
| 30 Error Seek(off_t offset, int whence, off_t* out_offset); | 31 Error Seek(off_t offset, int whence, off_t* out_offset); |
| 31 | 32 |
| 32 ScopedRef<Mount> mount_; | 33 ScopedRef<Mount> mount_; |
| 33 ScopedRef<MountNode> node_; | 34 ScopedRef<MountNode> node_; |
| 34 size_t offs_; | 35 size_t offs_; |
| 35 | 36 |
| 36 private: | 37 private: |
| 38 SimpleLock lock_; |
| 39 |
| 37 friend class KernelProxy; | 40 friend class KernelProxy; |
| 38 DISALLOW_COPY_AND_ASSIGN(KernelHandle); | 41 DISALLOW_COPY_AND_ASSIGN(KernelHandle); |
| 39 }; | 42 }; |
| 40 | 43 |
| 41 typedef ScopedRef<KernelHandle> ScopedKernelHandle; | 44 typedef ScopedRef<KernelHandle> ScopedKernelHandle; |
| 42 | 45 |
| 43 #endif // LIBRARIES_NACL_IO_KERNEL_HANDLE_H_ | 46 #endif // LIBRARIES_NACL_IO_KERNEL_HANDLE_H_ |
| OLD | NEW |