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

Side by Side Diff: mojo/edk/embedder/embedder.h

Issue 703273002: Update mojo sdk to rev 04a510fb37db10642e156957f9b2c11c2f6442ac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix content/child -> mojo/common linking Created 6 years, 1 month 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/embedder/channel_init.h ('k') | mojo/edk/embedder/embedder.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_EMBEDDER_EMBEDDER_H_ 5 #ifndef MOJO_EDK_EMBEDDER_EMBEDDER_H_
6 #define MOJO_EDK_EMBEDDER_EMBEDDER_H_ 6 #define MOJO_EDK_EMBEDDER_EMBEDDER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/task_runner.h" 11 #include "base/task_runner.h"
12 #include "mojo/edk/embedder/channel_info_forward.h"
12 #include "mojo/edk/embedder/scoped_platform_handle.h" 13 #include "mojo/edk/embedder/scoped_platform_handle.h"
13 #include "mojo/edk/system/system_impl_export.h" 14 #include "mojo/edk/system/system_impl_export.h"
14 #include "mojo/public/cpp/system/core.h" 15 #include "mojo/public/cpp/system/core.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 namespace embedder { 18 namespace embedder {
18 19
19 class PlatformSupport; 20 class PlatformSupport;
20 21
21 // Must be called first to initialize the (global, singleton) system. 22 // Must be called first to initialize the (global, singleton) system.
(...skipping 24 matching lines...) Expand all
46 // (E.g., a message written immediately to the returned handle will be queued 47 // (E.g., a message written immediately to the returned handle will be queued
47 // and the handle immediately closed, before the channel begins operation. In 48 // and the handle immediately closed, before the channel begins operation. In
48 // this case, the channel should connect as usual, send the queued message, and 49 // this case, the channel should connect as usual, send the queued message, and
49 // report that the handle was closed to the other side. The message sent may 50 // report that the handle was closed to the other side. The message sent may
50 // have other handles, so there may still be message pipes "on" this channel.) 51 // have other handles, so there may still be message pipes "on" this channel.)
51 // 52 //
52 // Both also produce a |ChannelInfo*| (a pointer to an opaque object) -- the 53 // Both also produce a |ChannelInfo*| (a pointer to an opaque object) -- the
53 // first synchronously and second asynchronously. 54 // first synchronously and second asynchronously.
54 // 55 //
55 // The destruction functions are similarly synchronous and asynchronous, 56 // The destruction functions are similarly synchronous and asynchronous,
56 // respectively, and take the |ChannelInfo*| produced by the creation function. 57 // respectively, and take the |ChannelInfo*| produced by the creation functions.
57 // (Note: One may call |DestroyChannelOnIOThread()| with the result of
58 // |CreateChannel()|, but not |DestroyChannel()| with the result of
59 // |CreateChannelOnIOThread()|.)
60 // 58 //
61 // TODO(vtl): Figure out channel teardown. 59 // TODO(vtl): Figure out channel teardown.
62 struct ChannelInfo;
63 60
64 // Creates a channel; must only be called from the I/O thread. |platform_handle| 61 // Creates a channel; must only be called from the I/O thread. |platform_handle|
65 // should be a handle to a connected OS "pipe". Eventually (even on failure), 62 // should be a handle to a connected OS "pipe". Eventually (even on failure),
66 // the "out" value |*channel_info| should be passed to 63 // the "out" value |*channel_info| should be passed to
67 // |DestroyChannelOnIOThread()| to tear down the channel. Returns a handle to 64 // |DestroyChannelOnIOThread()| (or |DestoryChannel()|) to tear down the
68 // the bootstrap message pipe. 65 // channel. Returns a handle to the bootstrap message pipe.
69 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle 66 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle
70 CreateChannelOnIOThread(ScopedPlatformHandle platform_handle, 67 CreateChannelOnIOThread(ScopedPlatformHandle platform_handle,
71 ChannelInfo** channel_info); 68 ChannelInfo** channel_info);
72 69
73 typedef base::Callback<void(ChannelInfo*)> DidCreateChannelCallback; 70 typedef base::Callback<void(ChannelInfo*)> DidCreateChannelCallback;
74 // Creates a channel asynchronously; may be called from any thread. 71 // Creates a channel asynchronously; may be called from any thread.
75 // |platform_handle| should be a handle to a connected OS "pipe". 72 // |platform_handle| should be a handle to a connected OS "pipe".
76 // |io_thread_task_runner| should be the |TaskRunner| for the I/O thread. 73 // |io_thread_task_runner| should be the |TaskRunner| for the I/O thread.
77 // |callback| should be the callback to call with the |ChannelInfo*|, which 74 // |callback| should be the callback to call with the |ChannelInfo*|, which
78 // should eventually be passed to |DestroyChannel()| (or 75 // should eventually be passed to |DestroyChannel()| (or
79 // |DestroyChannelOnIOThread()|) to tear down the channel; the callback will be 76 // |DestroyChannelOnIOThread()|) to tear down the channel; the callback will be
80 // called using |callback_thread_task_runner| if that is non-null, or otherwise 77 // called using |callback_thread_task_runner| if that is non-null, or otherwise
81 // it will be called using |io_thread_task_runner|. Returns a handle to the 78 // it will be called using |io_thread_task_runner|. Returns a handle to the
82 // bootstrap message pipe. 79 // bootstrap message pipe.
83 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle 80 MOJO_SYSTEM_IMPL_EXPORT ScopedMessagePipeHandle
84 CreateChannel(ScopedPlatformHandle platform_handle, 81 CreateChannel(ScopedPlatformHandle platform_handle,
85 scoped_refptr<base::TaskRunner> io_thread_task_runner, 82 scoped_refptr<base::TaskRunner> io_thread_task_runner,
86 DidCreateChannelCallback callback, 83 DidCreateChannelCallback callback,
87 scoped_refptr<base::TaskRunner> callback_thread_task_runner); 84 scoped_refptr<base::TaskRunner> callback_thread_task_runner);
88 85
89 // Destroys a channel that was created using either |CreateChannelOnIOThread()| 86 // Destroys a channel that was created using either |CreateChannelOnIOThread()|
90 // or |CreateChannel()|; must only be called from the I/O thread. |channel_info| 87 // or |CreateChannel()|; must only be called from the I/O thread. |channel_info|
91 // should be the "out" value from |CreateChannelOnIOThread()| or the value 88 // should be the "out" value from |CreateChannelOnIOThread()| or the value
92 // provided to the callback to |CreateChannel()|. 89 // provided to the callback to |CreateChannel()|.
93 MOJO_SYSTEM_IMPL_EXPORT void DestroyChannelOnIOThread( 90 MOJO_SYSTEM_IMPL_EXPORT void DestroyChannelOnIOThread(
94 ChannelInfo* channel_info); 91 ChannelInfo* channel_info);
95 92
96 // Destroys a channel (asynchronously) that was created using |CreateChannel()| 93 // Destroys a channel (asynchronously) that was created using |CreateChannel()|;
97 // (note: NOT |CreateChannelOnIOThread()|); may be called from any thread. 94 // may be called from any thread. |channel_info| should be the value provided to
98 // |channel_info| should be the value provided to the callback to 95 // the callback to |CreateChannel()|.
99 // |CreateChannel()|.
100 MOJO_SYSTEM_IMPL_EXPORT void DestroyChannel(ChannelInfo* channel_info); 96 MOJO_SYSTEM_IMPL_EXPORT void DestroyChannel(ChannelInfo* channel_info);
101 97
102 // Inform the channel that it will soon be destroyed (doing so is optional). 98 // Inform the channel that it will soon be destroyed (doing so is optional).
103 // This may be called from any thread, but the caller must ensure that this is 99 // This may be called from any thread, but the caller must ensure that this is
104 // called before |DestroyChannel()| or |DestroyChannelOnIOThread()|. 100 // called before |DestroyChannel()| or |DestroyChannelOnIOThread()|.
105 MOJO_SYSTEM_IMPL_EXPORT void WillDestroyChannelSoon(ChannelInfo* channel_info); 101 MOJO_SYSTEM_IMPL_EXPORT void WillDestroyChannelSoon(ChannelInfo* channel_info);
106 102
107 // Creates a |MojoHandle| that wraps the given |PlatformHandle| (taking 103 // Creates a |MojoHandle| that wraps the given |PlatformHandle| (taking
108 // ownership of it). This |MojoHandle| can then, e.g., be passed through message 104 // ownership of it). This |MojoHandle| can then, e.g., be passed through message
109 // pipes. Note: This takes ownership (and thus closes) |platform_handle| even on 105 // pipes. Note: This takes ownership (and thus closes) |platform_handle| even on
110 // failure, which is different from what you'd expect from a Mojo API, but it 106 // failure, which is different from what you'd expect from a Mojo API, but it
111 // makes for a more convenient embedder API. 107 // makes for a more convenient embedder API.
112 MOJO_SYSTEM_IMPL_EXPORT MojoResult 108 MOJO_SYSTEM_IMPL_EXPORT MojoResult
113 CreatePlatformHandleWrapper(ScopedPlatformHandle platform_handle, 109 CreatePlatformHandleWrapper(ScopedPlatformHandle platform_handle,
114 MojoHandle* platform_handle_wrapper_handle); 110 MojoHandle* platform_handle_wrapper_handle);
115 // Retrieves the |PlatformHandle| that was wrapped into a |MojoHandle| (using 111 // Retrieves the |PlatformHandle| that was wrapped into a |MojoHandle| (using
116 // |CreatePlatformHandleWrapper()| above). Note that the |MojoHandle| must still 112 // |CreatePlatformHandleWrapper()| above). Note that the |MojoHandle| must still
117 // be closed separately. 113 // be closed separately.
118 MOJO_SYSTEM_IMPL_EXPORT MojoResult 114 MOJO_SYSTEM_IMPL_EXPORT MojoResult
119 PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle, 115 PassWrappedPlatformHandle(MojoHandle platform_handle_wrapper_handle,
120 ScopedPlatformHandle* platform_handle); 116 ScopedPlatformHandle* platform_handle);
121 117
122 } // namespace embedder 118 } // namespace embedder
123 } // namespace mojo 119 } // namespace mojo
124 120
125 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_ 121 #endif // MOJO_EDK_EMBEDDER_EMBEDDER_H_
OLDNEW
« no previous file with comments | « mojo/edk/embedder/channel_init.h ('k') | mojo/edk/embedder/embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698