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

Side by Side Diff: webkit/plugins/ppapi/npobject_var.h

Issue 20165002: Move webkit/plugins/ppapi to content/renderer/pepper. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: more more clang fun Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/npapi_glue.cc ('k') | webkit/plugins/ppapi/npobject_var.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_
6 #define WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "ppapi/c/pp_instance.h"
12 #include "ppapi/shared_impl/var.h"
13 #include "webkit/plugins/webkit_plugins_export.h"
14
15 typedef struct NPObject NPObject;
16 typedef struct _NPVariant NPVariant;
17 typedef void* NPIdentifier;
18
19 namespace ppapi {
20
21 // NPObjectVar -----------------------------------------------------------------
22
23 // Represents a JavaScript object Var. By itself, this represents random
24 // NPObjects that a given plugin (identified by the resource's module) wants to
25 // reference. If two different modules reference the same NPObject (like the
26 // "window" object), then there will be different NPObjectVar's (and hence
27 // PP_Var IDs) for each module. This allows us to track all references owned by
28 // a given module and free them when the plugin exits independently of other
29 // plugins that may be running at the same time.
30 class NPObjectVar : public Var {
31 public:
32 // You should always use FromNPObject to create an NPObjectVar. This function
33 // guarantees that we maintain the 1:1 mapping between NPObject and
34 // NPObjectVar.
35 NPObjectVar(PP_Instance instance, NPObject* np_object);
36
37 virtual ~NPObjectVar();
38
39 // Var overrides.
40 virtual NPObjectVar* AsNPObjectVar() OVERRIDE;
41 virtual PP_VarType GetType() const OVERRIDE;
42
43 // Returns the underlying NPObject corresponding to this NPObjectVar.
44 // Guaranteed non-NULL.
45 NPObject* np_object() const { return np_object_; }
46
47 // Notification that the instance was deleted, the internal reference will be
48 // zeroed out.
49 void InstanceDeleted();
50
51 // Possibly 0 if the object has outlived its instance.
52 PP_Instance pp_instance() const { return pp_instance_; }
53
54 // Helper function that converts a PP_Var to an object. This will return NULL
55 // if the PP_Var is not of object type or the object is invalid.
56 WEBKIT_PLUGINS_EXPORT static scoped_refptr<NPObjectVar> FromPPVar(PP_Var var);
57
58 private:
59 // Possibly 0 if the object has outlived its instance.
60 PP_Instance pp_instance_;
61
62 // Guaranteed non-NULL, this is the underlying object used by WebKit. We
63 // hold a reference to this object.
64 NPObject* np_object_;
65
66 DISALLOW_COPY_AND_ASSIGN(NPObjectVar);
67 };
68
69 } // namespace
70
71 #endif // WEBKIT_PLUGINS_PPAPI_NPOBJECT_VAR_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/npapi_glue.cc ('k') | webkit/plugins/ppapi/npobject_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698