| Index: src/shared/ppapi_proxy/plugin_resource_tracker.cc
|
| diff --git a/src/shared/ppapi_proxy/plugin_resource_tracker.cc b/src/shared/ppapi_proxy/plugin_resource_tracker.cc
|
| index 48bd48319f5ff500bad93bab773cfcf375aab3f4..dbefc12275741ca9ecd8a299a74fc676156acca6 100644
|
| --- a/src/shared/ppapi_proxy/plugin_resource_tracker.cc
|
| +++ b/src/shared/ppapi_proxy/plugin_resource_tracker.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2010 The Native Client Authors. All rights reserved.
|
| +// Copyright (c) 2011 The Native Client Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -11,13 +11,14 @@
|
| #include "native_client/src/include/portability.h"
|
| #include "native_client/src/shared/ppapi_proxy/plugin_globals.h"
|
| #include "native_client/src/shared/ppapi_proxy/plugin_resource.h"
|
| +#include "native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h"
|
| #include "native_client/src/third_party/ppapi/c/pp_resource.h"
|
| -#include "srpcgen/ppb_rpc.h"
|
|
|
| namespace ppapi_proxy {
|
|
|
| PluginResourceTracker::ResourceAndRefCounts::ResourceAndRefCounts(
|
| - PluginResource* r) : resource(r), browser_refcount(1), plugin_refcount(1) {
|
| + PluginResource* r, size_t browser_count)
|
| + : resource(r), browser_refcount(browser_count), plugin_refcount(1) {
|
| }
|
|
|
| PluginResourceTracker::ResourceAndRefCounts::~ResourceAndRefCounts() {
|
| @@ -32,13 +33,15 @@ scoped_refptr<PluginResource> PluginResourceTracker::GetExistingResource(
|
| return result->second.resource;
|
| }
|
|
|
| -PluginResourceTracker::PluginResourceTracker() : last_id_(0) {
|
| +PluginResourceTracker::PluginResourceTracker() {
|
| }
|
|
|
| void PluginResourceTracker::AddResource(PluginResource* resource,
|
| - PP_Resource id) {
|
| + PP_Resource id,
|
| + size_t browser_refcount) {
|
| // Add the resource with plugin use-count 1.
|
| - live_resources_.insert(std::make_pair(id, ResourceAndRefCounts(resource)));
|
| + live_resources_.insert(
|
| + std::make_pair(id, ResourceAndRefCounts(resource, browser_refcount)));
|
| }
|
|
|
| bool PluginResourceTracker::AddRefResource(PP_Resource res) {
|
| @@ -50,6 +53,12 @@ bool PluginResourceTracker::AddRefResource(PP_Resource res) {
|
| // once per every byte in the address space could have just as well unrefed
|
| // one time too many.
|
| i->second.plugin_refcount++;
|
| + if (i->second.browser_refcount == 0) {
|
| + // If we don't currently have any refcount with the browser, try to
|
| + // obtain one.
|
| + i->second.browser_refcount++;
|
| + ObtainBrowserResource(res);
|
| + }
|
| return true;
|
| }
|
| }
|
| @@ -60,7 +69,6 @@ bool PluginResourceTracker::UnrefResource(PP_Resource res) {
|
| i->second.plugin_refcount--;
|
| if (0 == i->second.plugin_refcount) {
|
| size_t browser_refcount = i->second.browser_refcount;
|
| - i->second.resource->StoppedTracking();
|
| live_resources_.erase(i);
|
|
|
| // Release all browser references.
|
| @@ -82,7 +90,7 @@ void PluginResourceTracker::ObtainBrowserResource(PP_Resource res) {
|
| void PluginResourceTracker::ReleaseBrowserResource(PP_Resource res,
|
| size_t browser_refcount) {
|
| // Release all browser references.
|
| - if (res) {
|
| + if (res && (browser_refcount > 0)) {
|
| NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
|
| PpbCoreRpcClient::ReleaseResourceMultipleTimes(channel, res,
|
| browser_refcount);
|
|
|