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

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

Issue 568793002: PPAPI: Fix GetBrowserInterface race conditions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lockless approach Created 6 years, 3 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
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/plugin_globals.h" 5 #include "ppapi/proxy/plugin_globals.h"
6 6
7 #include "base/task_runner.h" 7 #include "base/task_runner.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 #include "ipc/ipc_sender.h" 10 #include "ipc/ipc_sender.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 GetMainThreadMessageLoop()->PostDelayedTask( 185 GetMainThreadMessageLoop()->PostDelayedTask(
186 FROM_HERE, 186 FROM_HERE,
187 RunWhileLocked(base::Bind(&PluginGlobals::OnReleaseKeepaliveThrottle, 187 RunWhileLocked(base::Bind(&PluginGlobals::OnReleaseKeepaliveThrottle,
188 weak_factory_.GetWeakPtr())), 188 weak_factory_.GetWeakPtr())),
189 base::TimeDelta::FromMilliseconds( 189 base::TimeDelta::FromMilliseconds(
190 keepalive_throttle_interval_milliseconds_)); 190 keepalive_throttle_interval_milliseconds_));
191 } 191 }
192 } 192 }
193 193
194 IPC::Sender* PluginGlobals::GetBrowserSender() { 194 IPC::Sender* PluginGlobals::GetBrowserSender() {
195 if (!browser_sender_.get()) { 195 // CAUTION: This funciton is called without the ProxyLock. See also
teravest 2014/09/12 19:08:27 s/funciton/function
dmichael (off chromium) 2014/09/12 20:44:00 Done.
196 browser_sender_.reset( 196 // InterfaceList::GetInterfaceForPPB.
197 new BrowserSender(plugin_proxy_delegate_->GetBrowserSender()));
198 }
199
200 return browser_sender_.get(); 197 return browser_sender_.get();
201 } 198 }
202 199
203 std::string PluginGlobals::GetUILanguage() { 200 std::string PluginGlobals::GetUILanguage() {
204 return plugin_proxy_delegate_->GetUILanguage(); 201 return plugin_proxy_delegate_->GetUILanguage();
205 } 202 }
206 203
207 void PluginGlobals::SetActiveURL(const std::string& url) { 204 void PluginGlobals::SetActiveURL(const std::string& url) {
208 plugin_proxy_delegate_->SetActiveURL(url); 205 plugin_proxy_delegate_->SetActiveURL(url);
209 } 206 }
210 207
211 PP_Resource PluginGlobals::CreateBrowserFont( 208 PP_Resource PluginGlobals::CreateBrowserFont(
212 Connection connection, 209 Connection connection,
213 PP_Instance instance, 210 PP_Instance instance,
214 const PP_BrowserFont_Trusted_Description& desc, 211 const PP_BrowserFont_Trusted_Description& desc,
215 const ppapi::Preferences& prefs) { 212 const ppapi::Preferences& prefs) {
216 return plugin_proxy_delegate_->CreateBrowserFont( 213 return plugin_proxy_delegate_->CreateBrowserFont(
217 connection, instance, desc, prefs); 214 connection, instance, desc, prefs);
218 } 215 }
219 216
217 void PluginGlobals::SetPluginProxyDelegate(PluginProxyDelegate* delegate) {
218 plugin_proxy_delegate_ = delegate;
219 browser_sender_.reset(
220 new BrowserSender(plugin_proxy_delegate_->GetBrowserSender()));
221 }
222
220 MessageLoopResource* PluginGlobals::loop_for_main_thread() { 223 MessageLoopResource* PluginGlobals::loop_for_main_thread() {
221 return loop_for_main_thread_.get(); 224 return loop_for_main_thread_.get();
222 } 225 }
223 226
224 void PluginGlobals::set_keepalive_throttle_interval_milliseconds(unsigned i) { 227 void PluginGlobals::set_keepalive_throttle_interval_milliseconds(unsigned i) {
225 keepalive_throttle_interval_milliseconds_ = i; 228 keepalive_throttle_interval_milliseconds_ = i;
226 } 229 }
227 230
228 bool PluginGlobals::IsPluginGlobals() const { 231 bool PluginGlobals::IsPluginGlobals() const {
229 return true; 232 return true;
230 } 233 }
231 234
232 void PluginGlobals::OnReleaseKeepaliveThrottle() { 235 void PluginGlobals::OnReleaseKeepaliveThrottle() {
233 ppapi::ProxyLock::AssertAcquiredDebugOnly(); 236 ppapi::ProxyLock::AssertAcquiredDebugOnly();
234 plugin_recently_active_ = false; 237 plugin_recently_active_ = false;
235 } 238 }
236 239
237 } // namespace proxy 240 } // namespace proxy
238 } // namespace ppapi 241 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698