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