Chromium Code Reviews| Index: content/browser/android/app_web_message_port_service_impl.h |
| diff --git a/android_webview/native/aw_message_port_service_impl.h b/content/browser/android/app_web_message_port_service_impl.h |
| similarity index 55% |
| rename from android_webview/native/aw_message_port_service_impl.h |
| rename to content/browser/android/app_web_message_port_service_impl.h |
| index f62b76ec8488456f591032673c36ac1cc53fa3ca..159c4d0f3ef5eaebe6c7f025e5d976c298cc9625 100644 |
| --- a/android_webview/native/aw_message_port_service_impl.h |
| +++ b/content/browser/android/app_web_message_port_service_impl.h |
| @@ -2,45 +2,48 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ |
| -#define ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ |
| +#ifndef CONTENT_BROWSER_ANDROID_APP_WEB_MESSAGE_PORT_SERVICE_IMPL_H_ |
| +#define CONTENT_BROWSER_ANDROID_APP_WEB_MESSAGE_PORT_SERVICE_IMPL_H_ |
| -#include <jni.h> |
| #include <map> |
| -#include "android_webview/browser/aw_message_port_service.h" |
| #include "base/android/jni_weak_ref.h" |
| #include "base/macros.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/memory/singleton.h" |
| #include "base/strings/string16.h" |
| +#include "content/public/browser/android/app_web_message_port_service.h" |
| -namespace android_webview { |
| -// This class is the native peer of AwMessagePortService.java. Please see the |
| -// java class for an explanation of use, ownership and lifetime. |
| +namespace content { |
| +class AppWebMessagePortMessageFilter; |
| + |
| +// This class is the native peer of AppWebMessagePortService.java. |
| +// Please see the java class for an explanation of use, ownership and lifetime. |
|
sgurun-gerrit only
2016/09/30 23:40:59
do the notes in java class still apply after this
Yusuf
2016/10/04 21:33:14
Yes!
|
| // Threading: Created and initialized on UI thread. For other methods, see |
| // the method level DCHECKS or documentation. |
| -class AwMessagePortServiceImpl : public AwMessagePortService { |
| +class AppWebMessagePortServiceImpl : public AppWebMessagePortService { |
| public: |
| - static AwMessagePortServiceImpl* GetInstance(); |
| - AwMessagePortServiceImpl(); |
| - ~AwMessagePortServiceImpl() override; |
| + // Returns the AppWebMessagePortServiceImpl singleton. |
| + static AppWebMessagePortServiceImpl* GetInstance(); |
| + |
| + AppWebMessagePortServiceImpl(); |
| + ~AppWebMessagePortServiceImpl() override; |
| void Init(JNIEnv* env, jobject object); |
| - void CreateMessageChannel(JNIEnv* env, jobjectArray ports, |
| - scoped_refptr<AwMessagePortMessageFilter> filter); |
| + // AppWebMessagePortService implementation |
| - // AwMessagePortService implementation |
| + void CreateMessageChannel( |
| + JNIEnv* env, jobjectArray ports, WebContents* web_contents) override; |
| void OnConvertedWebToAppMessage( |
| int message_port_id, |
| const base::ListValue& message, |
| const std::vector<int>& sent_message_port_ids) override; |
| - void OnMessagePortMessageFilterClosing( |
| - AwMessagePortMessageFilter* filter) override; |
| void CleanupPort(int message_port_id) override; |
| + void RemoveSentPorts(const std::vector<int>& sent_ports) override; |
|
sgurun-gerrit only
2016/09/30 23:40:59
private
Yusuf
2016/10/04 21:33:14
Got rid of override, but had to keep it public sin
|
| // Methods called from Java. |
| void PostAppToWebMessage( |
| JNIEnv* env, |
| @@ -55,33 +58,36 @@ class AwMessagePortServiceImpl : public AwMessagePortService { |
| const base::android::JavaParamRef<jobject>& object, |
| int message_port_id); |
| - void RemoveSentPorts(const std::vector<int>& sent_ports); |
| + void OnMessagePortMessageFilterClosing( |
| + AppWebMessagePortMessageFilter* filter); |
| private: |
| + friend struct base::DefaultSingletonTraits<AppWebMessagePortServiceImpl>; |
| + |
| void PostAppToWebMessageOnIOThread( |
| int sender_id, |
| base::string16* message, |
| std::vector<int>* sent_ports); |
| void CreateMessageChannelOnIOThread( |
| - scoped_refptr<AwMessagePortMessageFilter> filter, |
| + scoped_refptr<AppWebMessagePortMessageFilter> filter, |
| int* port1, |
| int* port2); |
| void OnMessageChannelCreated( |
| base::android::ScopedJavaGlobalRef<jobjectArray>* ports, |
| int* port1, |
| int* port2); |
| - void AddPort(int message_port_id, AwMessagePortMessageFilter* filter); |
| + void AddPort(int message_port_id, AppWebMessagePortMessageFilter* filter); |
| void PostClosePortMessage(int message_port_id); |
| JavaObjectWeakGlobalRef java_ref_; |
| - typedef std::map<int, AwMessagePortMessageFilter*> MessagePorts; |
| + typedef std::map<int, AppWebMessagePortMessageFilter*> MessagePorts; |
| MessagePorts ports_; // Access on IO thread |
| - DISALLOW_COPY_AND_ASSIGN(AwMessagePortServiceImpl); |
| + DISALLOW_COPY_AND_ASSIGN(AppWebMessagePortServiceImpl); |
| }; |
| -bool RegisterAwMessagePortService(JNIEnv* env); |
| +bool RegisterAppWebMessagePortService(JNIEnv* env); |
| -} // namespace android_webview |
| +} // namespace content |
| -#endif // ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ |
| +#endif // CONTENT_BROWSER_ANDROID_APP_WEB_MESSAGE_PORT_SERVICE_IMPL_H_ |