| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "native_client/src/shared/ppapi_proxy/plugin_resource_tracker.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_resource_tracker.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 scoped_refptr<PluginResource> PluginResourceTracker::GetExistingResource( | 34 scoped_refptr<PluginResource> PluginResourceTracker::GetExistingResource( |
| 35 PP_Resource res) const { | 35 PP_Resource res) const { |
| 36 ResourceMap::const_iterator result = live_resources_.find(res); | 36 ResourceMap::const_iterator result = live_resources_.find(res); |
| 37 if (result == live_resources_.end()) | 37 if (result == live_resources_.end()) |
| 38 return scoped_refptr<PluginResource>(); | 38 return scoped_refptr<PluginResource>(); |
| 39 else | 39 else |
| 40 return result->second.resource; | 40 return result->second.resource; |
| 41 } | 41 } |
| 42 | 42 |
| 43 PluginResourceTracker::PluginResourceTracker() { | 43 PluginResourceTracker::PluginResourceTracker() : last_id_(0) { |
| 44 } | 44 } |
| 45 | 45 |
| 46 void PluginResourceTracker::AddResource(PluginResource* resource, | 46 void PluginResourceTracker::AddResource(PluginResource* resource, |
| 47 PP_Resource id, | 47 PP_Resource id, |
| 48 size_t browser_refcount) { | 48 size_t browser_refcount) { |
| 49 // Add the resource with plugin use-count 1. | 49 // Add the resource with plugin use-count 1. |
| 50 live_resources_.insert( | 50 live_resources_.insert( |
| 51 std::make_pair(id, ResourceAndRefCounts(resource, browser_refcount))); | 51 std::make_pair(id, ResourceAndRefCounts(resource, browser_refcount))); |
| 52 } | 52 } |
| 53 | 53 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // Release all browser references. | 99 // Release all browser references. |
| 100 if (res && (browser_refcount > 0)) { | 100 if (res && (browser_refcount > 0)) { |
| 101 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); | 101 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); |
| 102 PpbCoreRpcClient::ReleaseResourceMultipleTimes(channel, res, | 102 PpbCoreRpcClient::ReleaseResourceMultipleTimes(channel, res, |
| 103 browser_refcount); | 103 browser_refcount); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace ppapi_proxy | 107 } // namespace ppapi_proxy |
| 108 | 108 |
| OLD | NEW |