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/edk/embedder/embedder.h" | 5 #include "mojo/edk/embedder/embedder.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void ShutdownIPCSupport() { | 100 void ShutdownIPCSupport() { |
101 CHECK(internal::g_process_delegate); | 101 CHECK(internal::g_process_delegate); |
102 CHECK(internal::g_core); | 102 CHECK(internal::g_core); |
103 internal::g_core->RequestShutdown( | 103 internal::g_core->RequestShutdown( |
104 base::Bind(&ProcessDelegate::OnShutdownComplete, | 104 base::Bind(&ProcessDelegate::OnShutdownComplete, |
105 base::Unretained(internal::g_process_delegate))); | 105 base::Unretained(internal::g_process_delegate))); |
106 } | 106 } |
107 | 107 |
108 ScopedMessagePipeHandle CreateMessagePipe( | 108 ScopedMessagePipeHandle CreateMessagePipe( |
109 ScopedPlatformHandle platform_handle) { | 109 ScopedPlatformHandle platform_handle) { |
110 DCHECK(internal::g_core); | 110 NOTREACHED(); |
111 return internal::g_core->CreateMessagePipe(std::move(platform_handle)); | 111 return ScopedMessagePipeHandle(); |
112 } | 112 } |
113 | 113 |
114 void CreateMessagePipe( | 114 void CreateMessagePipe( |
115 ScopedPlatformHandle platform_handle, | 115 ScopedPlatformHandle platform_handle, |
116 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { | 116 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { |
117 DCHECK(internal::g_core); | 117 DCHECK(internal::g_core); |
118 callback.Run(CreateMessagePipe(std::move(platform_handle))); | 118 internal::g_core->CreateMessagePipe(std::move(platform_handle), callback); |
119 } | |
120 | |
121 ScopedMessagePipeHandle CreateParentMessagePipe(const std::string& token) { | |
122 DCHECK(internal::g_core); | |
123 return internal::g_core->CreateParentMessagePipe(token); | |
124 } | 119 } |
125 | 120 |
126 void CreateParentMessagePipe( | 121 void CreateParentMessagePipe( |
127 const std::string& token, | 122 const std::string& token, |
128 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { | 123 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { |
129 callback.Run(CreateParentMessagePipe(token)); | |
130 } | |
131 | |
132 ScopedMessagePipeHandle CreateChildMessagePipe(const std::string& token) { | |
133 DCHECK(internal::g_core); | 124 DCHECK(internal::g_core); |
134 return internal::g_core->CreateChildMessagePipe(token); | 125 internal::g_core->CreateParentMessagePipe(token, callback); |
135 } | 126 } |
136 | 127 |
137 void CreateChildMessagePipe( | 128 void CreateChildMessagePipe( |
138 const std::string& token, | 129 const std::string& token, |
139 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { | 130 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { |
140 callback.Run(CreateChildMessagePipe(token)); | 131 DCHECK(internal::g_core); |
| 132 internal::g_core->CreateChildMessagePipe(token, callback); |
141 } | 133 } |
142 | 134 |
143 std::string GenerateRandomToken() { | 135 std::string GenerateRandomToken() { |
144 char random_bytes[16]; | 136 char random_bytes[16]; |
145 crypto::RandBytes(random_bytes, 16); | 137 crypto::RandBytes(random_bytes, 16); |
146 return base::HexEncode(random_bytes, 16); | 138 return base::HexEncode(random_bytes, 16); |
147 } | 139 } |
148 | 140 |
149 } // namespace edk | 141 } // namespace edk |
150 } // namespace mojo | 142 } // namespace mojo |
OLD | NEW |