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

Unified Diff: webkit/glue/plugins/pepper_resource_tracker.h

Issue 1697008: New Pepper API implementation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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 | « webkit/glue/plugins/pepper_resource.cc ('k') | webkit/glue/plugins/pepper_resource_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/pepper_resource_tracker.h
===================================================================
--- webkit/glue/plugins/pepper_resource_tracker.h (revision 0)
+++ webkit/glue/plugins/pepper_resource_tracker.h (revision 0)
@@ -0,0 +1,57 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
+#define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
+
+#include <set>
+
+#include "base/atomic_sequence_num.h"
+#include "base/basictypes.h"
+#include "base/lock.h"
+#include "base/ref_counted.h"
+#include "base/singleton.h"
+
+typedef struct _pp_Resource PP_Resource;
+
+namespace pepper {
+
+class Resource;
+
+// This class maintains a global list of all live pepper resources. It allows
+// us to check resource ID validity and to map them to a specific module.
+//
+// This object is threadsafe.
+class ResourceTracker {
+ public:
+ // Returns the pointer to the singleton object.
+ static ResourceTracker* Get();
+
+ // The returned pointer will be NULL if there is no resource.
+ Resource* GetResource(PP_Resource res) const;
+
+ // Adds the given resource to the tracker and assigns it a resource ID. The
+ // assigned resource ID will be returned.
+ void AddResource(Resource* resource);
+
+ void DeleteResource(Resource* resource);
+
+ private:
+ friend struct DefaultSingletonTraits<ResourceTracker>;
+
+ ResourceTracker();
+ ~ResourceTracker();
+
+ // Hold this lock when accessing this object's members.
+ mutable Lock lock_;
+
+ typedef std::set<Resource*> ResourceSet;
+ ResourceSet live_resources_;
+
+ DISALLOW_COPY_AND_ASSIGN(ResourceTracker);
+};
+
+} // namespace pepper
+
+#endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
Property changes on: webkit/glue/plugins/pepper_resource_tracker.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « webkit/glue/plugins/pepper_resource.cc ('k') | webkit/glue/plugins/pepper_resource_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698