OLD | NEW |
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 #include "mojo/embedder/embedder.h" | 5 #include "mojo/embedder/embedder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 callback.Run(channel_info.release()); | 90 callback.Run(channel_info.release()); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 void Init() { | 96 void Init() { |
97 system::entrypoints::SetCore(new system::Core()); | 97 system::entrypoints::SetCore(new system::Core()); |
98 } | 98 } |
99 | 99 |
| 100 void InitIfNeeded() { |
| 101 if (!system::entrypoints::GetCore()) |
| 102 system::entrypoints::SetCore(new system::Core()); |
| 103 } |
| 104 |
100 ScopedMessagePipeHandle CreateChannel( | 105 ScopedMessagePipeHandle CreateChannel( |
101 ScopedPlatformHandle platform_handle, | 106 ScopedPlatformHandle platform_handle, |
102 scoped_refptr<base::TaskRunner> io_thread_task_runner, | 107 scoped_refptr<base::TaskRunner> io_thread_task_runner, |
103 DidCreateChannelCallback callback, | 108 DidCreateChannelCallback callback, |
104 scoped_refptr<base::TaskRunner> callback_thread_task_runner) { | 109 scoped_refptr<base::TaskRunner> callback_thread_task_runner) { |
105 DCHECK(platform_handle.is_valid()); | 110 DCHECK(platform_handle.is_valid()); |
106 | 111 |
107 std::pair<scoped_refptr<system::MessagePipeDispatcher>, | 112 std::pair<scoped_refptr<system::MessagePipeDispatcher>, |
108 scoped_refptr<system::MessagePipe> > remote_message_pipe = | 113 scoped_refptr<system::MessagePipe> > remote_message_pipe = |
109 system::MessagePipeDispatcher::CreateRemoteMessagePipe(); | 114 system::MessagePipeDispatcher::CreateRemoteMessagePipe(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 if (dispatcher->GetType() != system::Dispatcher::kTypePlatformHandle) | 175 if (dispatcher->GetType() != system::Dispatcher::kTypePlatformHandle) |
171 return MOJO_RESULT_INVALID_ARGUMENT; | 176 return MOJO_RESULT_INVALID_ARGUMENT; |
172 | 177 |
173 *platform_handle = static_cast<system::PlatformHandleDispatcher*>( | 178 *platform_handle = static_cast<system::PlatformHandleDispatcher*>( |
174 dispatcher.get())->PassPlatformHandle().Pass(); | 179 dispatcher.get())->PassPlatformHandle().Pass(); |
175 return MOJO_RESULT_OK; | 180 return MOJO_RESULT_OK; |
176 } | 181 } |
177 | 182 |
178 } // namespace embedder | 183 } // namespace embedder |
179 } // namespace mojo | 184 } // namespace mojo |
OLD | NEW |