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

Side by Side Diff: gin/function_template.h

Issue 105743007: Gin: Make it easier to implement Wrappable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 7 years 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 | gin/function_template.cc » ('j') | gin/wrappable.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // This simple base class is used so that we can share a single object template
60 virtual WrapperInfo* GetWrapperInfo() OVERRIDE; 60 // among every CallbackHolder instance.
61 static WrapperInfo kWrapperInfo; 61 class CallbackHolderBase : public Wrappable<CallbackHolderBase> {
62 protected: 62 protected:
63 virtual ~CallbackHolderBase() {} 63 virtual ~CallbackHolderBase() {}
64 }; 64 };
65 65
66 template<typename Sig> 66 template<typename Sig>
67 class CallbackHolder : public CallbackHolderBase { 67 class CallbackHolder : public CallbackHolderBase {
68 public: 68 public:
69 CallbackHolder(const base::Callback<Sig>& callback, int flags) 69 CallbackHolder(const base::Callback<Sig>& callback, int flags)
70 : callback(callback), flags(flags) {} 70 : callback(callback), flags(flags) {}
71 base::Callback<Sig> callback; 71 base::Callback<Sig> callback;
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 gin::Handle<HolderT> holder = CreateHandle( 345 gin::Handle<HolderT> holder = CreateHandle(
346 isolate, new HolderT(callback, callback_flags)); 346 isolate, new HolderT(callback, callback_flags));
347 return v8::FunctionTemplate::New( 347 return v8::FunctionTemplate::New(
348 &internal::Dispatcher<Sig>::DispatchToCallback, 348 &internal::Dispatcher<Sig>::DispatchToCallback,
349 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get())); 349 ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get()));
350 } 350 }
351 351
352 } // namespace gin 352 } // namespace gin
353 353
354 #endif // GIN_FUNCTION_TEMPLATE_H_ 354 #endif // GIN_FUNCTION_TEMPLATE_H_
OLDNEW
« no previous file with comments | « no previous file | gin/function_template.cc » ('j') | gin/wrappable.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698