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 #include "content/browser/renderer_host/java/java_bridge_channel_host.h" | 5 #include "content/browser/renderer_host/java/java_bridge_channel_host.h" |
6 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
11 #include "content/common/java_bridge_messages.h" | 11 #include "content/common/java_bridge_messages.h" |
12 | 12 |
13 using base::WaitableEvent; | 13 using base::WaitableEvent; |
14 | 14 |
15 namespace content { | |
15 namespace { | 16 namespace { |
16 struct WaitableEventLazyInstanceTraits | 17 struct WaitableEventLazyInstanceTraits |
tfarina
2012/10/29 18:17:39
I'd put blank lines between these things to increa
| |
17 : public base::DefaultLazyInstanceTraits<WaitableEvent> { | 18 : public base::DefaultLazyInstanceTraits<WaitableEvent> { |
18 static WaitableEvent* New(void* instance) { | 19 static WaitableEvent* New(void* instance) { |
19 // Use placement new to initialize our instance in our preallocated space. | 20 // Use placement new to initialize our instance in our preallocated space. |
20 // The parenthesis is very important here to force POD type initialization. | 21 // The parenthesis is very important here to force POD type initialization. |
21 return new (instance) WaitableEvent(false, false); | 22 return new (instance) WaitableEvent(false, false); |
22 } | 23 } |
23 }; | 24 }; |
24 base::LazyInstance<WaitableEvent, WaitableEventLazyInstanceTraits> dummy_event = | 25 base::LazyInstance<WaitableEvent, WaitableEventLazyInstanceTraits> dummy_event = |
tfarina
2012/10/29 18:17:39
likewise
| |
25 LAZY_INSTANCE_INITIALIZER; | 26 LAZY_INSTANCE_INITIALIZER; |
26 | 27 |
27 base::subtle::AtomicWord g_last_id = 0; | 28 base::subtle::AtomicWord g_last_id = 0; |
28 } | 29 } |
tfarina
2012/10/29 18:17:39
// namespace
tfarina
2012/10/29 18:17:39
likewise
| |
29 | 30 |
30 JavaBridgeChannelHost* JavaBridgeChannelHost::GetJavaBridgeChannelHost( | 31 JavaBridgeChannelHost* JavaBridgeChannelHost::GetJavaBridgeChannelHost( |
31 int renderer_id, | 32 int renderer_id, |
32 base::MessageLoopProxy* ipc_message_loop) { | 33 base::MessageLoopProxy* ipc_message_loop) { |
33 std::string channel_name(StringPrintf("r%d.javabridge", renderer_id)); | 34 std::string channel_name(StringPrintf("r%d.javabridge", renderer_id)); |
34 // There's no need for a shutdown event here. If the browser is terminated | 35 // There's no need for a shutdown event here. If the browser is terminated |
35 // while the JavaBridgeChannelHost is blocked on a synchronous IPC call, the | 36 // while the JavaBridgeChannelHost is blocked on a synchronous IPC call, the |
36 // renderer's shutdown event will cause the underlying channel to shut down, | 37 // renderer's shutdown event will cause the underlying channel to shut down, |
37 // thus terminating the IPC call. | 38 // thus terminating the IPC call. |
38 return static_cast<JavaBridgeChannelHost*>(NPChannelBase::GetChannel( | 39 return static_cast<JavaBridgeChannelHost*>(NPChannelBase::GetChannel( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 bool handled = true; | 74 bool handled = true; |
74 IPC_BEGIN_MESSAGE_MAP(JavaBridgeChannelHost, message) | 75 IPC_BEGIN_MESSAGE_MAP(JavaBridgeChannelHost, message) |
75 IPC_MESSAGE_HANDLER(JavaBridgeMsg_GenerateRouteID, OnGenerateRouteID) | 76 IPC_MESSAGE_HANDLER(JavaBridgeMsg_GenerateRouteID, OnGenerateRouteID) |
76 IPC_END_MESSAGE_MAP() | 77 IPC_END_MESSAGE_MAP() |
77 return handled; | 78 return handled; |
78 } | 79 } |
79 | 80 |
80 void JavaBridgeChannelHost::OnGenerateRouteID(int* route_id) { | 81 void JavaBridgeChannelHost::OnGenerateRouteID(int* route_id) { |
81 *route_id = GenerateRouteID(); | 82 *route_id = GenerateRouteID(); |
82 } | 83 } |
84 | |
85 } // namespace content | |
OLD | NEW |