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

Side by Side Diff: third_party/mojo/src/mojo/edk/system/core.h

Issue 877993004: Revert "Update mojo sdk to rev 8d45c89c30b230843c5bd6dd0693a555750946c0" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 MOJO_EDK_SYSTEM_CORE_H_ 5 #ifndef MOJO_EDK_SYSTEM_CORE_H_
6 #define MOJO_EDK_SYSTEM_CORE_H_ 6 #define MOJO_EDK_SYSTEM_CORE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 21 matching lines...) Expand all
32 class Dispatcher; 32 class Dispatcher;
33 struct HandleSignalsState; 33 struct HandleSignalsState;
34 34
35 // |Core| is an object that implements the Mojo system calls. All public methods 35 // |Core| is an object that implements the Mojo system calls. All public methods
36 // are thread-safe. 36 // are thread-safe.
37 class MOJO_SYSTEM_IMPL_EXPORT Core { 37 class MOJO_SYSTEM_IMPL_EXPORT Core {
38 public: 38 public:
39 // --------------------------------------------------------------------------- 39 // ---------------------------------------------------------------------------
40 40
41 // These methods are only to be used by via the embedder API (and internally): 41 // These methods are only to be used by via the embedder API (and internally):
42 42 explicit Core(scoped_ptr<embedder::PlatformSupport> platform_support);
43 // |*platform_support| must outlive this object.
44 explicit Core(embedder::PlatformSupport* platform_support);
45 virtual ~Core(); 43 virtual ~Core();
46 44
47 // Adds |dispatcher| to the handle table, returning the handle for it. Returns 45 // Adds |dispatcher| to the handle table, returning the handle for it. Returns
48 // |MOJO_HANDLE_INVALID| on failure, namely if the handle table is full. 46 // |MOJO_HANDLE_INVALID| on failure, namely if the handle table is full.
49 MojoHandle AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher); 47 MojoHandle AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher);
50 48
51 // Looks up the dispatcher for the given handle. Returns null if the handle is 49 // Looks up the dispatcher for the given handle. Returns null if the handle is
52 // invalid. 50 // invalid.
53 scoped_refptr<Dispatcher> GetDispatcher(MojoHandle handle); 51 scoped_refptr<Dispatcher> GetDispatcher(MojoHandle handle);
54 52
55 // Watches on the given handle for the given signals, calling |callback| when 53 // Watches on the given handle for the given signals, calling |callback| when
56 // a signal is satisfied or when all signals become unsatisfiable. |callback| 54 // a signal is satisfied or when all signals become unsatisfiable. |callback|
57 // must satisfy stringent requirements -- see |Awakable::Awake()| in 55 // must satisfy stringent requirements -- see |Awakable::Awake()| in
58 // awakable.h. In particular, it must not call any Mojo system functions. 56 // awakable.h. In particular, it must not call any Mojo system functions.
59 MojoResult AsyncWait(MojoHandle handle, 57 MojoResult AsyncWait(MojoHandle handle,
60 MojoHandleSignals signals, 58 MojoHandleSignals signals,
61 base::Callback<void(MojoResult)> callback); 59 base::Callback<void(MojoResult)> callback);
62 60
63 embedder::PlatformSupport* platform_support() const { 61 embedder::PlatformSupport* platform_support() const {
64 return platform_support_; 62 return platform_support_.get();
65 } 63 }
66 64
67 // --------------------------------------------------------------------------- 65 // ---------------------------------------------------------------------------
68 66
69 // The following methods are essentially implementations of the Mojo Core 67 // System calls implementation:
70 // functions of the Mojo API, with the C interface translated to C++ by
71 // "mojo/edk/embedder/entrypoints.cc". The best way to understand the contract
72 // of these methods is to look at the header files defining the corresponding
73 // API functions, referenced below.
74
75 // These methods correspond to the API functions defined in
76 // "mojo/public/c/system/functions.h":
77 MojoTimeTicks GetTimeTicksNow(); 68 MojoTimeTicks GetTimeTicksNow();
78 MojoResult Close(MojoHandle handle); 69 MojoResult Close(MojoHandle handle);
79 MojoResult Wait(MojoHandle handle, 70 MojoResult Wait(MojoHandle handle,
80 MojoHandleSignals signals, 71 MojoHandleSignals signals,
81 MojoDeadline deadline, 72 MojoDeadline deadline,
82 UserPointer<MojoHandleSignalsState> signals_state); 73 UserPointer<MojoHandleSignalsState> signals_state);
83 MojoResult WaitMany(UserPointer<const MojoHandle> handles, 74 MojoResult WaitMany(UserPointer<const MojoHandle> handles,
84 UserPointer<const MojoHandleSignals> signals, 75 UserPointer<const MojoHandleSignals> signals,
85 uint32_t num_handles, 76 uint32_t num_handles,
86 MojoDeadline deadline, 77 MojoDeadline deadline,
87 UserPointer<uint32_t> result_index, 78 UserPointer<uint32_t> result_index,
88 UserPointer<MojoHandleSignalsState> signals_states); 79 UserPointer<MojoHandleSignalsState> signals_states);
89
90 // These methods correspond to the API functions defined in
91 // "mojo/public/c/system/message_pipe.h":
92 MojoResult CreateMessagePipe( 80 MojoResult CreateMessagePipe(
93 UserPointer<const MojoCreateMessagePipeOptions> options, 81 UserPointer<const MojoCreateMessagePipeOptions> options,
94 UserPointer<MojoHandle> message_pipe_handle0, 82 UserPointer<MojoHandle> message_pipe_handle0,
95 UserPointer<MojoHandle> message_pipe_handle1); 83 UserPointer<MojoHandle> message_pipe_handle1);
96 MojoResult WriteMessage(MojoHandle message_pipe_handle, 84 MojoResult WriteMessage(MojoHandle message_pipe_handle,
97 UserPointer<const void> bytes, 85 UserPointer<const void> bytes,
98 uint32_t num_bytes, 86 uint32_t num_bytes,
99 UserPointer<const MojoHandle> handles, 87 UserPointer<const MojoHandle> handles,
100 uint32_t num_handles, 88 uint32_t num_handles,
101 MojoWriteMessageFlags flags); 89 MojoWriteMessageFlags flags);
102 MojoResult ReadMessage(MojoHandle message_pipe_handle, 90 MojoResult ReadMessage(MojoHandle message_pipe_handle,
103 UserPointer<void> bytes, 91 UserPointer<void> bytes,
104 UserPointer<uint32_t> num_bytes, 92 UserPointer<uint32_t> num_bytes,
105 UserPointer<MojoHandle> handles, 93 UserPointer<MojoHandle> handles,
106 UserPointer<uint32_t> num_handles, 94 UserPointer<uint32_t> num_handles,
107 MojoReadMessageFlags flags); 95 MojoReadMessageFlags flags);
108
109 // These methods correspond to the API functions defined in
110 // "mojo/public/c/system/data_pipe.h":
111 MojoResult CreateDataPipe( 96 MojoResult CreateDataPipe(
112 UserPointer<const MojoCreateDataPipeOptions> options, 97 UserPointer<const MojoCreateDataPipeOptions> options,
113 UserPointer<MojoHandle> data_pipe_producer_handle, 98 UserPointer<MojoHandle> data_pipe_producer_handle,
114 UserPointer<MojoHandle> data_pipe_consumer_handle); 99 UserPointer<MojoHandle> data_pipe_consumer_handle);
115 MojoResult WriteData(MojoHandle data_pipe_producer_handle, 100 MojoResult WriteData(MojoHandle data_pipe_producer_handle,
116 UserPointer<const void> elements, 101 UserPointer<const void> elements,
117 UserPointer<uint32_t> num_bytes, 102 UserPointer<uint32_t> num_bytes,
118 MojoWriteDataFlags flags); 103 MojoWriteDataFlags flags);
119 MojoResult BeginWriteData(MojoHandle data_pipe_producer_handle, 104 MojoResult BeginWriteData(MojoHandle data_pipe_producer_handle,
120 UserPointer<void*> buffer, 105 UserPointer<void*> buffer,
121 UserPointer<uint32_t> buffer_num_bytes, 106 UserPointer<uint32_t> buffer_num_bytes,
122 MojoWriteDataFlags flags); 107 MojoWriteDataFlags flags);
123 MojoResult EndWriteData(MojoHandle data_pipe_producer_handle, 108 MojoResult EndWriteData(MojoHandle data_pipe_producer_handle,
124 uint32_t num_bytes_written); 109 uint32_t num_bytes_written);
125 MojoResult ReadData(MojoHandle data_pipe_consumer_handle, 110 MojoResult ReadData(MojoHandle data_pipe_consumer_handle,
126 UserPointer<void> elements, 111 UserPointer<void> elements,
127 UserPointer<uint32_t> num_bytes, 112 UserPointer<uint32_t> num_bytes,
128 MojoReadDataFlags flags); 113 MojoReadDataFlags flags);
129 MojoResult BeginReadData(MojoHandle data_pipe_consumer_handle, 114 MojoResult BeginReadData(MojoHandle data_pipe_consumer_handle,
130 UserPointer<const void*> buffer, 115 UserPointer<const void*> buffer,
131 UserPointer<uint32_t> buffer_num_bytes, 116 UserPointer<uint32_t> buffer_num_bytes,
132 MojoReadDataFlags flags); 117 MojoReadDataFlags flags);
133 MojoResult EndReadData(MojoHandle data_pipe_consumer_handle, 118 MojoResult EndReadData(MojoHandle data_pipe_consumer_handle,
134 uint32_t num_bytes_read); 119 uint32_t num_bytes_read);
135
136 // These methods correspond to the API functions defined in
137 // "mojo/public/c/system/buffer.h":
138 MojoResult CreateSharedBuffer( 120 MojoResult CreateSharedBuffer(
139 UserPointer<const MojoCreateSharedBufferOptions> options, 121 UserPointer<const MojoCreateSharedBufferOptions> options,
140 uint64_t num_bytes, 122 uint64_t num_bytes,
141 UserPointer<MojoHandle> shared_buffer_handle); 123 UserPointer<MojoHandle> shared_buffer_handle);
142 MojoResult DuplicateBufferHandle( 124 MojoResult DuplicateBufferHandle(
143 MojoHandle buffer_handle, 125 MojoHandle buffer_handle,
144 UserPointer<const MojoDuplicateBufferHandleOptions> options, 126 UserPointer<const MojoDuplicateBufferHandleOptions> options,
145 UserPointer<MojoHandle> new_buffer_handle); 127 UserPointer<MojoHandle> new_buffer_handle);
146 MojoResult MapBuffer(MojoHandle buffer_handle, 128 MojoResult MapBuffer(MojoHandle buffer_handle,
147 uint64_t offset, 129 uint64_t offset,
148 uint64_t num_bytes, 130 uint64_t num_bytes,
149 UserPointer<void*> buffer, 131 UserPointer<void*> buffer,
150 MojoMapBufferFlags flags); 132 MojoMapBufferFlags flags);
151 MojoResult UnmapBuffer(UserPointer<void> buffer); 133 MojoResult UnmapBuffer(UserPointer<void> buffer);
152 134
153 private: 135 private:
154 friend bool internal::ShutdownCheckNoLeaks(Core*); 136 friend bool internal::ShutdownCheckNoLeaks(Core*);
155 137
156 // Internal implementation of |Wait()| and |WaitMany()|; doesn't do basic 138 // Internal implementation of |Wait()| and |WaitMany()|; doesn't do basic
157 // validation of arguments. |*result_index| is only set if the result (whether 139 // validation of arguments. |*result_index| is only set if the result (whether
158 // success or failure) applies to a specific handle, so its value should be 140 // success or failure) applies to a specific handle, so its value should be
159 // preinitialized to |static_cast<uint32_t>(-1)|. 141 // preinitialized to |static_cast<uint32_t>(-1)|.
160 MojoResult WaitManyInternal(const MojoHandle* handles, 142 MojoResult WaitManyInternal(const MojoHandle* handles,
161 const MojoHandleSignals* signals, 143 const MojoHandleSignals* signals,
162 uint32_t num_handles, 144 uint32_t num_handles,
163 MojoDeadline deadline, 145 MojoDeadline deadline,
164 uint32_t* result_index, 146 uint32_t* result_index,
165 HandleSignalsState* signals_states); 147 HandleSignalsState* signals_states);
166 148
167 embedder::PlatformSupport* const platform_support_; 149 const scoped_ptr<embedder::PlatformSupport> platform_support_;
168 150
169 // TODO(vtl): |handle_table_lock_| should be a reader-writer lock (if only we 151 // TODO(vtl): |handle_table_lock_| should be a reader-writer lock (if only we
170 // had them). 152 // had them).
171 base::Lock handle_table_lock_; // Protects |handle_table_|. 153 base::Lock handle_table_lock_; // Protects |handle_table_|.
172 HandleTable handle_table_; 154 HandleTable handle_table_;
173 155
174 base::Lock mapping_table_lock_; // Protects |mapping_table_|. 156 base::Lock mapping_table_lock_; // Protects |mapping_table_|.
175 MappingTable mapping_table_; 157 MappingTable mapping_table_;
176 158
177 DISALLOW_COPY_AND_ASSIGN(Core); 159 DISALLOW_COPY_AND_ASSIGN(Core);
178 }; 160 };
179 161
180 } // namespace system 162 } // namespace system
181 } // namespace mojo 163 } // namespace mojo
182 164
183 #endif // MOJO_EDK_SYSTEM_CORE_H_ 165 #endif // MOJO_EDK_SYSTEM_CORE_H_
OLDNEW
« no previous file with comments | « third_party/mojo/src/mojo/edk/system/connection_manager_unittest.cc ('k') | third_party/mojo/src/mojo/edk/system/core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698