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

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

Issue 464653003: Change V8ObjectVar to store a pointer to the instance rather than an ID (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 | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_V8OBJECT_VAR_H_ 5 #ifndef CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_
6 #define CONTENT_RENDERER_PEPPER_V8OBJECT_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 "content/common/content_export.h"
12 #include "ppapi/c/pp_instance.h" 12 #include "ppapi/c/pp_instance.h"
13 #include "ppapi/shared_impl/var.h" 13 #include "ppapi/shared_impl/var.h"
14 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
15 15
16 namespace content {
17 class PepperPluginInstanceImpl;
18 } // namespace content
19
16 namespace ppapi { 20 namespace ppapi {
17 21
18 // V8ObjectVar ----------------------------------------------------------------- 22 // V8ObjectVar -----------------------------------------------------------------
19 23
20 // Represents a JavaScript object Var. By itself, this represents random 24 // Represents a JavaScript object Var. By itself, this represents random
21 // v8 objects that a given plugin (identified by the resource's module) wants to 25 // v8 objects that a given plugin (identified by the resource's module) wants to
22 // reference. If two different modules reference the same NPObject (like the 26 // reference. If two different modules reference the same NPObject (like the
23 // "window" object), then there will be different V8ObjectVar's (and hence 27 // "window" object), then there will be different V8ObjectVar's (and hence
24 // PP_Var IDs) for each module. This allows us to track all references owned by 28 // PP_Var IDs) for each module. This allows us to track all references owned by
25 // a given module and free them when the plugin exits independently of other 29 // a given module and free them when the plugin exits independently of other
26 // plugins that may be running at the same time. 30 // plugins that may be running at the same time.
27 class V8ObjectVar : public Var { 31 class V8ObjectVar : public Var {
28 public: 32 public:
29 V8ObjectVar(PP_Instance instance, v8::Handle<v8::Object> v8_object); 33 V8ObjectVar(PP_Instance instance, v8::Handle<v8::Object> v8_object);
30 34
31 // Var overrides. 35 // Var overrides.
32 virtual V8ObjectVar* AsV8ObjectVar() OVERRIDE; 36 virtual V8ObjectVar* AsV8ObjectVar() OVERRIDE;
33 virtual PP_VarType GetType() const OVERRIDE; 37 virtual PP_VarType GetType() const OVERRIDE;
34 38
35 // Returns the underlying v8 object corresponding to this V8ObjectVar. This 39 // Returns the underlying v8 object corresponding to this V8ObjectVar. This
36 // should only be used on the stack. 40 // should only be used on the stack.
37 v8::Local<v8::Object> GetHandle() const; 41 v8::Local<v8::Object> GetHandle() const;
38 42
39 // Notification that the instance was deleted, the internal reference will be 43 // Notification that the instance was deleted, the internal reference will be
40 // zeroed out. 44 // zeroed out.
41 void InstanceDeleted(); 45 void InstanceDeleted();
42 46
43 // Possibly 0 if the object has outlived its instance. 47 // Possibly 0 if the object has outlived its instance.
Sam McNally 2014/08/12 01:44:05 s/0/NULL/
raymes 2014/08/12 03:09:08 Done.
44 PP_Instance instance() const { return instance_; } 48 content::PepperPluginInstanceImpl* instance() const { return instance_; }
45 49
46 // Helper function that converts a PP_Var to an object. This will return NULL 50 // Helper function that converts a PP_Var to an object. This will return NULL
47 // if the PP_Var is not of object type or the object is invalid. 51 // if the PP_Var is not of object type or the object is invalid.
48 CONTENT_EXPORT static scoped_refptr<V8ObjectVar> FromPPVar(PP_Var var); 52 CONTENT_EXPORT static scoped_refptr<V8ObjectVar> FromPPVar(PP_Var var);
49 53
50 private: 54 private:
51 virtual ~V8ObjectVar(); 55 virtual ~V8ObjectVar();
52 56
53 PP_Instance instance_; 57 content::PepperPluginInstanceImpl* instance_;
54 58
55 v8::Persistent<v8::Object> v8_object_; 59 v8::Persistent<v8::Object> v8_object_;
56 60
57 DISALLOW_COPY_AND_ASSIGN(V8ObjectVar); 61 DISALLOW_COPY_AND_ASSIGN(V8ObjectVar);
58 }; 62 };
59 63
60 } // ppapi 64 } // ppapi
61 65
62 #endif // CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_ 66 #endif // CONTENT_RENDERER_PEPPER_V8OBJECT_VAR_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/pepper/v8object_var.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698