| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_resource_tracker.h" | 5 #include "webkit/glue/plugins/pepper_resource_tracker.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 return result->second.first; | 22 return result->second.first; |
| 23 } | 23 } |
| 24 | 24 |
| 25 ResourceTracker::ResourceTracker() | 25 ResourceTracker::ResourceTracker() |
| 26 : last_id_(0) { | 26 : last_id_(0) { |
| 27 } | 27 } |
| 28 | 28 |
| 29 ResourceTracker::~ResourceTracker() { | 29 ResourceTracker::~ResourceTracker() { |
| 30 } | 30 } |
| 31 | 31 |
| 32 // static |
| 33 ResourceTracker* ResourceTracker::Get() { |
| 34 return Singleton<ResourceTracker>::get(); |
| 35 } |
| 36 |
| 32 PP_Resource ResourceTracker::AddResource(Resource* resource) { | 37 PP_Resource ResourceTracker::AddResource(Resource* resource) { |
| 33 // If the plugin manages to create 4B resources... | 38 // If the plugin manages to create 4B resources... |
| 34 if (last_id_ == std::numeric_limits<PP_Resource>::max()) { | 39 if (last_id_ == std::numeric_limits<PP_Resource>::max()) { |
| 35 return 0; | 40 return 0; |
| 36 } | 41 } |
| 37 // Add the resource with plugin use-count 1. | 42 // Add the resource with plugin use-count 1. |
| 38 ++last_id_; | 43 ++last_id_; |
| 39 live_resources_.insert(std::make_pair(last_id_, std::make_pair(resource, 1))); | 44 live_resources_.insert(std::make_pair(last_id_, std::make_pair(resource, 1))); |
| 40 return last_id_; | 45 return last_id_; |
| 41 } | 46 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 163 } |
| 159 | 164 |
| 160 PluginModule* ResourceTracker::GetModule(PP_Module module) { | 165 PluginModule* ResourceTracker::GetModule(PP_Module module) { |
| 161 ModuleMap::iterator found = module_map_.find(module); | 166 ModuleMap::iterator found = module_map_.find(module); |
| 162 if (found == module_map_.end()) | 167 if (found == module_map_.end()) |
| 163 return NULL; | 168 return NULL; |
| 164 return found->second; | 169 return found->second; |
| 165 } | 170 } |
| 166 | 171 |
| 167 } // namespace pepper | 172 } // namespace pepper |
| OLD | NEW |