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

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

Issue 1949283002: EDK: Replace HandleTable::GetAndRemoveDispatcher() with GetAndRemoveHandle(). (Closed) Base URL: https://github.com/domokit/mojo.git@work789_edk_handle_13.3-x-work788_edk_handle_13.2
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | mojo/edk/system/core.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <functional> 10 #include <functional>
(...skipping 19 matching lines...) Expand all
30 class PlatformSupport; 30 class PlatformSupport;
31 } 31 }
32 32
33 namespace system { 33 namespace system {
34 34
35 class Dispatcher; 35 class Dispatcher;
36 struct HandleSignalsState; 36 struct HandleSignalsState;
37 37
38 // |Core| is an object that implements the Mojo system calls. All public methods 38 // |Core| is an object that implements the Mojo system calls. All public methods
39 // are thread-safe. 39 // are thread-safe.
40 //
41 // Convention: |MojoHandle|s are referred to as |handle| or |foo_handle|,
42 // whereas |Handle|s are just |h|.
40 class Core { 43 class Core {
41 public: 44 public:
42 // --------------------------------------------------------------------------- 45 // ---------------------------------------------------------------------------
43 46
44 // These methods are only to be used by via the embedder API (and internally): 47 // These methods are only to be used by via the embedder API (and internally):
45 48
46 // |*platform_support| must outlive this object. 49 // |*platform_support| must outlive this object.
47 explicit Core(embedder::PlatformSupport* platform_support); 50 explicit Core(embedder::PlatformSupport* platform_support);
48 virtual ~Core(); 51 virtual ~Core();
49 52
50 // Adds |handle| (which must have a dispatcher) to the handle table, returning 53 // Adds |handle| (which must have a dispatcher) to the handle table, returning
51 // the handle value for it. Returns |MOJO_HANDLE_INVALID| on failure, namely 54 // the handle value for it. Returns |MOJO_HANDLE_INVALID| on failure, namely
52 // if the handle table is full. 55 // if the handle table is full.
53 MojoHandle AddHandle(Handle&& handle); 56 MojoHandle AddHandle(Handle&& h);
54 57
55 // Looks up the dispatcher for the given handle value. On success, gets the 58 // Looks up the dispatcher for the given handle value. On success, gets the
56 // dispatcher for a given handle value. On failure, returns an appropriate 59 // dispatcher for a given handle value. On failure, returns an appropriate
57 // result and leaves |dispatcher| alone), namely 60 // result and leaves |dispatcher| alone), namely
58 // |MOJO_RESULT_INVALID_ARGUMENT| if the handle value is invalid or 61 // |MOJO_RESULT_INVALID_ARGUMENT| if the handle value is invalid or
59 // |MOJO_RESULT_BUSY| if the handle is marked as busy. 62 // |MOJO_RESULT_BUSY| if the handle is marked as busy.
60 MojoResult GetDispatcher(MojoHandle handle_value, 63 MojoResult GetDispatcher(MojoHandle handle,
61 util::RefPtr<Dispatcher>* dispatcher); 64 util::RefPtr<Dispatcher>* dispatcher);
62 65
63 // Like |GetDispatcher()|, but on success also removes the handle from the 66 // Like |GetDispatcher()|, but on success also removes the handle from the
64 // handle table. 67 // handle table.
65 MojoResult GetAndRemoveDispatcher(MojoHandle handle_value, 68 MojoResult GetAndRemoveDispatcher(MojoHandle handle,
66 util::RefPtr<Dispatcher>* dispatcher); 69 util::RefPtr<Dispatcher>* dispatcher);
67 70
68 // Watches on the given handle for the given signals, calling |callback| when 71 // Watches on the given handle for the given signals, calling |callback| when
69 // a signal is satisfied or when all signals become unsatisfiable. |callback| 72 // a signal is satisfied or when all signals become unsatisfiable. |callback|
70 // must satisfy stringent requirements -- see |Awakable::Awake()| in 73 // must satisfy stringent requirements -- see |Awakable::Awake()| in
71 // awakable.h. In particular, it must not call any Mojo system functions. 74 // awakable.h. In particular, it must not call any Mojo system functions.
72 MojoResult AsyncWait(MojoHandle handle, 75 MojoResult AsyncWait(MojoHandle handle,
73 MojoHandleSignals signals, 76 MojoHandleSignals signals,
74 const std::function<void(MojoResult)>& callback); 77 const std::function<void(MojoResult)>& callback);
75 78
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 util::Mutex mapping_table_mutex_; 214 util::Mutex mapping_table_mutex_;
212 MappingTable mapping_table_ MOJO_GUARDED_BY(mapping_table_mutex_); 215 MappingTable mapping_table_ MOJO_GUARDED_BY(mapping_table_mutex_);
213 216
214 MOJO_DISALLOW_COPY_AND_ASSIGN(Core); 217 MOJO_DISALLOW_COPY_AND_ASSIGN(Core);
215 }; 218 };
216 219
217 } // namespace system 220 } // namespace system
218 } // namespace mojo 221 } // namespace mojo
219 222
220 #endif // MOJO_EDK_SYSTEM_CORE_H_ 223 #endif // MOJO_EDK_SYSTEM_CORE_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/edk/system/core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698