| OLD | NEW |
| 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" |
| 11 #include "mojo/edk/system/handle_table.h" | 11 #include "mojo/edk/system/handle_table.h" |
| 12 #include "mojo/edk/system/mapping_table.h" | 12 #include "mojo/edk/system/mapping_table.h" |
| 13 #include "mojo/edk/system/memory.h" | 13 #include "mojo/edk/system/memory.h" |
| 14 #include "mojo/edk/system/mutex.h" | 14 #include "mojo/edk/system/mutex.h" |
| 15 #include "mojo/edk/system/ref_ptr.h" | 15 #include "mojo/edk/util/ref_ptr.h" |
| 16 #include "mojo/public/c/system/buffer.h" | 16 #include "mojo/public/c/system/buffer.h" |
| 17 #include "mojo/public/c/system/data_pipe.h" | 17 #include "mojo/public/c/system/data_pipe.h" |
| 18 #include "mojo/public/c/system/message_pipe.h" | 18 #include "mojo/public/c/system/message_pipe.h" |
| 19 #include "mojo/public/c/system/types.h" | 19 #include "mojo/public/c/system/types.h" |
| 20 #include "mojo/public/cpp/system/macros.h" | 20 #include "mojo/public/cpp/system/macros.h" |
| 21 | 21 |
| 22 namespace mojo { | 22 namespace mojo { |
| 23 | 23 |
| 24 namespace embedder { | 24 namespace embedder { |
| 25 class PlatformSupport; | 25 class PlatformSupport; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 41 // |*platform_support| must outlive this object. | 41 // |*platform_support| must outlive this object. |
| 42 explicit Core(embedder::PlatformSupport* platform_support); | 42 explicit Core(embedder::PlatformSupport* platform_support); |
| 43 virtual ~Core(); | 43 virtual ~Core(); |
| 44 | 44 |
| 45 // 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 |
| 46 // |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. |
| 47 MojoHandle AddDispatcher(Dispatcher* dispatcher); | 47 MojoHandle AddDispatcher(Dispatcher* dispatcher); |
| 48 | 48 |
| 49 // 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 |
| 50 // invalid. | 50 // invalid. |
| 51 RefPtr<Dispatcher> GetDispatcher(MojoHandle handle); | 51 util::RefPtr<Dispatcher> GetDispatcher(MojoHandle handle); |
| 52 | 52 |
| 53 // Like |GetDispatcher()|, but also removes the handle from the handle table. | 53 // Like |GetDispatcher()|, but also removes the handle from the handle table. |
| 54 // On success, gets the dispatcher for a given handle (which should not be | 54 // On success, gets the dispatcher for a given handle (which should not be |
| 55 // |MOJO_HANDLE_INVALID|) and removes it. (On failure, returns an appropriate | 55 // |MOJO_HANDLE_INVALID|) and removes it. (On failure, returns an appropriate |
| 56 // result (and leaves |dispatcher| alone), namely | 56 // result (and leaves |dispatcher| alone), namely |
| 57 // |MOJO_RESULT_INVALID_ARGUMENT| if there's no dispatcher for the given | 57 // |MOJO_RESULT_INVALID_ARGUMENT| if there's no dispatcher for the given |
| 58 // handle or |MOJO_RESULT_BUSY| if the handle is marked as busy.) | 58 // handle or |MOJO_RESULT_BUSY| if the handle is marked as busy.) |
| 59 MojoResult GetAndRemoveDispatcher(MojoHandle handle, | 59 MojoResult GetAndRemoveDispatcher(MojoHandle handle, |
| 60 RefPtr<Dispatcher>* dispatcher); | 60 util::RefPtr<Dispatcher>* dispatcher); |
| 61 | 61 |
| 62 // Watches on the given handle for the given signals, calling |callback| when | 62 // Watches on the given handle for the given signals, calling |callback| when |
| 63 // a signal is satisfied or when all signals become unsatisfiable. |callback| | 63 // a signal is satisfied or when all signals become unsatisfiable. |callback| |
| 64 // must satisfy stringent requirements -- see |Awakable::Awake()| in | 64 // must satisfy stringent requirements -- see |Awakable::Awake()| in |
| 65 // awakable.h. In particular, it must not call any Mojo system functions. | 65 // awakable.h. In particular, it must not call any Mojo system functions. |
| 66 MojoResult AsyncWait(MojoHandle handle, | 66 MojoResult AsyncWait(MojoHandle handle, |
| 67 MojoHandleSignals signals, | 67 MojoHandleSignals signals, |
| 68 const base::Callback<void(MojoResult)>& callback); | 68 const base::Callback<void(MojoResult)>& callback); |
| 69 | 69 |
| 70 embedder::PlatformSupport* platform_support() const { | 70 embedder::PlatformSupport* platform_support() const { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 Mutex mapping_table_mutex_; | 181 Mutex mapping_table_mutex_; |
| 182 MappingTable mapping_table_ MOJO_GUARDED_BY(mapping_table_mutex_); | 182 MappingTable mapping_table_ MOJO_GUARDED_BY(mapping_table_mutex_); |
| 183 | 183 |
| 184 MOJO_DISALLOW_COPY_AND_ASSIGN(Core); | 184 MOJO_DISALLOW_COPY_AND_ASSIGN(Core); |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 } // namespace system | 187 } // namespace system |
| 188 } // namespace mojo | 188 } // namespace mojo |
| 189 | 189 |
| 190 #endif // MOJO_EDK_SYSTEM_CORE_H_ | 190 #endif // MOJO_EDK_SYSTEM_CORE_H_ |
| OLD | NEW |