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

Unified Diff: ppapi/proxy/plugin_resource_tracker.cc

Issue 6282007: First pass at making the proxy handle multiple renderers. This associates the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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_resource_tracker.h ('k') | ppapi/proxy/plugin_var_serialization_rules.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/plugin_resource_tracker.cc
===================================================================
--- ppapi/proxy/plugin_resource_tracker.cc (revision 71973)
+++ ppapi/proxy/plugin_resource_tracker.cc (working copy)
@@ -5,6 +5,7 @@
#include "ppapi/proxy/plugin_resource_tracker.h"
#include "base/logging.h"
+#include "base/singleton.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/plugin_resource.h"
@@ -38,13 +39,17 @@
return *this;
}
-PluginResourceTracker::PluginResourceTracker(PluginDispatcher* dispatcher)
- : dispatcher_(dispatcher) {
+PluginResourceTracker::PluginResourceTracker() {
}
PluginResourceTracker::~PluginResourceTracker() {
}
+// static
+PluginResourceTracker* PluginResourceTracker::GetInstance() {
+ return Singleton<PluginResourceTracker>::get();
+}
+
PluginResource* PluginResourceTracker::GetResourceObject(
PP_Resource pp_resource) {
ResourceMap::iterator found = resource_map_.find(pp_resource);
@@ -81,8 +86,8 @@
// in the plugin for the additional ref, and then a Release in the renderer
// because the code in the renderer addrefed on behalf of the caller.
found->second.ref_count++;
- dispatcher_->Send(new PpapiHostMsg_PPBCore_ReleaseResource(
- INTERFACE_ID_PPB_CORE, resource));
+
+ SendReleaseResourceToHost(resource, found->second.resource.get());
return true;
}
@@ -94,13 +99,24 @@
return;
found->second.ref_count--;
if (found->second.ref_count == 0) {
- if (notify_browser_on_release) {
- dispatcher_->Send(new PpapiHostMsg_PPBCore_ReleaseResource(
- INTERFACE_ID_PPB_CORE, resource));
- }
+ if (notify_browser_on_release)
+ SendReleaseResourceToHost(resource, found->second.resource.get());
resource_map_.erase(found);
}
}
+void PluginResourceTracker::SendReleaseResourceToHost(
+ PP_Resource resource_id,
+ PluginResource* resource) {
+ PluginDispatcher* dispatcher =
+ PluginDispatcher::GetForInstance(resource->instance());
+ if (dispatcher) {
+ dispatcher->Send(new PpapiHostMsg_PPBCore_ReleaseResource(
+ INTERFACE_ID_PPB_CORE, resource_id));
+ } else {
+ NOTREACHED();
+ }
+}
+
} // namespace proxy
} // namespace pp
« no previous file with comments | « ppapi/proxy/plugin_resource_tracker.h ('k') | ppapi/proxy/plugin_var_serialization_rules.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698