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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8PerContextData.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "bindings/core/v8/V8PerContextData.h" 31 #include "bindings/core/v8/V8PerContextData.h"
32 32
33 #include "bindings/core/v8/ScriptState.h" 33 #include "bindings/core/v8/ScriptState.h"
34 #include "bindings/core/v8/V8Binding.h" 34 #include "bindings/core/v8/V8Binding.h"
35 #include "bindings/core/v8/V8ObjectConstructor.h" 35 #include "bindings/core/v8/V8ObjectConstructor.h"
36 #include "core/inspector/InstanceCounters.h" 36 #include "core/inspector/InstanceCounters.h"
37 #include "wtf/PtrUtil.h"
38 #include "wtf/StringExtras.h" 37 #include "wtf/StringExtras.h"
39 #include <memory> 38
40 #include <stdlib.h> 39 #include <stdlib.h>
41 40
42 namespace blink { 41 namespace blink {
43 42
44 V8PerContextData::V8PerContextData(v8::Local<v8::Context> context) 43 V8PerContextData::V8PerContextData(v8::Local<v8::Context> context)
45 : m_isolate(context->GetIsolate()) 44 : m_isolate(context->GetIsolate())
46 , m_wrapperBoilerplates(m_isolate) 45 , m_wrapperBoilerplates(m_isolate)
47 , m_constructorMap(m_isolate) 46 , m_constructorMap(m_isolate)
48 , m_contextHolder(wrapUnique(new gin::ContextHolder(m_isolate))) 47 , m_contextHolder(adoptPtr(new gin::ContextHolder(m_isolate)))
49 , m_context(m_isolate, context) 48 , m_context(m_isolate, context)
50 , m_activityLogger(0) 49 , m_activityLogger(0)
51 , m_compiledPrivateScript(m_isolate) 50 , m_compiledPrivateScript(m_isolate)
52 { 51 {
53 m_contextHolder->SetContext(context); 52 m_contextHolder->SetContext(context);
54 53
55 v8::Context::Scope contextScope(context); 54 v8::Context::Scope contextScope(context);
56 ASSERT(m_errorPrototype.isEmpty()); 55 ASSERT(m_errorPrototype.isEmpty());
57 v8::Local<v8::Value> objectValue = context->Global()->Get(context, v8AtomicS tring(m_isolate, "Error")).ToLocalChecked(); 56 v8::Local<v8::Value> objectValue = context->Global()->Get(context, v8AtomicS tring(m_isolate, "Error")).ToLocalChecked();
58 v8::Local<v8::Value> prototypeValue = objectValue.As<v8::Object>()->Get(cont ext, v8AtomicString(m_isolate, "prototype")).ToLocalChecked(); 57 v8::Local<v8::Value> prototypeValue = objectValue.As<v8::Object>()->Get(cont ext, v8AtomicString(m_isolate, "prototype")).ToLocalChecked();
59 m_errorPrototype.set(m_isolate, prototypeValue); 58 m_errorPrototype.set(m_isolate, prototypeValue);
60 59
61 if (isMainThread()) 60 if (isMainThread())
62 InstanceCounters::incrementCounter(InstanceCounters::V8PerContextDataCou nter); 61 InstanceCounters::incrementCounter(InstanceCounters::V8PerContextDataCou nter);
63 } 62 }
64 63
65 V8PerContextData::~V8PerContextData() 64 V8PerContextData::~V8PerContextData()
66 { 65 {
67 if (isMainThread()) 66 if (isMainThread())
68 InstanceCounters::decrementCounter(InstanceCounters::V8PerContextDataCou nter); 67 InstanceCounters::decrementCounter(InstanceCounters::V8PerContextDataCou nter);
69 } 68 }
70 69
71 std::unique_ptr<V8PerContextData> V8PerContextData::create(v8::Local<v8::Context > context) 70 PassOwnPtr<V8PerContextData> V8PerContextData::create(v8::Local<v8::Context> con text)
72 { 71 {
73 return wrapUnique(new V8PerContextData(context)); 72 return adoptPtr(new V8PerContextData(context));
74 } 73 }
75 74
76 V8PerContextData* V8PerContextData::from(v8::Local<v8::Context> context) 75 V8PerContextData* V8PerContextData::from(v8::Local<v8::Context> context)
77 { 76 {
78 return ScriptState::from(context)->perContextData(); 77 return ScriptState::from(context)->perContextData();
79 } 78 }
80 79
81 v8::Local<v8::Object> V8PerContextData::createWrapperFromCacheSlowCase(const Wra pperTypeInfo* type) 80 v8::Local<v8::Object> V8PerContextData::createWrapperFromCacheSlowCase(const Wra pperTypeInfo* type)
82 { 81 {
83 ASSERT(!m_errorPrototype.isEmpty()); 82 ASSERT(!m_errorPrototype.isEmpty());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 { 138 {
140 v8::Local<v8::Object> constructor = constructorForType(type); 139 v8::Local<v8::Object> constructor = constructorForType(type);
141 if (constructor.IsEmpty()) 140 if (constructor.IsEmpty())
142 return v8::Local<v8::Object>(); 141 return v8::Local<v8::Object>();
143 v8::Local<v8::Value> prototypeValue; 142 v8::Local<v8::Value> prototypeValue;
144 if (!constructor->Get(context(), v8String(m_isolate, "prototype")).ToLocal(& prototypeValue) || !prototypeValue->IsObject()) 143 if (!constructor->Get(context(), v8String(m_isolate, "prototype")).ToLocal(& prototypeValue) || !prototypeValue->IsObject())
145 return v8::Local<v8::Object>(); 144 return v8::Local<v8::Object>();
146 return prototypeValue.As<v8::Object>(); 145 return prototypeValue.As<v8::Object>();
147 } 146 }
148 147
149 void V8PerContextData::addCustomElementBinding(std::unique_ptr<V0CustomElementBi nding> binding) 148 void V8PerContextData::addCustomElementBinding(PassOwnPtr<V0CustomElementBinding > binding)
150 { 149 {
151 m_customElementBindings.append(std::move(binding)); 150 m_customElementBindings.append(std::move(binding));
152 } 151 }
153 152
154 v8::Local<v8::Value> V8PerContextData::compiledPrivateScript(String className) 153 v8::Local<v8::Value> V8PerContextData::compiledPrivateScript(String className)
155 { 154 {
156 return m_compiledPrivateScript.Get(className); 155 return m_compiledPrivateScript.Get(className);
157 } 156 }
158 157
159 void V8PerContextData::setCompiledPrivateScript(String className, v8::Local<v8:: Value> compiledObject) 158 void V8PerContextData::setCompiledPrivateScript(String className, v8::Local<v8:: Value> compiledObject)
160 { 159 {
161 m_compiledPrivateScript.Set(className, compiledObject); 160 m_compiledPrivateScript.Set(className, compiledObject);
162 } 161 }
163 162
164 } // namespace blink 163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698