| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 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 // |
| 62 // TODO(aa): Do we still need the separate base class? |
| 61 class CallbackHolderBase : public Wrappable { | 63 class CallbackHolderBase : public Wrappable { |
| 62 public: | |
| 63 virtual WrapperInfo* GetWrapperInfo() OVERRIDE; | |
| 64 static WrapperInfo kWrapperInfo; | |
| 65 protected: | 64 protected: |
| 66 virtual ~CallbackHolderBase() {} | 65 virtual ~CallbackHolderBase() {} |
| 67 }; | 66 }; |
| 68 | 67 |
| 69 template<typename Sig> | 68 template<typename Sig> |
| 70 class CallbackHolder : public CallbackHolderBase { | 69 class CallbackHolder : public CallbackHolderBase { |
| 71 public: | 70 public: |
| 72 CallbackHolder(const base::Callback<Sig>& callback, int flags) | 71 CallbackHolder(const base::Callback<Sig>& callback, int flags) |
| 73 : callback(callback), flags(flags) {} | 72 : callback(callback), flags(flags) {} |
| 74 base::Callback<Sig> callback; | 73 base::Callback<Sig> callback; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 gin::Handle<HolderT> holder = CreateHandle( | 199 gin::Handle<HolderT> holder = CreateHandle( |
| 201 isolate, new HolderT(callback, callback_flags)); | 200 isolate, new HolderT(callback, callback_flags)); |
| 202 return v8::FunctionTemplate::New( | 201 return v8::FunctionTemplate::New( |
| 203 &internal::Dispatcher<Sig>::DispatchToCallback, | 202 &internal::Dispatcher<Sig>::DispatchToCallback, |
| 204 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); | 203 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); |
| 205 } | 204 } |
| 206 | 205 |
| 207 } // namespace gin | 206 } // namespace gin |
| 208 | 207 |
| 209 #endif // GIN_FUNCTION_TEMPLATE_H_ | 208 #endif // GIN_FUNCTION_TEMPLATE_H_ |
| OLD | NEW |