Chromium Code Reviews| Index: android_webview/native/aw_message_port_service_impl.h |
| diff --git a/android_webview/native/aw_message_port_service_impl.h b/android_webview/native/aw_message_port_service_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7285057bba7f8c527191b246171bb17a35f72294 |
| --- /dev/null |
| +++ b/android_webview/native/aw_message_port_service_impl.h |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2014 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 ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ |
| +#define ANDROID_WEBVIEW_NATIVE_AW_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/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/strings/string16.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. |
|
mnaganov (inactive)
2015/01/07 11:43:54
I would recommend adding comments and asserts abou
sgurun-gerrit only
2015/01/10 02:36:29
Done.
|
| +class AwMessagePortServiceImpl : public AwMessagePortService { |
| + public: |
| + static AwMessagePortServiceImpl* GetInstance(); |
| + |
| + AwMessagePortServiceImpl(); |
| + ~AwMessagePortServiceImpl(); |
| + void Init(JNIEnv* env, jobject object); |
| + |
| + void OnMessageChannelCreated( |
| + AwMessagePortMessageFilter* filter, |
| + base::android::ScopedJavaGlobalRef<jobject>* callback, |
| + int* port1, |
| + int* port2); |
| + |
| + // AwMessagePortService implementation |
| + void OnConvertedMessage( |
| + int message_port_id, |
| + const base::ListValue& message, |
| + const std::vector<int>& sent_message_port_ids) override; |
| + void OnMessagePortMessageFilterClosing( |
| + AwMessagePortMessageFilter* filter) override; |
| + |
| +private: |
| + void AddPort(int message_port_id, AwMessagePortMessageFilter* filter); |
| + |
| + JavaObjectWeakGlobalRef java_ref_; |
| + typedef std::map<int, AwMessagePortMessageFilter*> MessagePorts; |
| + MessagePorts ports_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AwMessagePortServiceImpl); |
| +}; |
| + |
| +bool RegisterAwMessagePortService(JNIEnv* env); |
| + |
| +} // namespace android_webview |
| + |
| +#endif // ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ |