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

Unified Diff: gin/wrappable_unittest.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gin/wrappable.cc ('k') | mojo/apps/js/bindings/waiting_callback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/wrappable_unittest.cc
diff --git a/gin/wrappable_unittest.cc b/gin/wrappable_unittest.cc
index 8886a7990ccebbe7f1950f7577d25a27a039e962..b2b859f753e6235d6340f9cb78d17ce8f0f5699b 100644
--- a/gin/wrappable_unittest.cc
+++ b/gin/wrappable_unittest.cc
@@ -14,65 +14,32 @@
#include "testing/gtest/include/gtest/gtest.h"
namespace gin {
-namespace {
-class MyObject : public Wrappable {
+class MyObject : public Wrappable<MyObject> {
public:
- static gin::Handle<MyObject> Create(v8::Isolate* isolate);
+ static gin::Handle<MyObject> Create(v8::Isolate* isolate) {
+ return CreateHandle(isolate, new MyObject());
+ }
int value() const { return value_; }
void set_value(int value) { value_ = value; }
- static WrapperInfo kWrapperInfo;
- virtual WrapperInfo* GetWrapperInfo() OVERRIDE;
-
private:
MyObject() : value_(0) {}
- virtual ~MyObject() {}
+ ~MyObject() {}
int value_;
};
-WrapperInfo MyObject::kWrapperInfo = { kEmbedderNativeGin };
-
-gin::Handle<MyObject> MyObject::Create(v8::Isolate* isolate) {
- return CreateHandle(isolate, new MyObject());
-}
-
-WrapperInfo* MyObject::GetWrapperInfo() {
- return &kWrapperInfo;
-}
-
-
-class MyObject2 : public Wrappable {
- public:
- MyObject2() {
- }
- static WrapperInfo kWrapperInfo;
- virtual WrapperInfo* GetWrapperInfo() OVERRIDE;
+class MyObject2 : public Wrappable<MyObject2> {
};
-WrapperInfo MyObject2::kWrapperInfo = { kEmbedderNativeGin };
-
-WrapperInfo* MyObject2::GetWrapperInfo() {
- return &kWrapperInfo;
-}
-
-
-class MyObjectBlink : public Wrappable {
- public:
- MyObjectBlink() {
- }
- static WrapperInfo kWrapperInfo;
- virtual WrapperInfo* GetWrapperInfo() OVERRIDE;
+class MyObjectBlink : public Wrappable<MyObjectBlink> {
};
-WrapperInfo MyObjectBlink::kWrapperInfo = { kEmbedderBlink };
-
-WrapperInfo* MyObjectBlink::GetWrapperInfo() {
- return &kWrapperInfo;
-}
-
+INIT_WRAPPABLE(gin::MyObject);
+INIT_WRAPPABLE(gin::MyObject2);
+INIT_WRAPPABLE(gin::MyObjectBlink);
void RegisterTemplates(v8::Isolate* isolate) {
PerIsolateData* data = PerIsolateData::From(isolate);
@@ -173,5 +140,4 @@ TEST_F(WrappableTest, GetAndSetProperty) {
EXPECT_EQ(191, obj->value());
}
-} // namespace
} // namespace gin
« no previous file with comments | « gin/wrappable.cc ('k') | mojo/apps/js/bindings/waiting_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698