Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/kernel_handle.h

Issue 19717004: [NaCl SDK] Add nacl_io and sdk_util namespaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad copyright in mount_mem Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "sdk_util/simple_lock.h"
19 19
20 namespace nacl_io {
21
20 // KernelHandle provides a reference counted container for the open 22 // KernelHandle provides a reference counted container for the open
21 // file information, such as it's mount, node, access type and offset. 23 // file information, such as it's mount, node, access type and offset.
22 // KernelHandle can only be referenced when the KernelProxy lock is held. 24 // KernelHandle can only be referenced when the KernelProxy lock is held.
23 class KernelHandle : public RefObject { 25 class KernelHandle : public sdk_util::RefObject {
24 public: 26 public:
25 KernelHandle(); 27 KernelHandle();
26 KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node); 28 KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node);
27 29
28 Error Init(int open_flags); 30 Error Init(int open_flags);
29 31
30 // Assumes |out_offset| is non-NULL. 32 // Assumes |out_offset| is non-NULL.
31 Error Seek(off_t offset, int whence, off_t* out_offset); 33 Error Seek(off_t offset, int whence, off_t* out_offset);
32 34
33 // Dispatches Read, Write, GetDents to atomically update offs_. 35 // Dispatches Read, Write, GetDents to atomically update offs_.
34 Error Read(void* buf, size_t nbytes, int* bytes_read); 36 Error Read(void* buf, size_t nbytes, int* bytes_read);
35 Error Write(const void* buf, size_t nbytes, int* bytes_written); 37 Error Write(const void* buf, size_t nbytes, int* bytes_written);
36 Error GetDents(struct dirent* pdir, size_t count, int* bytes_written); 38 Error GetDents(struct dirent* pdir, size_t count, int* bytes_written);
37 39
38 const ScopedRef<MountNode>& node(); 40 const ScopedMountNode& node() { return node_; }
39 const ScopedRef<Mount>& mount(); 41 const ScopedMount& mount() { return mount_; }
40 42
41 private: 43 private:
42 ScopedRef<MountNode> node_; 44 ScopedMountNode node_;
43 ScopedRef<Mount> mount_; 45 ScopedMount mount_;
44 SimpleLock offs_lock_; 46 sdk_util::SimpleLock offs_lock_;
45 size_t offs_; 47 size_t offs_;
46 48
47 friend class KernelProxy; 49 friend class KernelProxy;
48 DISALLOW_COPY_AND_ASSIGN(KernelHandle); 50 DISALLOW_COPY_AND_ASSIGN(KernelHandle);
49 }; 51 };
50 52
51 typedef ScopedRef<KernelHandle> ScopedKernelHandle; 53 typedef sdk_util::ScopedRef<KernelHandle> ScopedKernelHandle;
54
55 } // namespace nacl_io
52 56
53 #endif // LIBRARIES_NACL_IO_KERNEL_HANDLE_H_ 57 #endif // LIBRARIES_NACL_IO_KERNEL_HANDLE_H_
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/inode_pool.h ('k') | native_client_sdk/src/libraries/nacl_io/kernel_handle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698