Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: ppapi/proxy/ppb_network_monitor_private_proxy.cc

Issue 9958150: Make sure that scoped_ptr<> cannot be used with ref-counted objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/service_process_util_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 8 #include "ppapi/proxy/plugin_proxy_delegate.h"
9 #include "ppapi/proxy/ppapi_messages.h" 9 #include "ppapi/proxy/ppapi_messages.h"
10 #include "ppapi/thunk/ppb_network_monitor_private_api.h" 10 #include "ppapi/thunk/ppb_network_monitor_private_api.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); 76 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
77 if (!dispatcher) 77 if (!dispatcher)
78 return 0; 78 return 0;
79 PPB_NetworkMonitor_Private_Proxy* proxy = 79 PPB_NetworkMonitor_Private_Proxy* proxy =
80 static_cast<PPB_NetworkMonitor_Private_Proxy*>( 80 static_cast<PPB_NetworkMonitor_Private_Proxy*>(
81 dispatcher->GetInterfaceProxy(kApiID)); 81 dispatcher->GetInterfaceProxy(kApiID));
82 if (!proxy) 82 if (!proxy)
83 return 0; 83 return 0;
84 84
85 scoped_ptr<NetworkMonitor> result( 85 scoped_refptr<NetworkMonitor> result(
86 new NetworkMonitor(instance, proxy, callback, user_data)); 86 new NetworkMonitor(instance, proxy, callback, user_data));
87 proxy->monitors_->AddObserver(result.get()); 87 proxy->monitors_->AddObserver(result.get());
88 88
89 proxy->monitors_count_++; 89 proxy->monitors_count_++;
90 if (proxy->monitors_count_ == 1) { 90 if (proxy->monitors_count_ == 1) {
91 // If that is the first network monitor then send Start message. 91 // If that is the first network monitor then send Start message.
92 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( 92 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(
93 new PpapiHostMsg_PPBNetworkMonitor_Start( 93 new PpapiHostMsg_PPBNetworkMonitor_Start(
94 dispatcher->plugin_dispatcher_id())); 94 dispatcher->plugin_dispatcher_id()));
95 95
96 // We could have received network list message after sending the 96 // We could have received network list message after sending the
97 // previous Stop message. This list is stale now, so reset it 97 // previous Stop message. This list is stale now, so reset it
98 // here. 98 // here.
99 proxy->current_list_ = NULL; 99 proxy->current_list_ = NULL;
100 } else if (proxy->current_list_.get()) { 100 } else if (proxy->current_list_.get()) {
101 MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 101 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
102 &NetworkMonitor::OnNetworkListReceived, 102 &NetworkMonitor::OnNetworkListReceived,
103 result->AsWeakPtr(), proxy->current_list_)); 103 result->AsWeakPtr(), proxy->current_list_));
104 } 104 }
105 105
106 return result.release()->GetReference(); 106 return result->GetReference();
107 } 107 }
108 108
109 bool PPB_NetworkMonitor_Private_Proxy::OnMessageReceived( 109 bool PPB_NetworkMonitor_Private_Proxy::OnMessageReceived(
110 const IPC::Message& msg) { 110 const IPC::Message& msg) {
111 bool handled = true; 111 bool handled = true;
112 IPC_BEGIN_MESSAGE_MAP(PPB_NetworkMonitor_Private_Proxy, msg) 112 IPC_BEGIN_MESSAGE_MAP(PPB_NetworkMonitor_Private_Proxy, msg)
113 IPC_MESSAGE_HANDLER(PpapiMsg_PPBNetworkMonitor_NetworkList, 113 IPC_MESSAGE_HANDLER(PpapiMsg_PPBNetworkMonitor_NetworkList,
114 OnPluginMsgNetworkList) 114 OnPluginMsgNetworkList)
115 IPC_MESSAGE_UNHANDLED(handled = false) 115 IPC_MESSAGE_UNHANDLED(handled = false)
116 IPC_END_MESSAGE_MAP() 116 IPC_END_MESSAGE_MAP()
(...skipping 20 matching lines...) Expand all
137 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( 137 PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser(
138 new PpapiHostMsg_PPBNetworkMonitor_Stop( 138 new PpapiHostMsg_PPBNetworkMonitor_Stop(
139 dispatcher->plugin_dispatcher_id())); 139 dispatcher->plugin_dispatcher_id()));
140 } 140 }
141 current_list_ = NULL; 141 current_list_ = NULL;
142 } 142 }
143 } 143 }
144 144
145 } // namespace proxy 145 } // namespace proxy
146 } // namespace ppapi 146 } // namespace ppapi
OLDNEW
« no previous file with comments | « chrome/common/service_process_util_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698