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

Side by Side Diff: Source/bindings/v8/V8PerContextData.cpp

Issue 217053007: Revert of Make DOMWrapperWorld::current() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Revert 213543004 too Created 6 years, 9 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 | « Source/bindings/v8/V8PerContextData.h ('k') | Source/bindings/v8/V8PerIsolateData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 V8PerContextDataHolder* holder = static_cast<V8PerContextDataHolder*>(co ntext->GetAlignedPointerFromEmbedderData(v8ContextPerContextDataIndex)); 61 V8PerContextDataHolder* holder = static_cast<V8PerContextDataHolder*>(co ntext->GetAlignedPointerFromEmbedderData(v8ContextPerContextDataIndex));
62 // V8PerContextDataHolder::from() must not be called for a context that does not have 62 // V8PerContextDataHolder::from() must not be called for a context that does not have
63 // valid embedder data in the embedder field. 63 // valid embedder data in the embedder field.
64 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(holder); 64 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(holder);
65 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(holder->context() == context); 65 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(holder->context() == context);
66 return holder; 66 return holder;
67 } 67 }
68 68
69 V8PerContextData* perContextData() const { return m_perContextData; } 69 V8PerContextData* perContextData() const { return m_perContextData; }
70 void setPerContextData(V8PerContextData* data) { m_perContextData = data; } 70 void setPerContextData(V8PerContextData* data) { m_perContextData = data; }
71 DOMWrapperWorld& world() const { return *m_world; } 71 DOMWrapperWorld* world() const { return m_world.get(); }
72 v8::Handle<v8::Context> context() const { return m_context.newLocal(m_isolat e); } 72 v8::Handle<v8::Context> context() const { return m_context.newLocal(m_isolat e); }
73 73
74 private: 74 private:
75 V8PerContextDataHolder(v8::Handle<v8::Context> context, PassRefPtr<DOMWrappe rWorld> world) 75 V8PerContextDataHolder(v8::Handle<v8::Context> context, PassRefPtr<DOMWrappe rWorld> world)
76 : m_isolate(context->GetIsolate()) 76 : m_isolate(context->GetIsolate())
77 , m_context(m_isolate, context) 77 , m_context(m_isolate, context)
78 , m_perContextData(0) 78 , m_perContextData(0)
79 , m_world(world) 79 , m_world(world)
80 { 80 {
81 ASSERT(m_world);
82 m_context.setWeak(this, &V8PerContextDataHolder::weakCallback); 81 m_context.setWeak(this, &V8PerContextDataHolder::weakCallback);
83 context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, t his); 82 context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, t his);
84 } 83 }
85 84
86 ~V8PerContextDataHolder() { } 85 ~V8PerContextDataHolder() { }
87 86
88 static void weakCallback(const v8::WeakCallbackData<v8::Context, V8PerContex tDataHolder>& data) 87 static void weakCallback(const v8::WeakCallbackData<v8::Context, V8PerContex tDataHolder>& data)
89 { 88 {
90 data.GetValue()->SetAlignedPointerInEmbedderData(v8ContextPerContextData Index, 0); 89 data.GetValue()->SetAlignedPointerInEmbedderData(v8ContextPerContextData Index, 0);
91 delete data.GetParameter(); 90 delete data.GetParameter();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 123
125 disposeMapWithUnsafePersistentValues(&m_wrapperBoilerplates); 124 disposeMapWithUnsafePersistentValues(&m_wrapperBoilerplates);
126 disposeMapWithUnsafePersistentValues(&m_constructorMap); 125 disposeMapWithUnsafePersistentValues(&m_constructorMap);
127 } 126 }
128 127
129 V8PerContextData* V8PerContextData::from(v8::Handle<v8::Context> context) 128 V8PerContextData* V8PerContextData::from(v8::Handle<v8::Context> context)
130 { 129 {
131 return V8PerContextDataHolder::from(context)->perContextData(); 130 return V8PerContextDataHolder::from(context)->perContextData();
132 } 131 }
133 132
134 DOMWrapperWorld& V8PerContextData::world(v8::Handle<v8::Context> context) 133 DOMWrapperWorld* V8PerContextData::world(v8::Handle<v8::Context> context)
135 { 134 {
136 DOMWrapperWorld& world = V8PerContextDataHolder::from(context)->world(); 135 DOMWrapperWorld* world = V8PerContextDataHolder::from(context)->world();
136 ASSERT(world);
137 return world; 137 return world;
138 } 138 }
139 139
140 v8::Local<v8::Object> V8PerContextData::createWrapperFromCacheSlowCase(const Wra pperTypeInfo* type) 140 v8::Local<v8::Object> V8PerContextData::createWrapperFromCacheSlowCase(const Wra pperTypeInfo* type)
141 { 141 {
142 ASSERT(!m_errorPrototype.isEmpty()); 142 ASSERT(!m_errorPrototype.isEmpty());
143 143
144 v8::Context::Scope scope(context()); 144 v8::Context::Scope scope(context());
145 v8::Local<v8::Function> function = constructorForType(type); 145 v8::Local<v8::Function> function = constructorForType(type);
146 v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(fu nction); 146 v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(fu nction);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (!data->IsString()) 260 if (!data->IsString())
261 return -1; 261 return -1;
262 v8::String::Utf8Value utf8(data); 262 v8::String::Utf8Value utf8(data);
263 char* comma = strnstr(*utf8, ",", utf8.length()); 263 char* comma = strnstr(*utf8, ",", utf8.length());
264 if (!comma) 264 if (!comma)
265 return -1; 265 return -1;
266 return atoi(comma + 1); 266 return atoi(comma + 1);
267 } 267 }
268 268
269 } // namespace WebCore 269 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8PerContextData.h ('k') | Source/bindings/v8/V8PerIsolateData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698