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

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

Issue 1412283002: Convert mojo::system::Dispatcher to use our new refcounting stuff (instead of base's). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: no change Created 5 years, 2 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_manager_unittest.cc ('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"
11 #include "base/memory/ref_counted.h"
12 #include "mojo/edk/system/handle_table.h" 11 #include "mojo/edk/system/handle_table.h"
13 #include "mojo/edk/system/mapping_table.h" 12 #include "mojo/edk/system/mapping_table.h"
14 #include "mojo/edk/system/memory.h" 13 #include "mojo/edk/system/memory.h"
15 #include "mojo/edk/system/mutex.h" 14 #include "mojo/edk/system/mutex.h"
15 #include "mojo/edk/system/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 11 matching lines...) Expand all
37 // --------------------------------------------------------------------------- 37 // ---------------------------------------------------------------------------
38 38
39 // These methods are only to be used by via the embedder API (and internally): 39 // These methods are only to be used by via the embedder API (and internally):
40 40
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(const scoped_refptr<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 scoped_refptr<Dispatcher> GetDispatcher(MojoHandle handle); 51 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 scoped_refptr<Dispatcher>* dispatcher); 60 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
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_
OLDNEW
« no previous file with comments | « mojo/edk/system/channel_manager_unittest.cc ('k') | mojo/edk/system/core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698