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

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

Issue 23498015: [NaCl SDK] Support non blocking TCP/UDP (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove event friends, rename EventListenerPoll Created 7 years, 3 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_MOUNT_NODE_H_ 5 #ifndef LIBRARIES_NACL_IO_MOUNT_NODE_H_
6 #define LIBRARIES_NACL_IO_MOUNT_NODE_H_ 6 #define LIBRARIES_NACL_IO_MOUNT_NODE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "nacl_io/error.h" 10 #include "nacl_io/error.h"
11 #include "nacl_io/event_listener.h" 11 #include "nacl_io/event_listener.h"
12 #include "nacl_io/osdirent.h" 12 #include "nacl_io/osdirent.h"
13 #include "nacl_io/osstat.h" 13 #include "nacl_io/osstat.h"
14 #include "nacl_io/ostermios.h" 14 #include "nacl_io/ostermios.h"
15 15
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 Mount; 22 class Mount;
23 class MountNode; 23 class MountNode;
24 24
25 typedef sdk_util::ScopedRef<MountNode> ScopedMountNode; 25 typedef sdk_util::ScopedRef<MountNode> ScopedMountNode;
26 26
27 // NOTE: The KernelProxy is the only class that should be setting errno. All 27 // NOTE: The KernelProxy is the only class that should be setting errno. All
28 // other classes should return Error (as defined by nacl_io/error.h). 28 // other classes should return Error (as defined by nacl_io/error.h).
29 class MountNode : public EventListener { 29 class MountNode : public sdk_util::RefObject {
30 protected: 30 protected:
31 explicit MountNode(Mount* mount); 31 explicit MountNode(Mount* mount);
32 virtual ~MountNode(); 32 virtual ~MountNode();
33 33
34 protected: 34 protected:
35 // Initialize with node specific flags, in this case stat permissions. 35 // Initialize with node specific flags, in this case stat permissions.
36 virtual Error Init(int flags); 36 virtual Error Init(int flags);
37 virtual void Destroy(); 37 virtual void Destroy();
38 38
39 public: 39 public:
40 // Declared in EventEmitter. defaults to signalled. 40 // Returns the emitter for this Node if it has one, if not, assume this
41 // object can not block.
42 virtual EventEmitter* GetEventEmitter();
41 virtual uint32_t GetEventStatus(); 43 virtual uint32_t GetEventStatus();
42 44
43 // Normal OS operations on a node (file), can be called by the kernel 45 // Normal OS operations on a node (file), can be called by the kernel
44 // directly so it must lock and unlock appropriately. These functions 46 // directly so it must lock and unlock appropriately. These functions
45 // must not be called by the mount. 47 // must not be called by the mount.
46 virtual Error FSync(); 48 virtual Error FSync();
47 // It is expected that the derived MountNode will fill with 0 when growing 49 // It is expected that the derived MountNode will fill with 0 when growing
48 // the file. 50 // the file.
49 virtual Error FTruncate(off_t length); 51 virtual Error FTruncate(off_t length);
50 // Assume that |out_bytes| is non-NULL. 52 // Assume that |out_bytes| is non-NULL.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 102
101 // Find a child and return it without updating the refcount 103 // Find a child and return it without updating the refcount
102 // Assumes that |out_node| is non-NULL. 104 // Assumes that |out_node| is non-NULL.
103 virtual Error FindChild(const std::string& name, ScopedMountNode* out_node); 105 virtual Error FindChild(const std::string& name, ScopedMountNode* out_node);
104 106
105 // Update the link count 107 // Update the link count
106 virtual void Link(); 108 virtual void Link();
107 virtual void Unlink(); 109 virtual void Unlink();
108 110
109 protected: 111 protected:
112 uint32_t state_;
binji 2013/09/12 01:47:57 describe? state_ is pretty generic.
noelallen1 2013/09/12 23:19:03 Done.
110 struct stat stat_; 113 struct stat stat_;
111 sdk_util::SimpleLock node_lock_; 114 sdk_util::SimpleLock node_lock_;
112 115
113 // We use a pointer directly to avoid cycles in the ref count. 116 // We use a pointer directly to avoid cycles in the ref count.
114 // TODO(noelallen) We should change this so it's unnecessary for the node 117 // TODO(noelallen) We should change this so it's unnecessary for the node
115 // to track it's parent. When a node is unlinked, the mount should do 118 // to track it's parent. When a node is unlinked, the mount should do
116 // any cleanup it needs. 119 // any cleanup it needs.
117 Mount* mount_; 120 Mount* mount_;
118 121
119 friend class Mount; 122 friend class Mount;
120 friend class MountDev; 123 friend class MountDev;
121 friend class MountHtml5Fs; 124 friend class MountHtml5Fs;
122 friend class MountHttp; 125 friend class MountHttp;
123 friend class MountMem; 126 friend class MountMem;
124 friend class MountNodeDir; 127 friend class MountNodeDir;
125 }; 128 };
126 129
127 } // namespace nacl_io 130 } // namespace nacl_io
128 131
129 #endif // LIBRARIES_NACL_IO_MOUNT_NODE_H_ 132 #endif // LIBRARIES_NACL_IO_MOUNT_NODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698