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

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

Issue 2413313005: Reduce FOR_EACH_OBSERVER usage in ppapi (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | 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/host_dispatcher.h" 5 #include "ppapi/proxy/host_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Don't allow sending sync messages during module shutdown. Seee the "else" 149 // Don't allow sending sync messages during module shutdown. Seee the "else"
150 // block below for why. 150 // block below for why.
151 CHECK(!PP_ToBool(ppb_proxy()->IsInModuleDestructor(pp_module()))); 151 CHECK(!PP_ToBool(ppb_proxy()->IsInModuleDestructor(pp_module())));
152 152
153 // Prevent the dispatcher from going away during sync calls. Scenarios 153 // Prevent the dispatcher from going away during sync calls. Scenarios
154 // where this could happen include a Send for a sync message which while 154 // where this could happen include a Send for a sync message which while
155 // waiting for the reply, dispatches an incoming ExecuteScript call which 155 // waiting for the reply, dispatches an incoming ExecuteScript call which
156 // destroys the plugin module and in turn the dispatcher. 156 // destroys the plugin module and in turn the dispatcher.
157 ScopedModuleReference scoped_ref(this); 157 ScopedModuleReference scoped_ref(this);
158 158
159 FOR_EACH_OBSERVER(SyncMessageStatusObserver, sync_status_observer_list_, 159 for (auto& observer : sync_status_observer_list_)
160 BeginBlockOnSyncMessage()); 160 observer.BeginBlockOnSyncMessage();
161 bool result = Dispatcher::Send(msg); 161 bool result = Dispatcher::Send(msg);
162 FOR_EACH_OBSERVER(SyncMessageStatusObserver, sync_status_observer_list_, 162 for (auto& observer : sync_status_observer_list_)
163 EndBlockOnSyncMessage()); 163 observer.EndBlockOnSyncMessage();
164 164
165 return result; 165 return result;
166 } else { 166 } else {
167 // We don't want to have a scoped ref for async message cases since since 167 // We don't want to have a scoped ref for async message cases since since
168 // async messages are sent during module desruction. In this case, the 168 // async messages are sent during module desruction. In this case, the
169 // module will have a 0 refcount and addrefing and releasing it will 169 // module will have a 0 refcount and addrefing and releasing it will
170 // reenter the destructor and it will crash. 170 // reenter the destructor and it will crash.
171 return Dispatcher::Send(msg); 171 return Dispatcher::Send(msg);
172 } 172 }
173 } 173 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 } 284 }
285 285
286 ScopedModuleReference::~ScopedModuleReference() { 286 ScopedModuleReference::~ScopedModuleReference() {
287 if (dispatcher_) 287 if (dispatcher_)
288 dispatcher_->ppb_proxy()->ReleaseModule(dispatcher_->pp_module()); 288 dispatcher_->ppb_proxy()->ReleaseModule(dispatcher_->pp_module());
289 } 289 }
290 290
291 } // namespace proxy 291 } // namespace proxy
292 } // namespace ppapi 292 } // namespace ppapi
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698