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

Side by Side Diff: Source/bindings/core/v8/V8DOMWrapper.h

Issue 1278983003: Adding allocator annotations to blink classes and structs. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed patch conflict Created 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 #include "wtf/RawPtr.h" 37 #include "wtf/RawPtr.h"
38 #include "wtf/text/AtomicString.h" 38 #include "wtf/text/AtomicString.h"
39 #include <v8.h> 39 #include <v8.h>
40 40
41 namespace blink { 41 namespace blink {
42 42
43 class Node; 43 class Node;
44 struct WrapperTypeInfo; 44 struct WrapperTypeInfo;
45 45
46 class V8DOMWrapper { 46 class V8DOMWrapper {
47 STATIC_ONLY(V8DOMWrapper);
47 public: 48 public:
48 static v8::Local<v8::Object> createWrapper(v8::Isolate*, v8::Local<v8::Objec t> creationContext, const WrapperTypeInfo*, ScriptWrappable*); 49 static v8::Local<v8::Object> createWrapper(v8::Isolate*, v8::Local<v8::Objec t> creationContext, const WrapperTypeInfo*, ScriptWrappable*);
49 static bool isWrapper(v8::Isolate*, v8::Local<v8::Value>); 50 static bool isWrapper(v8::Isolate*, v8::Local<v8::Value>);
50 51
51 // Associates the given ScriptWrappable with the given |wrapper| if the 52 // Associates the given ScriptWrappable with the given |wrapper| if the
52 // ScriptWrappable is not yet associated with any wrapper. Returns the 53 // ScriptWrappable is not yet associated with any wrapper. Returns the
53 // wrapper already associated or |wrapper| if not yet associated. 54 // wrapper already associated or |wrapper| if not yet associated.
54 // The caller should always use the returned value rather than |wrapper|. 55 // The caller should always use the returned value rather than |wrapper|.
55 static v8::Local<v8::Object> associateObjectWithWrapper(v8::Isolate*, Script Wrappable*, const WrapperTypeInfo*, v8::Local<v8::Object> wrapper) WARN_UNUSED_R ETURN; 56 static v8::Local<v8::Object> associateObjectWithWrapper(v8::Isolate*, Script Wrappable*, const WrapperTypeInfo*, v8::Local<v8::Object> wrapper) WARN_UNUSED_R ETURN;
56 static v8::Local<v8::Object> associateObjectWithWrapper(v8::Isolate*, Node*, const WrapperTypeInfo*, v8::Local<v8::Object> wrapper) WARN_UNUSED_RETURN; 57 static v8::Local<v8::Object> associateObjectWithWrapper(v8::Isolate*, Node*, const WrapperTypeInfo*, v8::Local<v8::Object> wrapper) WARN_UNUSED_RETURN;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (DOMDataStore::setWrapper(isolate, node, wrapperTypeInfo, wrapper)) { 99 if (DOMDataStore::setWrapper(isolate, node, wrapperTypeInfo, wrapper)) {
99 wrapperTypeInfo->refObject(ScriptWrappable::fromNode(node)); 100 wrapperTypeInfo->refObject(ScriptWrappable::fromNode(node));
100 setNativeInfo(wrapper, wrapperTypeInfo, ScriptWrappable::fromNode(node)) ; 101 setNativeInfo(wrapper, wrapperTypeInfo, ScriptWrappable::fromNode(node)) ;
101 ASSERT(hasInternalFieldsSet(wrapper)); 102 ASSERT(hasInternalFieldsSet(wrapper));
102 } 103 }
103 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(toScriptWrappable(wrapper) == Scrip tWrappable::fromNode(node)); 104 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(toScriptWrappable(wrapper) == Scrip tWrappable::fromNode(node));
104 return wrapper; 105 return wrapper;
105 } 106 }
106 107
107 class V8WrapperInstantiationScope { 108 class V8WrapperInstantiationScope {
109 STACK_ALLOCATED();
108 public: 110 public:
109 V8WrapperInstantiationScope(v8::Local<v8::Object> creationContext, v8::Isola te* isolate) 111 V8WrapperInstantiationScope(v8::Local<v8::Object> creationContext, v8::Isola te* isolate)
110 : m_didEnterContext(false) 112 : m_didEnterContext(false)
111 , m_context(isolate->GetCurrentContext()) 113 , m_context(isolate->GetCurrentContext())
112 { 114 {
113 // creationContext should not be empty. Because if we have an 115 // creationContext should not be empty. Because if we have an
114 // empty creationContext, we will end up creating 116 // empty creationContext, we will end up creating
115 // a new object in the context currently entered. This is wrong. 117 // a new object in the context currently entered. This is wrong.
116 RELEASE_ASSERT(!creationContext.IsEmpty()); 118 RELEASE_ASSERT(!creationContext.IsEmpty());
117 v8::Local<v8::Context> contextForWrapper = creationContext->CreationCont ext(); 119 v8::Local<v8::Context> contextForWrapper = creationContext->CreationCont ext();
(...skipping 16 matching lines...) Expand all
134 v8::Local<v8::Context> context() const { return m_context; } 136 v8::Local<v8::Context> context() const { return m_context; }
135 137
136 private: 138 private:
137 bool m_didEnterContext; 139 bool m_didEnterContext;
138 v8::Local<v8::Context> m_context; 140 v8::Local<v8::Context> m_context;
139 }; 141 };
140 142
141 } // namespace blink 143 } // namespace blink
142 144
143 #endif // V8DOMWrapper_h 145 #endif // V8DOMWrapper_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8DOMConfiguration.h ('k') | Source/bindings/core/v8/V8EventListenerList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698