OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/proxy/ppb_network_monitor_private_proxy.h" | 5 #include "ppapi/proxy/ppb_network_monitor_private_proxy.h" |
6 | 6 |
7 #include "ppapi/proxy/enter_proxy.h" | 7 #include "ppapi/proxy/enter_proxy.h" |
8 #include "ppapi/proxy/plugin_proxy_delegate.h" | |
9 #include "ppapi/proxy/ppapi_messages.h" | 8 #include "ppapi/proxy/ppapi_messages.h" |
10 #include "ppapi/shared_impl/proxy_lock.h" | 9 #include "ppapi/shared_impl/proxy_lock.h" |
11 #include "ppapi/thunk/ppb_network_monitor_private_api.h" | 10 #include "ppapi/thunk/ppb_network_monitor_private_api.h" |
12 | 11 |
13 namespace ppapi { | 12 namespace ppapi { |
14 namespace proxy { | 13 namespace proxy { |
15 | 14 |
16 class PPB_NetworkMonitor_Private_Proxy::NetworkMonitor | 15 class PPB_NetworkMonitor_Private_Proxy::NetworkMonitor |
17 : public Resource, | 16 : public Resource, |
18 public thunk::PPB_NetworkMonitor_Private_API, | 17 public thunk::PPB_NetworkMonitor_Private_API, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 if (!proxy) | 90 if (!proxy) |
92 return 0; | 91 return 0; |
93 | 92 |
94 scoped_refptr<NetworkMonitor> result( | 93 scoped_refptr<NetworkMonitor> result( |
95 new NetworkMonitor(instance, proxy, callback, user_data)); | 94 new NetworkMonitor(instance, proxy, callback, user_data)); |
96 proxy->monitors_->AddObserver(result.get()); | 95 proxy->monitors_->AddObserver(result.get()); |
97 | 96 |
98 proxy->monitors_count_++; | 97 proxy->monitors_count_++; |
99 if (proxy->monitors_count_ == 1) { | 98 if (proxy->monitors_count_ == 1) { |
100 // If that is the first network monitor then send Start message. | 99 // If that is the first network monitor then send Start message. |
101 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 100 PluginGlobals::Get()->GetBrowserSender()->Send( |
102 new PpapiHostMsg_PPBNetworkMonitor_Start( | 101 new PpapiHostMsg_PPBNetworkMonitor_Start( |
103 dispatcher->plugin_dispatcher_id())); | 102 dispatcher->plugin_dispatcher_id())); |
104 | 103 |
105 // We could have received network list message after sending the | 104 // We could have received network list message after sending the |
106 // previous Stop message. This list is stale now, so reset it | 105 // previous Stop message. This list is stale now, so reset it |
107 // here. | 106 // here. |
108 proxy->current_list_ = NULL; | 107 proxy->current_list_ = NULL; |
109 } else if (proxy->current_list_.get()) { | 108 } else if (proxy->current_list_.get()) { |
110 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 109 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
111 &NetworkMonitor::OnNetworkListReceivedLocks, | 110 &NetworkMonitor::OnNetworkListReceivedLocks, |
(...skipping 24 matching lines...) Expand all Loading... |
136 | 135 |
137 void PPB_NetworkMonitor_Private_Proxy::OnNetworkMonitorDeleted( | 136 void PPB_NetworkMonitor_Private_Proxy::OnNetworkMonitorDeleted( |
138 NetworkMonitor* monitor, | 137 NetworkMonitor* monitor, |
139 PP_Instance instance) { | 138 PP_Instance instance) { |
140 monitors_->RemoveObserver(monitor); | 139 monitors_->RemoveObserver(monitor); |
141 monitors_count_--; | 140 monitors_count_--; |
142 if (monitors_count_ == 0) { | 141 if (monitors_count_ == 0) { |
143 // Send Stop message if that was the last NetworkMonitor. | 142 // Send Stop message if that was the last NetworkMonitor. |
144 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 143 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
145 if (dispatcher) { | 144 if (dispatcher) { |
146 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( | 145 PluginGlobals::Get()->GetBrowserSender()->Send( |
147 new PpapiHostMsg_PPBNetworkMonitor_Stop( | 146 new PpapiHostMsg_PPBNetworkMonitor_Stop( |
148 dispatcher->plugin_dispatcher_id())); | 147 dispatcher->plugin_dispatcher_id())); |
149 } | 148 } |
150 current_list_ = NULL; | 149 current_list_ = NULL; |
151 } | 150 } |
152 } | 151 } |
153 | 152 |
154 } // namespace proxy | 153 } // namespace proxy |
155 } // namespace ppapi | 154 } // namespace ppapi |
OLD | NEW |