OLD | NEW |
1 // This file was GENERATED by command: | 1 // This file was GENERATED by command: |
2 // pump.py function_template.h.pump | 2 // pump.py function_template.h.pump |
3 // DO NOT EDIT BY HAND!!! | 3 // DO NOT EDIT BY HAND!!! |
4 | 4 |
5 | 5 |
6 | 6 |
7 #ifndef GIN_FUNCTION_TEMPLATE_H_ | 7 #ifndef GIN_FUNCTION_TEMPLATE_H_ |
8 #define GIN_FUNCTION_TEMPLATE_H_ | 8 #define GIN_FUNCTION_TEMPLATE_H_ |
9 | 9 |
10 // Copyright 2013 The Chromium Authors. All rights reserved. | 10 // Copyright 2013 The Chromium Authors. All rights reserved. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 // CallbackHolder and CallbackHolderBase are used to pass a base::Callback from | 49 // CallbackHolder and CallbackHolderBase are used to pass a base::Callback from |
50 // CreateFunctionTemplate through v8 (via v8::FunctionTemplate) to | 50 // CreateFunctionTemplate through v8 (via v8::FunctionTemplate) to |
51 // DispatchToCallback, where it is invoked. | 51 // DispatchToCallback, where it is invoked. |
52 // | 52 // |
53 // v8::FunctionTemplate only supports passing void* as data so how do we know | 53 // v8::FunctionTemplate only supports passing void* as data so how do we know |
54 // when to delete the base::Callback? That's where CallbackHolderBase comes in. | 54 // when to delete the base::Callback? That's where CallbackHolderBase comes in. |
55 // It inherits from Wrappable, which delete itself when both (a) the refcount | 55 // It inherits from Wrappable, which delete itself when both (a) the refcount |
56 // via base::RefCounted has dropped to zero, and (b) there are no more | 56 // via base::RefCounted has dropped to zero, and (b) there are no more |
57 // JavaScript references in V8. | 57 // JavaScript references in V8. |
58 class CallbackHolderBase : public Wrappable { | 58 // |
59 public: | 59 // TODO(aa): Do we still need the separate base class? |
60 virtual WrapperInfo* GetWrapperInfo() OVERRIDE; | 60 class CallbackHolderBase : public Wrappable<CallbackHolderBase> { |
61 static WrapperInfo kWrapperInfo; | |
62 protected: | 61 protected: |
63 virtual ~CallbackHolderBase() {} | 62 virtual ~CallbackHolderBase() {} |
64 }; | 63 }; |
65 | 64 |
66 template<typename Sig> | 65 template<typename Sig> |
67 class CallbackHolder : public CallbackHolderBase { | 66 class CallbackHolder : public CallbackHolderBase { |
68 public: | 67 public: |
69 CallbackHolder(const base::Callback<Sig>& callback, int flags) | 68 CallbackHolder(const base::Callback<Sig>& callback, int flags) |
70 : callback(callback), flags(flags) {} | 69 : callback(callback), flags(flags) {} |
71 base::Callback<Sig> callback; | 70 base::Callback<Sig> callback; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 gin::Handle<HolderT> holder = CreateHandle( | 344 gin::Handle<HolderT> holder = CreateHandle( |
346 isolate, new HolderT(callback, callback_flags)); | 345 isolate, new HolderT(callback, callback_flags)); |
347 return v8::FunctionTemplate::New( | 346 return v8::FunctionTemplate::New( |
348 &internal::Dispatcher<Sig>::DispatchToCallback, | 347 &internal::Dispatcher<Sig>::DispatchToCallback, |
349 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); | 348 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); |
350 } | 349 } |
351 | 350 |
352 } // namespace gin | 351 } // namespace gin |
353 | 352 |
354 #endif // GIN_FUNCTION_TEMPLATE_H_ | 353 #endif // GIN_FUNCTION_TEMPLATE_H_ |
OLD | NEW |