| 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 54%
|
| 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..e1bd001d1cd2f158349d80ba2ac7a670a4f6a415 100644
|
| --- a/android_webview/native/aw_message_port_service_impl.h
|
| +++ b/content/browser/android/app_web_message_port_service_impl.h
|
| @@ -2,43 +2,41 @@
|
| // 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.
|
|
|
| // 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 OnConvertedWebToAppMessage(
|
| - int message_port_id,
|
| - const base::ListValue& message,
|
| - const std::vector<int>& sent_message_port_ids) override;
|
| - void OnMessagePortMessageFilterClosing(
|
| - AwMessagePortMessageFilter* filter) override;
|
| + void CreateMessageChannel(
|
| + JNIEnv* env, jobjectArray ports, WebContents* web_contents) override;
|
| void CleanupPort(int message_port_id) override;
|
|
|
| // Methods called from Java.
|
| @@ -55,33 +53,43 @@ class AwMessagePortServiceImpl : public AwMessagePortService {
|
| const base::android::JavaParamRef<jobject>& object,
|
| int message_port_id);
|
|
|
| + void OnMessagePortMessageFilterClosing(
|
| + AppWebMessagePortMessageFilter* filter);
|
| +
|
| + // AppWebMessagePortServiceImpl specific calls
|
| + void OnConvertedWebToAppMessage(
|
| + int message_port_id,
|
| + const base::ListValue& message,
|
| + const std::vector<int>& sent_message_port_ids);
|
| void RemoveSentPorts(const std::vector<int>& sent_ports);
|
|
|
| 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_
|
|
|