| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ | 5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ |
| 6 #define ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ | 6 #define ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 static AwMessagePortServiceImpl* GetInstance(); | 26 static AwMessagePortServiceImpl* GetInstance(); |
| 27 | 27 |
| 28 AwMessagePortServiceImpl(); | 28 AwMessagePortServiceImpl(); |
| 29 ~AwMessagePortServiceImpl(); | 29 ~AwMessagePortServiceImpl(); |
| 30 void Init(JNIEnv* env, jobject object); | 30 void Init(JNIEnv* env, jobject object); |
| 31 | 31 |
| 32 void CreateMessageChannel(JNIEnv* env, jobject callback, | 32 void CreateMessageChannel(JNIEnv* env, jobject callback, |
| 33 scoped_refptr<AwMessagePortMessageFilter> filter); | 33 scoped_refptr<AwMessagePortMessageFilter> filter); |
| 34 | 34 |
| 35 // AwMessagePortService implementation | 35 // AwMessagePortService implementation |
| 36 void OnConvertedMessage( | 36 void OnConvertedInMessage( |
| 37 int message_port_id, | 37 int message_port_id, |
| 38 const base::ListValue& message, | 38 const base::ListValue& message, |
| 39 const std::vector<int>& sent_message_port_ids) override; | 39 const std::vector<int>& sent_message_port_ids) override; |
| 40 void OnMessagePortMessageFilterClosing( | 40 void OnMessagePortMessageFilterClosing( |
| 41 AwMessagePortMessageFilter* filter) override; | 41 AwMessagePortMessageFilter* filter) override; |
| 42 | 42 |
| 43 // Methods called from Java. |
| 44 void PostOutMessage(JNIEnv* env, jobject object, int sender_id, |
| 45 jstring message, jintArray sent_ports); |
| 46 |
| 47 void RemoveSentPorts(const std::vector<int>& sent_ports); |
| 48 |
| 43 private: | 49 private: |
| 50 void PostOutMessageOnIOThread( |
| 51 int sender_id, |
| 52 base::string16* message, |
| 53 std::vector<int>* sent_ports); |
| 44 void CreateMessageChannelOnIOThread( | 54 void CreateMessageChannelOnIOThread( |
| 45 scoped_refptr<AwMessagePortMessageFilter> filter, | 55 scoped_refptr<AwMessagePortMessageFilter> filter, |
| 46 int* port1, | 56 int* port1, |
| 47 int* port2); | 57 int* port2); |
| 48 void OnMessageChannelCreated( | 58 void OnMessageChannelCreated( |
| 49 base::android::ScopedJavaGlobalRef<jobject>* callback, | 59 base::android::ScopedJavaGlobalRef<jobject>* callback, |
| 50 int* port1, | 60 int* port1, |
| 51 int* port2); | 61 int* port2); |
| 52 void AddPort(int message_port_id, AwMessagePortMessageFilter* filter); | 62 void AddPort(int message_port_id, AwMessagePortMessageFilter* filter); |
| 53 | 63 |
| 54 JavaObjectWeakGlobalRef java_ref_; | 64 JavaObjectWeakGlobalRef java_ref_; |
| 55 typedef std::map<int, AwMessagePortMessageFilter*> MessagePorts; | 65 typedef std::map<int, AwMessagePortMessageFilter*> MessagePorts; |
| 56 MessagePorts ports_; // Access on IO thread | 66 MessagePorts ports_; // Access on IO thread |
| 57 | 67 |
| 58 DISALLOW_COPY_AND_ASSIGN(AwMessagePortServiceImpl); | 68 DISALLOW_COPY_AND_ASSIGN(AwMessagePortServiceImpl); |
| 59 }; | 69 }; |
| 60 | 70 |
| 61 bool RegisterAwMessagePortService(JNIEnv* env); | 71 bool RegisterAwMessagePortService(JNIEnv* env); |
| 62 | 72 |
| 63 } // namespace android_webview | 73 } // namespace android_webview |
| 64 | 74 |
| 65 #endif // ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ | 75 #endif // ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ |
| OLD | NEW |