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

Side by Side Diff: Source/bindings/core/v8/inspector/InspectorWrapper.h

Issue 1152733010: Oilpan: fix build after r196583. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 InspectorWrapper_h 5 #ifndef InspectorWrapper_h
6 #define InspectorWrapper_h 6 #define InspectorWrapper_h
7 7
8 #include "platform/heap/Handle.h" 8 #include "platform/heap/Handle.h"
9 #include "wtf/PassRefPtr.h" 9 #include "wtf/PassRefPtr.h"
10 #include "wtf/RefPtr.h" 10 #include "wtf/RefPtr.h"
(...skipping 16 matching lines...) Expand all
27 27
28 static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate*, c onst char* className, const Vector<V8MethodConfiguration>& methods, const Vector <V8AttributeConfiguration>& attributes); 28 static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate*, c onst char* className, const Vector<V8MethodConfiguration>& methods, const Vector <V8AttributeConfiguration>& attributes);
29 29
30 protected: 30 protected:
31 static v8::Local<v8::Object> createWrapper(v8::Local<v8::FunctionTemplate>, v8::Local<v8::Context>); 31 static v8::Local<v8::Object> createWrapper(v8::Local<v8::FunctionTemplate>, v8::Local<v8::Context>);
32 static void* unwrap(v8::Local<v8::Object>, const char* name); 32 static void* unwrap(v8::Local<v8::Object>, const char* name);
33 33
34 static v8::Local<v8::String> v8InternalizedString(v8::Isolate*, const char* name); 34 static v8::Local<v8::String> v8InternalizedString(v8::Isolate*, const char* name);
35 }; 35 };
36 36
37 template<typename T, bool = IsGarbageCollectedType<T>::value>
38 class InspectorWrapperTypeTrait {
39 public:
40 using PassType = PassRefPtr<T>;
41 using Type = RefPtr<T>;
42 };
43
44 template<typename T>
45 class InspectorWrapperTypeTrait<T, true> {
46 public:
47 using PassType = PassRefPtrWillBeRawPtr<T>;
48 using Type = RefPtrWillBeRawPtr<T>;
49 };
50
37 template<class T, char* const hiddenPropertyName, char* const className> 51 template<class T, char* const hiddenPropertyName, char* const className>
38 class InspectorWrapper final : public InspectorWrapperBase { 52 class InspectorWrapper final : public InspectorWrapperBase {
39 public: 53 public:
40 class WeakCallbackData final { 54 class WeakCallbackData final {
41 public: 55 public:
42 WeakCallbackData(v8::Isolate* isolate, PassRefPtr<T> impl, v8::Local<v8: :Object> wrapper) 56 WeakCallbackData(v8::Isolate* isolate, typename InspectorWrapperTypeTrai t<T>::PassType impl, v8::Local<v8::Object> wrapper)
43 : m_impl(impl) 57 : m_impl(impl)
44 , m_persistent(isolate, wrapper) 58 , m_persistent(isolate, wrapper)
45 { 59 {
46 m_persistent.SetWeak(this, &WeakCallbackData::weakCallback, v8::Weak CallbackType::kParameter); 60 m_persistent.SetWeak(this, &WeakCallbackData::weakCallback, v8::Weak CallbackType::kParameter);
47 } 61 }
48 62
49 RefPtr<T> m_impl; 63 typename InspectorWrapperTypeTrait<T>::Type m_impl;
50 64
51 private: 65 private:
52 static void weakCallback(const v8::WeakCallbackInfo<WeakCallbackData>& i nfo) 66 static void weakCallback(const v8::WeakCallbackInfo<WeakCallbackData>& i nfo)
53 { 67 {
54 delete info.GetParameter(); 68 delete info.GetParameter();
55 } 69 }
56 70
57 v8::Global<v8::Object> m_persistent; 71 v8::Global<v8::Object> m_persistent;
58 }; 72 };
59 73
60 static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate* is olate, const Vector<V8MethodConfiguration>& methods, const Vector<V8AttributeCon figuration>& attributes) 74 static v8::Local<v8::FunctionTemplate> createWrapperTemplate(v8::Isolate* is olate, const Vector<V8MethodConfiguration>& methods, const Vector<V8AttributeCon figuration>& attributes)
61 { 75 {
62 return InspectorWrapperBase::createWrapperTemplate(isolate, className, m ethods, attributes); 76 return InspectorWrapperBase::createWrapperTemplate(isolate, className, m ethods, attributes);
63 } 77 }
64 78
65 static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructo rTemplate, v8::Local<v8::Context> context, PassRefPtr<T> object) 79 static v8::Local<v8::Object> wrap(v8::Local<v8::FunctionTemplate> constructo rTemplate, v8::Local<v8::Context> context, typename blink::InspectorWrapperTypeT rait<T>::PassType object)
66 { 80 {
67 v8::Context::Scope contextScope(context); 81 v8::Context::Scope contextScope(context);
68 v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(const ructorTemplate, context); 82 v8::Local<v8::Object> result = InspectorWrapperBase::createWrapper(const ructorTemplate, context);
69 if (result.IsEmpty()) 83 if (result.IsEmpty())
70 return v8::Local<v8::Object>(); 84 return v8::Local<v8::Object>();
71 RefPtrWillBeRawPtr<T> impl(object); 85 typename blink::InspectorWrapperTypeTrait<T>::Type impl(object);
72 v8::Isolate* isolate = context->GetIsolate(); 86 v8::Isolate* isolate = context->GetIsolate();
73 v8::Local<v8::External> objectReference = v8::External::New(isolate, new WeakCallbackData(isolate, impl, result)); 87 v8::Local<v8::External> objectReference = v8::External::New(isolate, new WeakCallbackData(isolate, impl, result));
74 result->SetHiddenValue(v8InternalizedString(isolate, hiddenPropertyName) , objectReference); 88 result->SetHiddenValue(v8InternalizedString(isolate, hiddenPropertyName) , objectReference);
75 return result; 89 return result;
76 } 90 }
77 static T* unwrap(v8::Local<v8::Object> object) 91 static T* unwrap(v8::Local<v8::Object> object)
78 { 92 {
79 void* data = InspectorWrapperBase::unwrap(object, hiddenPropertyName); 93 void* data = InspectorWrapperBase::unwrap(object, hiddenPropertyName);
80 if (!data) 94 if (!data)
81 return nullptr; 95 return nullptr;
82 return reinterpret_cast<WeakCallbackData*>(data)->m_impl.get(); 96 return reinterpret_cast<WeakCallbackData*>(data)->m_impl.get();
83 } 97 }
84 }; 98 };
85 99
86 } // namespace blink 100 } // namespace blink
87 101
88 #endif // InspectorWrapper_h 102 #endif // InspectorWrapper_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698