OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ | |
6 #define ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ | |
7 | |
8 #include <jni.h> | |
9 #include <map> | |
10 | |
11 #include "android_webview/browser/aw_message_port_service.h" | |
12 #include "base/android/jni_weak_ref.h" | |
13 #include "base/basictypes.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/strings/string16.h" | |
16 | |
17 namespace android_webview { | |
18 | |
19 // This class is the native peer of AwMessagePortService.java. Please see the | |
20 // 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.
| |
21 class AwMessagePortServiceImpl : public AwMessagePortService { | |
22 public: | |
23 static AwMessagePortServiceImpl* GetInstance(); | |
24 | |
25 AwMessagePortServiceImpl(); | |
26 ~AwMessagePortServiceImpl(); | |
27 void Init(JNIEnv* env, jobject object); | |
28 | |
29 void OnMessageChannelCreated( | |
30 AwMessagePortMessageFilter* filter, | |
31 base::android::ScopedJavaGlobalRef<jobject>* callback, | |
32 int* port1, | |
33 int* port2); | |
34 | |
35 // AwMessagePortService implementation | |
36 void OnConvertedMessage( | |
37 int message_port_id, | |
38 const base::ListValue& message, | |
39 const std::vector<int>& sent_message_port_ids) override; | |
40 void OnMessagePortMessageFilterClosing( | |
41 AwMessagePortMessageFilter* filter) override; | |
42 | |
43 private: | |
44 void AddPort(int message_port_id, AwMessagePortMessageFilter* filter); | |
45 | |
46 JavaObjectWeakGlobalRef java_ref_; | |
47 typedef std::map<int, AwMessagePortMessageFilter*> MessagePorts; | |
48 MessagePorts ports_; | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(AwMessagePortServiceImpl); | |
51 }; | |
52 | |
53 bool RegisterAwMessagePortService(JNIEnv* env); | |
54 | |
55 } // namespace android_webview | |
56 | |
57 #endif // ANDROID_WEBVIEW_NATIVE_AW_MESSAGE_PORT_SERVICE_IMPL_H_ | |
OLD | NEW |