OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_CHANNEL_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_CHANNEL_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_CHANNEL_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_CHANNEL_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "content/common/np_channel_base.h" | 9 #include "content/common/np_channel_base.h" |
10 | 10 |
11 // Threadsafe route ID generator. | |
joth
2011/12/07 14:49:09
could you expand this a little:
- allows injection
Steve Block
2011/12/07 16:47:44
Done.
| |
12 class RouteIDGenerator : public base::RefCountedThreadSafe<RouteIDGenerator> { | |
13 public: | |
14 int GenerateRouteID() const; | |
15 private: | |
joth
2011/12/07 14:49:09
\n before
| |
16 friend class base::RefCountedThreadSafe<RouteIDGenerator>; | |
17 ~RouteIDGenerator() {} | |
joth
2011/12/07 14:49:09
d'tor body always in .cc
| |
18 }; | |
joth
2011/12/07 14:49:09
as this does not have any state (other than in a s
Steve Block
2011/12/07 16:47:44
The only state this captures is ensuring that all
| |
19 | |
11 class JavaBridgeChannelHost : public NPChannelBase { | 20 class JavaBridgeChannelHost : public NPChannelBase { |
12 public: | 21 public: |
13 static JavaBridgeChannelHost* GetJavaBridgeChannelHost( | 22 static JavaBridgeChannelHost* GetJavaBridgeChannelHost( |
14 int renderer_id, base::MessageLoopProxy*); | 23 int renderer_id, base::MessageLoopProxy* ipc_message_loop, |
joth
2011/12/07 14:49:09
one param per line in declarations.
| |
24 RouteIDGenerator* route_id_generator); | |
15 | 25 |
16 // NPChannelBase implementation: | 26 // NPChannelBase implementation: |
17 virtual int GenerateRouteID() OVERRIDE; | 27 virtual int GenerateRouteID() OVERRIDE; |
18 | 28 |
19 // NPChannelBase override: | 29 // NPChannelBase override: |
20 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, | 30 virtual bool Init(base::MessageLoopProxy* ipc_message_loop, |
21 bool create_pipe_now, | 31 bool create_pipe_now, |
22 base::WaitableEvent* shutdown_event) OVERRIDE; | 32 base::WaitableEvent* shutdown_event) OVERRIDE; |
23 virtual bool Send(IPC::Message* msg) OVERRIDE; | 33 virtual bool Send(IPC::Message* msg) OVERRIDE; |
24 | 34 |
25 private: | 35 private: |
26 JavaBridgeChannelHost() {} | 36 JavaBridgeChannelHost() {} |
27 friend class base::RefCountedThreadSafe<JavaBridgeChannelHost>; | 37 friend class base::RefCountedThreadSafe<JavaBridgeChannelHost>; |
28 virtual ~JavaBridgeChannelHost() {} | 38 virtual ~JavaBridgeChannelHost() {} |
29 | 39 |
30 static NPChannelBase* ClassFactory() { | 40 static NPChannelBase* ClassFactory() { |
31 return new JavaBridgeChannelHost(); | 41 return new JavaBridgeChannelHost(); |
32 } | 42 } |
33 | 43 |
44 // Message handlers | |
45 void OnGenerateRouteID(int* route_id); | |
46 | |
47 scoped_refptr<RouteIDGenerator> route_id_generator_; | |
48 | |
34 DISALLOW_COPY_AND_ASSIGN(JavaBridgeChannelHost); | 49 DISALLOW_COPY_AND_ASSIGN(JavaBridgeChannelHost); |
35 }; | 50 }; |
36 | 51 |
37 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_CHANNEL_HOST_H_ | 52 #endif // CONTENT_BROWSER_RENDERER_HOST_JAVA_JAVA_BRIDGE_CHANNEL_HOST_H_ |
OLD | NEW |