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

Unified 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: Review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/proxy/plugin_globals.h ('k') | ppapi/proxy/ppapi_proxy_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/plugin_globals.cc
diff --git a/ppapi/proxy/plugin_globals.cc b/ppapi/proxy/plugin_globals.cc
index 82e16ffe328582f2a5bade188fad7057d1e4e4be..63bcb4490bca12359a800cc2adf6a755fe3c863a 100644
--- a/ppapi/proxy/plugin_globals.cc
+++ b/ppapi/proxy/plugin_globals.cc
@@ -192,11 +192,13 @@ void PluginGlobals::MarkPluginIsActive() {
}
IPC::Sender* PluginGlobals::GetBrowserSender() {
- if (!browser_sender_.get()) {
- browser_sender_.reset(
- new BrowserSender(plugin_proxy_delegate_->GetBrowserSender()));
- }
-
+ // CAUTION: This function is called without the ProxyLock. See also
+ // InterfaceList::GetInterfaceForPPB.
+ //
+ // See also SetPluginProxyDelegate. That initializes browser_sender_ before
+ // the plugin can start threads, and it may be cleared after the
+ // plugin has torn down threads. So this pointer is expected to remain valid
+ // during the lifetime of the plugin.
return browser_sender_.get();
}
@@ -217,6 +219,19 @@ PP_Resource PluginGlobals::CreateBrowserFont(
connection, instance, desc, prefs);
}
+void PluginGlobals::SetPluginProxyDelegate(PluginProxyDelegate* delegate) {
+ DCHECK(delegate && !plugin_proxy_delegate_);
+ plugin_proxy_delegate_ = delegate;
+ browser_sender_.reset(
+ new BrowserSender(plugin_proxy_delegate_->GetBrowserSender()));
+}
+
+void PluginGlobals::ResetPluginProxyDelegate() {
+ DCHECK(plugin_proxy_delegate_);
+ plugin_proxy_delegate_ = NULL;
+ browser_sender_.reset();
+}
+
MessageLoopResource* PluginGlobals::loop_for_main_thread() {
return loop_for_main_thread_.get();
}
« no previous file with comments | « ppapi/proxy/plugin_globals.h ('k') | ppapi/proxy/ppapi_proxy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698