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

Side by Side Diff: content/common/np_channel_base.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/gpu/gpu_child_thread.cc » ('j') | 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 "content/common/np_channel_base.h" 5 #include "content/common/np_channel_base.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 21 matching lines...) Expand all
32 bool create_pipe_now, base::WaitableEvent* shutdown_event) { 32 bool create_pipe_now, base::WaitableEvent* shutdown_event) {
33 scoped_refptr<NPChannelBase> channel; 33 scoped_refptr<NPChannelBase> channel;
34 std::string channel_key = channel_handle.name; 34 std::string channel_key = channel_handle.name;
35 ChannelMap::const_iterator iter = g_channels.Get().find(channel_key); 35 ChannelMap::const_iterator iter = g_channels.Get().find(channel_key);
36 if (iter == g_channels.Get().end()) { 36 if (iter == g_channels.Get().end()) {
37 channel = factory(); 37 channel = factory();
38 } else { 38 } else {
39 channel = iter->second; 39 channel = iter->second;
40 } 40 }
41 41
42 DCHECK(channel != NULL); 42 DCHECK(channel.get() != NULL);
43 43
44 if (!channel->channel_valid()) { 44 if (!channel->channel_valid()) {
45 channel->channel_handle_ = channel_handle; 45 channel->channel_handle_ = channel_handle;
46 if (mode & IPC::Channel::MODE_SERVER_FLAG) { 46 if (mode & IPC::Channel::MODE_SERVER_FLAG) {
47 channel->channel_handle_.name = 47 channel->channel_handle_.name =
48 IPC::Channel::GenerateVerifiedChannelID(channel_key); 48 IPC::Channel::GenerateVerifiedChannelID(channel_key);
49 } 49 }
50 channel->mode_ = mode; 50 channel->mode_ = mode;
51 if (channel->Init(ipc_message_loop, create_pipe_now, shutdown_event)) { 51 if (channel->Init(ipc_message_loop, create_pipe_now, shutdown_event)) {
52 g_channels.Get()[channel_key] = channel; 52 g_channels.Get()[channel_key] = channel;
53 } else { 53 } else {
54 channel = NULL; 54 channel = NULL;
55 } 55 }
56 } 56 }
57 57
58 return channel; 58 return channel.get();
59 } 59 }
60 60
61 void NPChannelBase::Broadcast(IPC::Message* message) { 61 void NPChannelBase::Broadcast(IPC::Message* message) {
62 for (ChannelMap::iterator iter = g_channels.Get().begin(); 62 for (ChannelMap::iterator iter = g_channels.Get().begin();
63 iter != g_channels.Get().end(); 63 iter != g_channels.Get().end();
64 ++iter) { 64 ++iter) {
65 iter->second->Send(new IPC::Message(*message)); 65 iter->second->Send(new IPC::Message(*message));
66 } 66 }
67 delete message; 67 delete message;
68 } 68 }
69 69
70 NPChannelBase::NPChannelBase() 70 NPChannelBase::NPChannelBase()
71 : mode_(IPC::Channel::MODE_NONE), 71 : mode_(IPC::Channel::MODE_NONE),
72 non_npobject_count_(0), 72 non_npobject_count_(0),
73 peer_pid_(0), 73 peer_pid_(0),
74 in_remove_route_(false), 74 in_remove_route_(false),
75 channel_valid_(false), 75 channel_valid_(false),
76 in_unblock_dispatch_(0), 76 in_unblock_dispatch_(0),
77 send_unblocking_only_during_unblock_dispatch_(false) { 77 send_unblocking_only_during_unblock_dispatch_(false) {
78 } 78 }
79 79
80 NPChannelBase::~NPChannelBase() { 80 NPChannelBase::~NPChannelBase() {
81 } 81 }
82 82
83 NPChannelBase* NPChannelBase::GetCurrentChannel() { 83 NPChannelBase* NPChannelBase::GetCurrentChannel() {
84 return g_lazy_channel_stack.Pointer()->top(); 84 return g_lazy_channel_stack.Pointer()->top().get();
85 } 85 }
86 86
87 void NPChannelBase::CleanupChannels() { 87 void NPChannelBase::CleanupChannels() {
88 // Make a copy of the references as we can't iterate the map since items will 88 // Make a copy of the references as we can't iterate the map since items will
89 // be removed from it as we clean them up. 89 // be removed from it as we clean them up.
90 std::vector<scoped_refptr<NPChannelBase> > channels; 90 std::vector<scoped_refptr<NPChannelBase> > channels;
91 for (ChannelMap::const_iterator iter = g_channels.Get().begin(); 91 for (ChannelMap::const_iterator iter = g_channels.Get().begin();
92 iter != g_channels.Get().end(); 92 iter != g_channels.Get().end();
93 ++iter) { 93 ++iter) {
94 channels.push_back(iter->second); 94 channels.push_back(iter->second);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 AutoReset<bool> auto_reset_in_remove_route(&in_remove_route_, true); 231 AutoReset<bool> auto_reset_in_remove_route(&in_remove_route_, true);
232 for (ListenerMap::iterator npobj_iter = npobject_listeners_.begin(); 232 for (ListenerMap::iterator npobj_iter = npobject_listeners_.begin();
233 npobj_iter != npobject_listeners_.end(); ++npobj_iter) { 233 npobj_iter != npobject_listeners_.end(); ++npobj_iter) {
234 if (npobj_iter->second) { 234 if (npobj_iter->second) {
235 npobj_iter->second->GetChannelListener()->OnChannelError(); 235 npobj_iter->second->GetChannelListener()->OnChannelError();
236 } 236 }
237 } 237 }
238 238
239 for (ChannelMap::iterator iter = g_channels.Get().begin(); 239 for (ChannelMap::iterator iter = g_channels.Get().begin();
240 iter != g_channels.Get().end(); ++iter) { 240 iter != g_channels.Get().end(); ++iter) {
241 if (iter->second == this) { 241 if (iter->second.get() == this) {
242 g_channels.Get().erase(iter); 242 g_channels.Get().erase(iter);
243 return; 243 return;
244 } 244 }
245 } 245 }
246 246
247 NOTREACHED(); 247 NOTREACHED();
248 } 248 }
249 } 249 }
250 250
251 bool NPChannelBase::OnControlMessageReceived(const IPC::Message& msg) { 251 bool NPChannelBase::OnControlMessageReceived(const IPC::Message& msg) {
252 NOTREACHED() << 252 NOTREACHED() <<
253 "should override in subclass if you care about control messages"; 253 "should override in subclass if you care about control messages";
254 return false; 254 return false;
255 } 255 }
256 256
257 void NPChannelBase::OnChannelError() { 257 void NPChannelBase::OnChannelError() {
258 channel_valid_ = false; 258 channel_valid_ = false;
259 259
260 // TODO(shess): http://crbug.com/97285 260 // TODO(shess): http://crbug.com/97285
261 // Once an error is seen on a channel, remap the channel to prevent 261 // Once an error is seen on a channel, remap the channel to prevent
262 // it from being vended again. Keep the channel in the map so 262 // it from being vended again. Keep the channel in the map so
263 // RemoveRoute() can clean things up correctly. 263 // RemoveRoute() can clean things up correctly.
264 for (ChannelMap::iterator iter = g_channels.Get().begin(); 264 for (ChannelMap::iterator iter = g_channels.Get().begin();
265 iter != g_channels.Get().end(); ++iter) { 265 iter != g_channels.Get().end(); ++iter) {
266 if (iter->second == this) { 266 if (iter->second.get() == this) {
267 // Insert new element before invalidating |iter|. 267 // Insert new element before invalidating |iter|.
268 g_channels.Get()[iter->first + "-error"] = iter->second; 268 g_channels.Get()[iter->first + "-error"] = iter->second;
269 g_channels.Get().erase(iter); 269 g_channels.Get().erase(iter);
270 break; 270 break;
271 } 271 }
272 } 272 }
273 } 273 }
274 274
275 NPObject* NPChannelBase::GetExistingNPObjectProxy(int route_id) { 275 NPObject* NPChannelBase::GetExistingNPObjectProxy(int route_id) {
276 ProxyMap::iterator iter = proxy_map_.find(route_id); 276 ProxyMap::iterator iter = proxy_map_.find(route_id);
(...skipping 20 matching lines...) Expand all
297 NPObject* object) { 297 NPObject* object) {
298 DCHECK(object != NULL); 298 DCHECK(object != NULL);
299 stub_map_.erase(object); 299 stub_map_.erase(object);
300 } 300 }
301 301
302 void NPChannelBase::RemoveMappingForNPObjectProxy(int route_id) { 302 void NPChannelBase::RemoveMappingForNPObjectProxy(int route_id) {
303 proxy_map_.erase(route_id); 303 proxy_map_.erase(route_id);
304 } 304 }
305 305
306 } // namespace content 306 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/gpu/gpu_child_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698