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

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

Issue 19744007: Create a public API around webkit::ppapi::PluginInstance and use it in chrome. After this, webkit/p… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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
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 #ifndef WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_
6 #define WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_ 6 #define WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 11
12 struct PP_Var; 12 struct PP_Var;
13 struct PPP_Class_Deprecated; 13 struct PPP_Class_Deprecated;
14 typedef struct NPObject NPObject; 14 typedef struct NPObject NPObject;
15 typedef struct _NPVariant NPVariant; 15 typedef struct _NPVariant NPVariant;
16 16
17 namespace webkit { 17 namespace webkit {
18 namespace ppapi { 18 namespace ppapi {
19 19
20 class PluginInstance; 20 class PluginInstanceImpl;
21 21
22 // A PluginObject is a JS-accessible object implemented by the plugin. 22 // A PluginObject is a JS-accessible object implemented by the plugin.
23 // 23 //
24 // In contrast, a var of type PP_VARTYPE_OBJECT is a reference to a JS object, 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. 25 // which might be implemented by the plugin (here) or by the JS engine.
26 class PluginObject { 26 class PluginObject {
27 public: 27 public:
28 virtual ~PluginObject(); 28 virtual ~PluginObject();
29 29
30 // Allocates a new PluginObject and returns it as a PP_Var with a 30 // Allocates a new PluginObject and returns it as a PP_Var with a
31 // refcount of 1. 31 // refcount of 1.
32 static PP_Var Create(PluginInstance* instance, 32 static PP_Var Create(PluginInstanceImpl* instance,
33 const PPP_Class_Deprecated* ppp_class, 33 const PPP_Class_Deprecated* ppp_class,
34 void* ppp_class_data); 34 void* ppp_class_data);
35 35
36 PluginInstance* instance() const { return instance_; } 36 PluginInstanceImpl* instance() const { return instance_; }
37 37
38 const PPP_Class_Deprecated* ppp_class() { return ppp_class_; } 38 const PPP_Class_Deprecated* ppp_class() { return ppp_class_; }
39 void* ppp_class_data() { return ppp_class_data_; }; 39 void* ppp_class_data() { return ppp_class_data_; };
40 40
41 NPObject* GetNPObject() const; 41 NPObject* GetNPObject() const;
42 42
43 // Returns true if the given var is an object implemented by the same plugin 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, 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 45 // returns true and places the class data into |*ppp_class_data| (which can
46 // optionally be NULL if no class data is desired). 46 // optionally be NULL if no class data is desired).
(...skipping 14 matching lines...) Expand all
61 static NPObject* AllocateObjectWrapper(); 61 static NPObject* AllocateObjectWrapper();
62 62
63 private: 63 private:
64 struct NPObjectWrapper; 64 struct NPObjectWrapper;
65 65
66 // This object must be created using the CreateObject function of the which 66 // This object must be created using the CreateObject function of the which
67 // will set up the correct NPObject. 67 // will set up the correct NPObject.
68 // 68 //
69 // The NPObjectWrapper (an NPObject) should already have the reference 69 // The NPObjectWrapper (an NPObject) should already have the reference
70 // incremented on it, and this class will take ownership of that reference. 70 // incremented on it, and this class will take ownership of that reference.
71 PluginObject(PluginInstance* instance, 71 PluginObject(PluginInstanceImpl* instance,
72 NPObjectWrapper* object_wrapper, 72 NPObjectWrapper* object_wrapper,
73 const PPP_Class_Deprecated* ppp_class, 73 const PPP_Class_Deprecated* ppp_class,
74 void* ppp_class_data); 74 void* ppp_class_data);
75 75
76 PluginInstance* instance_; 76 PluginInstanceImpl* instance_;
77 77
78 // Holds a pointer to the NPObject wrapper backing the var. This class 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 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. 80 // refcounted. When the type is not an object, this value will be NULL.
81 // 81 //
82 // We don't actually own this pointer, it's the NPObject that actually 82 // We don't actually own this pointer, it's the NPObject that actually
83 // owns us. 83 // owns us.
84 NPObjectWrapper* object_wrapper_; 84 NPObjectWrapper* object_wrapper_;
85 85
86 const PPP_Class_Deprecated* ppp_class_; 86 const PPP_Class_Deprecated* ppp_class_;
87 void* ppp_class_data_; 87 void* ppp_class_data_;
88 88
89 DISALLOW_COPY_AND_ASSIGN(PluginObject); 89 DISALLOW_COPY_AND_ASSIGN(PluginObject);
90 }; 90 };
91 91
92 } // namespace ppapi 92 } // namespace ppapi
93 } // namespace webkit 93 } // namespace webkit
94 94
95 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_ 95 #endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698