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

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

Issue 22587003: [NaCl SDK] Add UDP and TCP Sockets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to browser tester fix. Created 7 years, 4 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 { 20 namespace nacl_io {
21 21
22 class MountNode;
23 class MountNodeSocket;
24
22 // KernelHandle provides a reference counted container for the open 25 // KernelHandle provides a reference counted container for the open
23 // file information, such as it's mount, node, access type and offset. 26 // file information, such as it's mount, node, access type and offset.
24 // KernelHandle can only be referenced when the KernelProxy lock is held. 27 // KernelHandle can only be referenced when the KernelProxy lock is held.
25 class KernelHandle : public sdk_util::RefObject { 28 class KernelHandle : public sdk_util::RefObject {
26 public: 29 public:
27 KernelHandle(); 30 KernelHandle();
28 KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node); 31 KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node);
29 ~KernelHandle(); 32 ~KernelHandle();
30 33
31 Error Init(int open_flags); 34 Error Init(int open_flags);
32 35
33 // Assumes |out_offset| is non-NULL. 36 // Assumes |out_offset| is non-NULL.
34 Error Seek(off_t offset, int whence, off_t* out_offset); 37 Error Seek(off_t offset, int whence, off_t* out_offset);
35 38
36 // Dispatches Read, Write, GetDents to atomically update offs_. 39 // Dispatches Read, Write, GetDents to atomically update offs_.
37 Error Read(void* buf, size_t nbytes, int* bytes_read); 40 Error Read(void* buf, size_t nbytes, int* bytes_read);
38 Error Write(const void* buf, size_t nbytes, int* bytes_written); 41 Error Write(const void* buf, size_t nbytes, int* bytes_written);
39 Error GetDents(struct dirent* pdir, size_t count, int* bytes_written); 42 Error GetDents(struct dirent* pdir, size_t count, int* bytes_written);
40 43
41 const ScopedMountNode& node() { return node_; } 44 const ScopedMountNode& node() { return node_; }
42 const ScopedMount& mount() { return mount_; } 45 const ScopedMount& mount() { return mount_; }
43 46
47 // Returns the MountNodeSocket* if this node is a socket otherwise returns
48 // NULL.
49 MountNodeSocket* socket_node();
50
44 private: 51 private:
45 ScopedMount mount_; 52 ScopedMount mount_;
46 ScopedMountNode node_; 53 ScopedMountNode node_;
47 sdk_util::SimpleLock offs_lock_; 54 sdk_util::SimpleLock offs_lock_;
48 size_t offs_; 55 size_t offs_;
49 56
50 friend class KernelProxy; 57 friend class KernelProxy;
51 DISALLOW_COPY_AND_ASSIGN(KernelHandle); 58 DISALLOW_COPY_AND_ASSIGN(KernelHandle);
52 }; 59 };
53 60
54 typedef sdk_util::ScopedRef<KernelHandle> ScopedKernelHandle; 61 typedef sdk_util::ScopedRef<KernelHandle> ScopedKernelHandle;
55 62
56 } // namespace nacl_io 63 } // namespace nacl_io
57 64
58 #endif // LIBRARIES_NACL_IO_KERNEL_HANDLE_H_ 65 #endif // LIBRARIES_NACL_IO_KERNEL_HANDLE_H_
OLDNEW
« no previous file with comments | « native_client_sdk/src/build_tools/test_projects.py ('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