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

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

Issue 18644009: [NaCl SDK] Upate atomic ops in nacl_io (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 'Move comment to correct location' 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 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
33 // Distatches Read, Write, GetDents to atomically update offs_.
binji 2013/07/13 00:16:48 sp: Dispatches?
34 Error Read(void* buf, size_t nbytes, int* bytes_read);
35 Error Write(const void* buf, size_t nbytes, int* bytes_written);
36 Error GetDents(struct dirent* pdir, size_t count, int* bytes_written);
37
38 const ScopedRef<MountNode>& node();
39 const ScopedRef<Mount>& mount();
40
41 private:
42 ScopedRef<MountNode> node_;
32 ScopedRef<Mount> mount_; 43 ScopedRef<Mount> mount_;
33 ScopedRef<MountNode> node_; 44 SimpleLock offs_lock_;
34 size_t offs_; 45 size_t offs_;
35 46
36 private:
37 friend class KernelProxy; 47 friend class KernelProxy;
38 DISALLOW_COPY_AND_ASSIGN(KernelHandle); 48 DISALLOW_COPY_AND_ASSIGN(KernelHandle);
39 }; 49 };
40 50
41 typedef ScopedRef<KernelHandle> ScopedKernelHandle; 51 typedef ScopedRef<KernelHandle> ScopedKernelHandle;
42 52
43 #endif // LIBRARIES_NACL_IO_KERNEL_HANDLE_H_ 53 #endif // LIBRARIES_NACL_IO_KERNEL_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698