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

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

Issue 303223007: [NaCl SDK] nacl_io: Run clang-format over nacl_io sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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_OBJECT_H_ 5 #ifndef LIBRARIES_NACL_IO_KERNEL_OBJECT_H_
6 #define LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ 6 #define LIBRARIES_NACL_IO_KERNEL_OBJECT_H_
7 7
8 #include <pthread.h> 8 #include <pthread.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 15 matching lines...) Expand all
26 // objects such as the CWD, mount points, file descriptors and file handles. 26 // objects such as the CWD, mount points, file descriptors and file handles.
27 // All Kernel locks are private to ensure the lock order. 27 // All Kernel locks are private to ensure the lock order.
28 // 28 //
29 // All calls are assumed to be a relative path. 29 // All calls are assumed to be a relative path.
30 class KernelObject { 30 class KernelObject {
31 public: 31 public:
32 struct Descriptor_t { 32 struct Descriptor_t {
33 Descriptor_t() : flags(0) {} 33 Descriptor_t() : flags(0) {}
34 explicit Descriptor_t(const ScopedKernelHandle& h, 34 explicit Descriptor_t(const ScopedKernelHandle& h,
35 const std::string& open_path) 35 const std::string& open_path)
36 : handle(h), flags(0), path(open_path) {} 36 : handle(h), flags(0), path(open_path) {}
37 37
38 ScopedKernelHandle handle; 38 ScopedKernelHandle handle;
39 int flags; 39 int flags;
40 std::string path; 40 std::string path;
41 }; 41 };
42 typedef std::vector<Descriptor_t> HandleMap_t; 42 typedef std::vector<Descriptor_t> HandleMap_t;
43 typedef std::map<std::string, ScopedFilesystem> FsMap_t; 43 typedef std::map<std::string, ScopedFilesystem> FsMap_t;
44 44
45 KernelObject(); 45 KernelObject();
46 virtual ~KernelObject(); 46 virtual ~KernelObject();
(...skipping 20 matching lines...) Expand all
67 ScopedNode* out_node); 67 ScopedNode* out_node);
68 68
69 // Get FD-specific flags (currently only FD_CLOEXEC is supported). 69 // Get FD-specific flags (currently only FD_CLOEXEC is supported).
70 Error GetFDFlags(int fd, int* out_flags); 70 Error GetFDFlags(int fd, int* out_flags);
71 // Set FD-specific flags (currently only FD_CLOEXEC is supported). 71 // Set FD-specific flags (currently only FD_CLOEXEC is supported).
72 Error SetFDFlags(int fd, int flags); 72 Error SetFDFlags(int fd, int flags);
73 73
74 // Convert from FD to KernelHandle, and acquire the handle. 74 // Convert from FD to KernelHandle, and acquire the handle.
75 // Assumes |out_handle| is non-NULL. 75 // Assumes |out_handle| is non-NULL.
76 Error AcquireHandle(int fd, ScopedKernelHandle* out_handle); 76 Error AcquireHandle(int fd, ScopedKernelHandle* out_handle);
77 Error AcquireHandleAndPath(int fd, ScopedKernelHandle *out_handle, 77 Error AcquireHandleAndPath(int fd,
78 ScopedKernelHandle* out_handle,
78 std::string* out_path); 79 std::string* out_path);
79 80
80 // Allocate a new fd and assign the handle to it, while 81 // Allocate a new fd and assign the handle to it, while
81 // ref counting the handle and associated filesystem. 82 // ref counting the handle and associated filesystem.
82 // Assumes |handle| is non-NULL; 83 // Assumes |handle| is non-NULL;
83 int AllocateFD(const ScopedKernelHandle& handle, 84 int AllocateFD(const ScopedKernelHandle& handle,
84 const std::string& path=std::string()); 85 const std::string& path = std::string());
85 86
86 // Assumes |handle| is non-NULL; 87 // Assumes |handle| is non-NULL;
87 void FreeAndReassignFD(int fd, const ScopedKernelHandle& handle, 88 void FreeAndReassignFD(int fd,
89 const ScopedKernelHandle& handle,
88 const std::string& path); 90 const std::string& path);
89 void FreeFD(int fd); 91 void FreeFD(int fd);
90 92
91 // Returns or sets CWD 93 // Returns or sets CWD
92 std::string GetCWD(); 94 std::string GetCWD();
93 Error SetCWD(const std::string& path); 95 Error SetCWD(const std::string& path);
94 96
95 // Returns parts of the absolute path for the given relative path 97 // Returns parts of the absolute path for the given relative path
96 Path GetAbsParts(const std::string& path); 98 Path GetAbsParts(const std::string& path);
97 99
(...skipping 11 matching lines...) Expand all
109 111
110 // Lock to protect cwd_. 112 // Lock to protect cwd_.
111 sdk_util::SimpleLock cwd_lock_; 113 sdk_util::SimpleLock cwd_lock_;
112 114
113 DISALLOW_COPY_AND_ASSIGN(KernelObject); 115 DISALLOW_COPY_AND_ASSIGN(KernelObject);
114 }; 116 };
115 117
116 } // namespace nacl_io 118 } // namespace nacl_io
117 119
118 #endif // LIBRARIES_NACL_IO_KERNEL_OBJECT_H_ 120 #endif // LIBRARIES_NACL_IO_KERNEL_OBJECT_H_
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/kernel_intercept.cc ('k') | native_client_sdk/src/libraries/nacl_io/kernel_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698