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

Side by Side Diff: webkit/plugins/ppapi/plugin_object.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, 4 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/plugin_module.cc ('k') | webkit/plugins/ppapi/plugin_object.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) 2010 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_PLUGIN_OBJECT_H_
6 #define WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11
12 struct PP_Var;
13 struct PPP_Class_Deprecated;
14 typedef struct NPObject NPObject;
15 typedef struct _NPVariant NPVariant;
16
17 namespace webkit {
18 namespace ppapi {
19
20 class PluginInstanceImpl;
21
22 // A PluginObject is a JS-accessible object implemented by the plugin.
23 //
24 // In contrast, a var of type PP_VARTYPE_OBJECT is a reference to a JS object,
25 // which might be implemented by the plugin (here) or by the JS engine.
26 class PluginObject {
27 public:
28 virtual ~PluginObject();
29
30 // Allocates a new PluginObject and returns it as a PP_Var with a
31 // refcount of 1.
32 static PP_Var Create(PluginInstanceImpl* instance,
33 const PPP_Class_Deprecated* ppp_class,
34 void* ppp_class_data);
35
36 PluginInstanceImpl* instance() const { return instance_; }
37
38 const PPP_Class_Deprecated* ppp_class() { return ppp_class_; }
39 void* ppp_class_data() { return ppp_class_data_; };
40
41 NPObject* GetNPObject() const;
42
43 // Returns true if the given var is an object implemented by the same plugin
44 // that owns the var object, and that the class matches. If it matches,
45 // returns true and places the class data into |*ppp_class_data| (which can
46 // optionally be NULL if no class data is desired).
47 static bool IsInstanceOf(NPObject* np_object,
48 const PPP_Class_Deprecated* ppp_class,
49 void** ppp_class_data);
50
51 // Converts the given NPObject to the corresponding ObjectVar.
52 //
53 // The given NPObject must be one corresponding to a PluginObject or this
54 // will crash. If the object is a PluginObject but the plugin has gone
55 // away (the object could still be alive because of a reference from JS),
56 // then the return value will be NULL.
57 static PluginObject* FromNPObject(NPObject* object);
58
59 // Allocates a plugin wrapper object and returns it as an NPObject. This is
60 // used internally only.
61 static NPObject* AllocateObjectWrapper();
62
63 private:
64 struct NPObjectWrapper;
65
66 // This object must be created using the CreateObject function of the which
67 // will set up the correct NPObject.
68 //
69 // The NPObjectWrapper (an NPObject) should already have the reference
70 // incremented on it, and this class will take ownership of that reference.
71 PluginObject(PluginInstanceImpl* instance,
72 NPObjectWrapper* object_wrapper,
73 const PPP_Class_Deprecated* ppp_class,
74 void* ppp_class_data);
75
76 PluginInstanceImpl* instance_;
77
78 // Holds a pointer to the NPObject wrapper backing the var. This class
79 // derives from NPObject and we hold a reference to it, so it must be
80 // refcounted. When the type is not an object, this value will be NULL.
81 //
82 // We don't actually own this pointer, it's the NPObject that actually
83 // owns us.
84 NPObjectWrapper* object_wrapper_;
85
86 const PPP_Class_Deprecated* ppp_class_;
87 void* ppp_class_data_;
88
89 DISALLOW_COPY_AND_ASSIGN(PluginObject);
90 };
91
92 } // namespace ppapi
93 } // namespace webkit
94
95 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/plugin_module.cc ('k') | webkit/plugins/ppapi/plugin_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698