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

Unified Diff: mojo/edk/system/core.cc

Issue 2735113003: Changing SpawnChild to return a struct.
Patch Set: Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/message_pipe_dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/core.cc
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
index a5e432b8a749f3a2ddc937bcf5a86f392db1baa6..4b60bc48fe5eec210bdc2fd3c1fe3f817abd7f48 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -36,6 +36,10 @@
#include "mojo/edk/system/wait_set_dispatcher.h"
#include "mojo/edk/system/waiter.h"
+#if defined(OS_ANDROID)
+#include "base/android/jni_android.h"
+#endif
+
namespace mojo {
namespace edk {
@@ -89,6 +93,15 @@ MojoResult MojoPlatformHandleToScopedPlatformHandle(
break;
#endif
+#if defined(OS_ANDROID)
+ case MOJO_PLATFORM_HANDLE_TYPE_PARCELABLE:
+ handle.type = PlatformHandle::Type::PARCELABLE;
+ handle.parcelable.Reset(
+ base::android::AttachCurrentThread(),
+ reinterpret_cast<jobject>(platform_handle->value));
+ break;
+#endif
+
default:
return MOJO_RESULT_INVALID_ARGUMENT;
}
@@ -122,6 +135,14 @@ MojoResult ScopedPlatformHandleToMojoPlatformHandle(
break;
#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+#if defined(OS_ANDROID)
+ case PlatformHandle::Type::PARCELABLE:
+ platform_handle->type = MOJO_PLATFORM_HANDLE_TYPE_PARCELABLE;
+ platform_handle->value =
+ reinterpret_cast<uint64_t>(handle.release().parcelable.Release());
+ break;
+#endif // defined(OS_ANDROID)
+
default:
return MOJO_RESULT_INVALID_ARGUMENT;
}
@@ -172,12 +193,11 @@ void Core::SetDefaultProcessErrorCallback(
}
void Core::AddChild(base::ProcessHandle process_handle,
- ScopedPlatformHandle platform_handle,
+ ConnectionParam connection_param,
const std::string& child_token,
const ProcessErrorCallback& process_error_callback) {
GetNodeController()->ConnectToChild(process_handle,
- std::move(platform_handle),
- child_token,
+ std::move(connection_param), child_token,
process_error_callback);
}
@@ -194,7 +214,9 @@ ScopedMessagePipeHandle Core::ConnectToPeerProcess(
GetNodeController()->node()->CreatePortPair(&port0, &port1);
MojoHandle handle = AddDispatcher(new MessagePipeDispatcher(
GetNodeController(), port0, kUnknownPipeIdForDebug, 0));
- GetNodeController()->ConnectToPeer(std::move(pipe_handle), port1, peer_token);
+ ConnectionParam connection_param(std::move(pipe_handle));
+ GetNodeController()->ConnectToPeer(std::move(connection_param), port1,
+ peer_token);
return ScopedMessagePipeHandle(MessagePipeHandle(handle));
}
@@ -202,8 +224,8 @@ void Core::ClosePeerConnection(const std::string& peer_token) {
GetNodeController()->ClosePeerConnection(peer_token);
}
-void Core::InitChild(ScopedPlatformHandle platform_handle) {
- GetNodeController()->ConnectToParent(std::move(platform_handle));
+void Core::InitChild(ConnectionParam connection_param) {
+ GetNodeController()->ConnectToParent(std::move(connection_param));
}
void Core::SetMachPortProvider(base::PortProvider* port_provider) {
@@ -687,6 +709,7 @@ MojoResult Core::ReadMessage(MojoHandle message_pipe_handle,
auto dispatcher = GetDispatcher(message_pipe_handle);
if (!dispatcher)
return MOJO_RESULT_INVALID_ARGUMENT;
+
std::unique_ptr<MessageForTransit> message;
MojoResult rv =
dispatcher->ReadMessage(&message, num_bytes, handles, num_handles, flags,
« no previous file with comments | « mojo/edk/system/core.h ('k') | mojo/edk/system/message_pipe_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698