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

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

Issue 898623002: Make mojo::system::Core not own the PlatformSupport. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: foo 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
« no previous file with comments | « mojo/edk/system/channel.h ('k') | 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 "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 explicit Core(scoped_ptr<embedder::PlatformSupport> platform_support); 42
43 // |*platform_support| must outlive this object.
44 explicit Core(embedder::PlatformSupport* platform_support);
43 virtual ~Core(); 45 virtual ~Core();
44 46
45 // Adds |dispatcher| to the handle table, returning the handle for it. Returns 47 // Adds |dispatcher| to the handle table, returning the handle for it. Returns
46 // |MOJO_HANDLE_INVALID| on failure, namely if the handle table is full. 48 // |MOJO_HANDLE_INVALID| on failure, namely if the handle table is full.
47 MojoHandle AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher); 49 MojoHandle AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher);
48 50
49 // Looks up the dispatcher for the given handle. Returns null if the handle is 51 // Looks up the dispatcher for the given handle. Returns null if the handle is
50 // invalid. 52 // invalid.
51 scoped_refptr<Dispatcher> GetDispatcher(MojoHandle handle); 53 scoped_refptr<Dispatcher> GetDispatcher(MojoHandle handle);
52 54
53 // Watches on the given handle for the given signals, calling |callback| when 55 // Watches on the given handle for the given signals, calling |callback| when
54 // a signal is satisfied or when all signals become unsatisfiable. |callback| 56 // a signal is satisfied or when all signals become unsatisfiable. |callback|
55 // must satisfy stringent requirements -- see |Awakable::Awake()| in 57 // must satisfy stringent requirements -- see |Awakable::Awake()| in
56 // awakable.h. In particular, it must not call any Mojo system functions. 58 // awakable.h. In particular, it must not call any Mojo system functions.
57 MojoResult AsyncWait(MojoHandle handle, 59 MojoResult AsyncWait(MojoHandle handle,
58 MojoHandleSignals signals, 60 MojoHandleSignals signals,
59 base::Callback<void(MojoResult)> callback); 61 base::Callback<void(MojoResult)> callback);
60 62
61 embedder::PlatformSupport* platform_support() const { 63 embedder::PlatformSupport* platform_support() const {
62 return platform_support_.get(); 64 return platform_support_;
63 } 65 }
64 66
65 // --------------------------------------------------------------------------- 67 // ---------------------------------------------------------------------------
66 68
67 // The following methods are essentially implementations of the Mojo Core 69 // The following methods are essentially implementations of the Mojo Core
68 // functions of the Mojo API, with the C interface translated to C++ by 70 // functions of the Mojo API, with the C interface translated to C++ by
69 // "mojo/edk/embedder/entrypoints.cc". The best way to understand the contract 71 // "mojo/edk/embedder/entrypoints.cc". The best way to understand the contract
70 // of these methods is to look at the header files defining the corresponding 72 // of these methods is to look at the header files defining the corresponding
71 // API functions, referenced below. 73 // API functions, referenced below.
72 74
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // validation of arguments. |*result_index| is only set if the result (whether 157 // validation of arguments. |*result_index| is only set if the result (whether
156 // success or failure) applies to a specific handle, so its value should be 158 // success or failure) applies to a specific handle, so its value should be
157 // preinitialized to |static_cast<uint32_t>(-1)|. 159 // preinitialized to |static_cast<uint32_t>(-1)|.
158 MojoResult WaitManyInternal(const MojoHandle* handles, 160 MojoResult WaitManyInternal(const MojoHandle* handles,
159 const MojoHandleSignals* signals, 161 const MojoHandleSignals* signals,
160 uint32_t num_handles, 162 uint32_t num_handles,
161 MojoDeadline deadline, 163 MojoDeadline deadline,
162 uint32_t* result_index, 164 uint32_t* result_index,
163 HandleSignalsState* signals_states); 165 HandleSignalsState* signals_states);
164 166
165 const scoped_ptr<embedder::PlatformSupport> platform_support_; 167 embedder::PlatformSupport* const platform_support_;
166 168
167 // TODO(vtl): |handle_table_lock_| should be a reader-writer lock (if only we 169 // TODO(vtl): |handle_table_lock_| should be a reader-writer lock (if only we
168 // had them). 170 // had them).
169 base::Lock handle_table_lock_; // Protects |handle_table_|. 171 base::Lock handle_table_lock_; // Protects |handle_table_|.
170 HandleTable handle_table_; 172 HandleTable handle_table_;
171 173
172 base::Lock mapping_table_lock_; // Protects |mapping_table_|. 174 base::Lock mapping_table_lock_; // Protects |mapping_table_|.
173 MappingTable mapping_table_; 175 MappingTable mapping_table_;
174 176
175 DISALLOW_COPY_AND_ASSIGN(Core); 177 DISALLOW_COPY_AND_ASSIGN(Core);
176 }; 178 };
177 179
178 } // namespace system 180 } // namespace system
179 } // namespace mojo 181 } // namespace mojo
180 182
181 #endif // MOJO_EDK_SYSTEM_CORE_H_ 183 #endif // MOJO_EDK_SYSTEM_CORE_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/channel.h ('k') | mojo/edk/system/core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698