OLD | NEW |
1 $$ This is a pump file for generating file templates. Pump is a python | 1 $$ This is a pump file for generating file templates. Pump is a python |
2 $$ script that is part of the Google Test suite of utilities. Description | 2 $$ script that is part of the Google Test suite of utilities. Description |
3 $$ can be found here: | 3 $$ can be found here: |
4 $$ | 4 $$ |
5 $$ http://code.google.com/p/googletest/wiki/PumpManual | 5 $$ http://code.google.com/p/googletest/wiki/PumpManual |
6 $$ | 6 $$ |
7 | 7 |
8 #ifndef GIN_FUNCTION_TEMPLATE_H_ | 8 #ifndef GIN_FUNCTION_TEMPLATE_H_ |
9 #define GIN_FUNCTION_TEMPLATE_H_ | 9 #define GIN_FUNCTION_TEMPLATE_H_ |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // CallbackHolder and CallbackHolderBase are used to pass a base::Callback from | 52 // CallbackHolder and CallbackHolderBase are used to pass a base::Callback from |
53 // CreateFunctionTemplate through v8 (via v8::FunctionTemplate) to | 53 // CreateFunctionTemplate through v8 (via v8::FunctionTemplate) to |
54 // DispatchToCallback, where it is invoked. | 54 // DispatchToCallback, where it is invoked. |
55 // | 55 // |
56 // v8::FunctionTemplate only supports passing void* as data so how do we know | 56 // v8::FunctionTemplate only supports passing void* as data so how do we know |
57 // when to delete the base::Callback? That's where CallbackHolderBase comes in. | 57 // when to delete the base::Callback? That's where CallbackHolderBase comes in. |
58 // It inherits from Wrappable, which delete itself when both (a) the refcount | 58 // It inherits from Wrappable, which delete itself when both (a) the refcount |
59 // via base::RefCounted has dropped to zero, and (b) there are no more | 59 // via base::RefCounted has dropped to zero, and (b) there are no more |
60 // JavaScript references in V8. | 60 // JavaScript references in V8. |
61 class CallbackHolderBase : public Wrappable { | 61 class CallbackHolderBase : public Wrappable { |
62 public: | |
63 virtual WrapperInfo* GetWrapperInfo() OVERRIDE; | |
64 static WrapperInfo kWrapperInfo; | |
65 protected: | 62 protected: |
66 virtual ~CallbackHolderBase() {} | 63 virtual ~CallbackHolderBase() {} |
67 }; | 64 }; |
68 | 65 |
69 template<typename Sig> | 66 template<typename Sig> |
70 class CallbackHolder : public CallbackHolderBase { | 67 class CallbackHolder : public CallbackHolderBase { |
71 public: | 68 public: |
72 CallbackHolder(const base::Callback<Sig>& callback, int flags) | 69 CallbackHolder(const base::Callback<Sig>& callback, int flags) |
73 : callback(callback), flags(flags) {} | 70 : callback(callback), flags(flags) {} |
74 base::Callback<Sig> callback; | 71 base::Callback<Sig> callback; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 gin::Handle<HolderT> holder = CreateHandle( | 197 gin::Handle<HolderT> holder = CreateHandle( |
201 isolate, new HolderT(callback, callback_flags)); | 198 isolate, new HolderT(callback, callback_flags)); |
202 return v8::FunctionTemplate::New( | 199 return v8::FunctionTemplate::New( |
203 &internal::Dispatcher<Sig>::DispatchToCallback, | 200 &internal::Dispatcher<Sig>::DispatchToCallback, |
204 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); | 201 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); |
205 } | 202 } |
206 | 203 |
207 } // namespace gin | 204 } // namespace gin |
208 | 205 |
209 #endif // GIN_FUNCTION_TEMPLATE_H_ | 206 #endif // GIN_FUNCTION_TEMPLATE_H_ |
OLD | NEW |