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 NOTREACHED(); | 110 DCHECK(internal::g_core); |
111 return ScopedMessagePipeHandle(); | 111 return internal::g_core->CreateMessagePipe(std::move(platform_handle)); |
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 internal::g_core->CreateMessagePipe(std::move(platform_handle), callback); | 118 callback.Run(CreateMessagePipe(std::move(platform_handle))); |
| 119 } |
| 120 |
| 121 ScopedMessagePipeHandle CreateParentMessagePipe(const std::string& token) { |
| 122 DCHECK(internal::g_core); |
| 123 return internal::g_core->CreateParentMessagePipe(token); |
119 } | 124 } |
120 | 125 |
121 void CreateParentMessagePipe( | 126 void CreateParentMessagePipe( |
122 const std::string& token, | 127 const std::string& token, |
123 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { | 128 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { |
| 129 callback.Run(CreateParentMessagePipe(token)); |
| 130 } |
| 131 |
| 132 ScopedMessagePipeHandle CreateChildMessagePipe(const std::string& token) { |
124 DCHECK(internal::g_core); | 133 DCHECK(internal::g_core); |
125 internal::g_core->CreateParentMessagePipe(token, callback); | 134 return internal::g_core->CreateChildMessagePipe(token); |
126 } | 135 } |
127 | 136 |
128 void CreateChildMessagePipe( | 137 void CreateChildMessagePipe( |
129 const std::string& token, | 138 const std::string& token, |
130 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { | 139 const base::Callback<void(ScopedMessagePipeHandle)>& callback) { |
131 DCHECK(internal::g_core); | 140 callback.Run(CreateChildMessagePipe(token)); |
132 internal::g_core->CreateChildMessagePipe(token, callback); | |
133 } | 141 } |
134 | 142 |
135 std::string GenerateRandomToken() { | 143 std::string GenerateRandomToken() { |
136 char random_bytes[16]; | 144 char random_bytes[16]; |
137 crypto::RandBytes(random_bytes, 16); | 145 crypto::RandBytes(random_bytes, 16); |
138 return base::HexEncode(random_bytes, 16); | 146 return base::HexEncode(random_bytes, 16); |
139 } | 147 } |
140 | 148 |
141 } // namespace edk | 149 } // namespace edk |
142 } // namespace mojo | 150 } // namespace mojo |
OLD | NEW |