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

Side by Side Diff: content/renderer/pepper/v8object_var.h

Issue 400823004: gin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « content/renderer/pepper/v8_var_converter.cc ('k') | content/renderer/pepper/v8object_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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 CONTENT_RENDERER_PEPPER_NPOBJECT_VAR_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_
6 #define CONTENT_RENDERER_PEPPER_NPOBJECT_VAR_H_ 6 #define CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "content/common/content_export.h"
11 #include "ppapi/c/pp_instance.h" 12 #include "ppapi/c/pp_instance.h"
12 #include "ppapi/shared_impl/var.h" 13 #include "ppapi/shared_impl/var.h"
13 #include "content/common/content_export.h" 14 #include "v8/include/v8.h"
14
15 typedef struct NPObject NPObject;
16 typedef struct _NPVariant NPVariant;
17 typedef void* NPIdentifier;
18 15
19 namespace ppapi { 16 namespace ppapi {
20 17
21 // NPObjectVar ----------------------------------------------------------------- 18 // V8ObjectVar -----------------------------------------------------------------
22 19
23 // Represents a JavaScript object Var. By itself, this represents random 20 // Represents a JavaScript object Var. By itself, this represents random
24 // NPObjects that a given plugin (identified by the resource's module) wants to 21 // 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 22 // reference. If two different modules reference the same NPObject (like the
26 // "window" object), then there will be different NPObjectVar's (and hence 23 // "window" object), then there will be different V8ObjectVar's (and hence
27 // PP_Var IDs) for each module. This allows us to track all references owned by 24 // 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 25 // a given module and free them when the plugin exits independently of other
29 // plugins that may be running at the same time. 26 // plugins that may be running at the same time.
30 class NPObjectVar : public Var { 27 class V8ObjectVar : public Var {
31 public: 28 public:
32 // You should always use FromNPObject to create an NPObjectVar. This function 29 struct Untracked {};
33 // guarantees that we maintain the 1:1 mapping between NPObject and 30
34 // NPObjectVar. 31 V8ObjectVar(PP_Instance instance,
35 NPObjectVar(PP_Instance instance, NPObject* np_object); 32 v8::Handle<v8::Object> v8_object);
36 33
37 // Var overrides. 34 // Var overrides.
38 virtual NPObjectVar* AsNPObjectVar() OVERRIDE; 35 virtual V8ObjectVar* AsV8ObjectVar() OVERRIDE;
39 virtual PP_VarType GetType() const OVERRIDE; 36 virtual PP_VarType GetType() const OVERRIDE;
40 37
41 // Returns the underlying NPObject corresponding to this NPObjectVar. 38 // Returns the underlying v8 object corresponding to this V8ObjectVar. This
42 // Guaranteed non-NULL. 39 // should only be used on the stack.
43 NPObject* np_object() const { return np_object_; } 40 v8::Local<v8::Object> GetHandle() const;
44 41
45 // Notification that the instance was deleted, the internal reference will be 42 // Notification that the instance was deleted, the internal reference will be
46 // zeroed out. 43 // zeroed out.
47 void InstanceDeleted(); 44 void InstanceDeleted();
48 45
49 // Possibly 0 if the object has outlived its instance. 46 // Possibly 0 if the object has outlived its instance.
50 PP_Instance pp_instance() const { return pp_instance_; } 47 PP_Instance instance() const { return instance_; }
51 48
52 // Helper function that converts a PP_Var to an object. This will return NULL 49 // Helper function that converts a PP_Var to an object. This will return NULL
53 // if the PP_Var is not of object type or the object is invalid. 50 // if the PP_Var is not of object type or the object is invalid.
54 CONTENT_EXPORT static scoped_refptr<NPObjectVar> FromPPVar(PP_Var var); 51 CONTENT_EXPORT static scoped_refptr<V8ObjectVar> FromPPVar(PP_Var var);
55 52
56 private: 53 private:
57 virtual ~NPObjectVar(); 54 virtual ~V8ObjectVar();
58 55
59 // Possibly 0 if the object has outlived its instance. 56 PP_Instance instance_;
60 PP_Instance pp_instance_;
61 57
62 // Guaranteed non-NULL, this is the underlying object used by WebKit. We 58 // Guaranteed non-NULL, this is the underlying object used by WebKit. We
63 // hold a reference to this object. 59 // hold a reference to this object.
64 NPObject* np_object_; 60 v8::Persistent<v8::Object> v8_object_;
65 61
66 DISALLOW_COPY_AND_ASSIGN(NPObjectVar); 62 DISALLOW_COPY_AND_ASSIGN(V8ObjectVar);
67 }; 63 };
68 64
69 } // ppapi 65 } // ppapi
70 66
71 #endif // CONTENT_RENDERER_PEPPER_NPOBJECT_VAR_H_ 67 #endif // CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_
OLDNEW
« no previous file with comments | « content/renderer/pepper/v8_var_converter.cc ('k') | content/renderer/pepper/v8object_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698