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

Side by Side Diff: Source/bindings/core/v8/ScriptWrappable.h

Issue 478243002: bindings: Adds virtual ScriptWrappable::wrap method. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced and sent out to the code review. Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // adopted and so forth. The overloaded initializeScriptWrappableForInterfac e() 141 // adopted and so forth. The overloaded initializeScriptWrappableForInterfac e()
142 // functions are implemented by the generated V8 bindings code. Declaring th e 142 // functions are implemented by the generated V8 bindings code. Declaring th e
143 // extern function in the template avoids making a centralized header of all 143 // extern function in the template avoids making a centralized header of all
144 // the bindings in the universe. C++11's extern template feature may provide 144 // the bindings in the universe. C++11's extern template feature may provide
145 // a cleaner solution someday. 145 // a cleaner solution someday.
146 template <class C> static void init(C* object) 146 template <class C> static void init(C* object)
147 { 147 {
148 initializeScriptWrappableHelper(object); 148 initializeScriptWrappableHelper(object);
149 } 149 }
150 150
151 // Returns the WrapperTypeInfo of the instance.
152 //
153 // This method must be overridden by using DEFINE_WRAPPERTYPEINFO macro.
haraken 2014/08/29 05:24:04 by using => by
Yuki 2014/09/01 06:06:39 Done.
Yuki 2014/09/01 06:06:39 Done.
154 virtual const WrapperTypeInfo* wrapperTypeInfo() const = 0;
155
156 // Creates and returns a new wrapper object.
157 virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext, v8::Isolate*);
158
151 void setWrapper(v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperConfiguration& configuration) 159 void setWrapper(v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, const WrapperConfiguration& configuration)
152 { 160 {
153 ASSERT(!containsWrapper()); 161 ASSERT(!containsWrapper());
154 if (!*wrapper) { 162 if (!*wrapper) {
155 m_wrapperOrTypeInfo = 0; 163 m_wrapperOrTypeInfo = 0;
156 return; 164 return;
157 } 165 }
158 v8::Persistent<v8::Object> persistent(isolate, wrapper); 166 v8::Persistent<v8::Object> persistent(isolate, wrapper);
159 configuration.configureWrapper(&persistent); 167 configuration.configureWrapper(&persistent);
160 persistent.SetWeak(this, &setWeakCallback); 168 persistent.SetWeak(this, &setWeakCallback);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 ASSERT(persistent == data.GetValue()); 339 ASSERT(persistent == data.GetValue());
332 data.GetParameter()->disposeWrapper(data.GetValue()); 340 data.GetParameter()->disposeWrapper(data.GetValue());
333 341
334 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed 342 // FIXME: I noticed that 50%~ of minor GC cycle times can be consumed
335 // inside data.GetParameter()->deref(), which causes Node destructions. We should 343 // inside data.GetParameter()->deref(), which causes Node destructions. We should
336 // make Node destructions incremental. 344 // make Node destructions incremental.
337 releaseObject(data.GetValue()); 345 releaseObject(data.GetValue());
338 } 346 }
339 }; 347 };
340 348
349 // Defines 'wrapperTypeInfo' virtual method which returns the WrapperTypeInfo of
350 // the instance. Also declares a static member of type WrapperTypeInfo, of which
351 // the definition is given by the IDL code generator.
352 //
353 // All the derived classes of ScriptWrappable, regardless of directly or
354 // indirectly, must write this macro in the class definition except for the case
355 // that the class is NoInterfaceObject.
haraken 2014/08/29 05:24:04 Help me understand: What's the relationship betwee
Yuki 2014/09/01 06:06:39 Added more comment.
356 #define DEFINE_WRAPPERTYPEINFO() \
357 public: \
358 virtual const WrapperTypeInfo* wrapperTypeInfo() const OVERRIDE \
359 { \
360 return &s_wrapperTypeInfo; \
361 } \
362 private: \
363 static const WrapperTypeInfo& s_wrapperTypeInfo
364
341 } // namespace blink 365 } // namespace blink
342 366
343 #endif // ScriptWrappable_h 367 #endif // ScriptWrappable_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptWrappable.cpp » ('j') | Source/bindings/core/v8/ScriptWrappable.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698