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

Unified Diff: content/browser/android/app_web_message_port.h

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Eliminate unnecessary PostTask Created 3 years, 10 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
Index: content/browser/android/app_web_message_port.h
diff --git a/content/browser/android/app_web_message_port.h b/content/browser/android/app_web_message_port.h
new file mode 100644
index 0000000000000000000000000000000000000000..e57865dd6f2b45d255b900c519159f4e32fac6c5
--- /dev/null
+++ b/content/browser/android/app_web_message_port.h
@@ -0,0 +1,59 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_ANDROID_APP_WEB_MESSAGE_PORT_H_
+#define CONTENT_BROWSER_ANDROID_APP_WEB_MESSAGE_PORT_H_
+
+#include "base/android/jni_weak_ref.h"
+#include "content/common/message_port.h"
+
+namespace content {
+
+class AppWebMessagePort {
+ public:
+ static void CreateAndBindToJavaObject(
+ JNIEnv* env,
+ mojo::ScopedMessagePipeHandle handle,
+ const base::android::JavaRef<jobject>& jobject);
+
+ static std::vector<MessagePort> UnwrapJavaArray(
+ JNIEnv* env,
+ const base::android::JavaRef<jobjectArray>& jports);
+
+ // Methods called from Java.
+ void CloseMessagePort(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jcaller);
+ void PostMessage(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jcaller,
+ const base::android::JavaParamRef<jstring>& jmessage,
+ const base::android::JavaParamRef<jobjectArray>& jports);
+ void DispatchReceivedMessages(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jcaller);
+ void StartReceivingMessages(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& jcaller);
+
+ private:
+ explicit AppWebMessagePort(
+ JNIEnv* env,
+ mojo::ScopedMessagePipeHandle handle,
+ const base::android::JavaRef<jobject>& jobject);
+ ~AppWebMessagePort();
+
+ void OnMessagesAvailable();
+
+ MessagePort port_;
+ JavaObjectWeakGlobalRef java_ref_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppWebMessagePort);
+};
+
+bool RegisterAppWebMessagePort(JNIEnv* env);
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_ANDROID_APP_WEB_MESSAGE_PORT_H_

Powered by Google App Engine
This is Rietveld 408576698