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

Side by Side Diff: sky/engine/tonic/dart_wrappable.h

Issue 936193005: Make it possible to inherit from any constructable host object (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Remove extra comment Created 5 years, 10 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 // 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 SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ 5 #ifndef SKY_ENGINE_TONIC_DART_WRAPPABLE_H_
6 #define SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ 6 #define SKY_ENGINE_TONIC_DART_WRAPPABLE_H_
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/template_util.h" 9 #include "base/template_util.h"
10 #include "dart/runtime/include/dart_api.h" 10 #include "dart/runtime/include/dart_api.h"
(...skipping 22 matching lines...) Expand all
33 // and provide information about their wrapper. There is no need to call your 33 // and provide information about their wrapper. There is no need to call your
34 // base class's implementation of this function. 34 // base class's implementation of this function.
35 virtual const DartWrapperInfo& GetDartWrapperInfo() const = 0; 35 virtual const DartWrapperInfo& GetDartWrapperInfo() const = 0;
36 36
37 // Subclasses that wish to integrate with the Dart garbage collector should 37 // Subclasses that wish to integrate with the Dart garbage collector should
38 // override this function. Please call your base class's AcceptDartGCVisitor 38 // override this function. Please call your base class's AcceptDartGCVisitor
39 // at the end of your override. 39 // at the end of your override.
40 virtual void AcceptDartGCVisitor(DartGCVisitor& visitor) const; 40 virtual void AcceptDartGCVisitor(DartGCVisitor& visitor) const;
41 41
42 Dart_Handle CreateDartWrapper(DartState* dart_state); 42 Dart_Handle CreateDartWrapper(DartState* dart_state);
43 void AssociateWithDartWrapper(Dart_NativeArguments args);
43 Dart_WeakPersistentHandle dart_wrapper() const { return dart_wrapper_; } 44 Dart_WeakPersistentHandle dart_wrapper() const { return dart_wrapper_; }
44 45
45 protected: 46 protected:
46 virtual ~DartWrappable(); 47 virtual ~DartWrappable();
47 48
48 private: 49 private:
49 static void FinalizeDartWrapper(void* isolate_callback_data, 50 static void FinalizeDartWrapper(void* isolate_callback_data,
50 Dart_WeakPersistentHandle wrapper, 51 Dart_WeakPersistentHandle wrapper,
51 void* peer); 52 void* peer);
52 53
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 static Dart_Handle ToDart(RefPtr<T> val) { 127 static Dart_Handle ToDart(RefPtr<T> val) {
127 return DartConverter<T*>::ToDart(val.get()); 128 return DartConverter<T*>::ToDart(val.get());
128 } 129 }
129 130
130 static RefPtr<T> FromDart(Dart_Handle handle) { 131 static RefPtr<T> FromDart(Dart_Handle handle) {
131 return DartConverter<T*>::FromDart(handle); 132 return DartConverter<T*>::FromDart(handle);
132 } 133 }
133 }; 134 };
134 135
135 template<typename T> 136 template<typename T>
136 static T* GetReceiver(Dart_NativeArguments args) { 137 inline T* GetReceiver(Dart_NativeArguments args) {
137 intptr_t receiver; 138 intptr_t receiver;
138 Dart_Handle result = Dart_GetNativeReceiver(args, &receiver); 139 Dart_Handle result = Dart_GetNativeReceiver(args, &receiver);
139 DCHECK(!Dart_IsError(result)); 140 DCHECK(!Dart_IsError(result));
140 return static_cast<T*>(reinterpret_cast<DartWrappable*>(receiver)); 141 return static_cast<T*>(reinterpret_cast<DartWrappable*>(receiver));
141 } 142 }
142 143
143 } // namespace blink 144 } // namespace blink
144 145
145 #endif // SKY_ENGINE_TONIC_DART_WRAPPABLE_H_ 146 #endif // SKY_ENGINE_TONIC_DART_WRAPPABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698