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

Side by Side Diff: webkit/glue/plugins/pepper_resource_tracker.cc

Issue 5581008: Add a new GetInstance() method for singleton classes, take 2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« base/global_descriptors_posix.h ('K') | « webkit/glue/plugins/pepper_resource_tracker.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698