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

Unified Diff: gin/wrappable_unittest.cc

Issue 105423003: gin::Wrappable shouldn't inherit from base::RefCounted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: gin/wrappable_unittest.cc
diff --git a/gin/wrappable_unittest.cc b/gin/wrappable_unittest.cc
index c653866bdd30a0b0011084896a8969fa889d35e4..7ab9df453dfc490eabf887e9e43866b99f5945a7 100644
--- a/gin/wrappable_unittest.cc
+++ b/gin/wrappable_unittest.cc
@@ -4,6 +4,7 @@
#include "base/logging.h"
#include "gin/arguments.h"
+#include "gin/handle.h"
#include "gin/per_isolate_data.h"
#include "gin/public/isolate_holder.h"
#include "gin/test/v8_test.h"
@@ -15,7 +16,7 @@ namespace {
class MyObject : public Wrappable {
public:
- static scoped_refptr<MyObject> Create();
+ static gin::Handle<MyObject> Create(v8::Isolate* isolate);
int value() const { return value_; }
void set_value(int value) { value_ = value; }
@@ -32,8 +33,8 @@ class MyObject : public Wrappable {
WrapperInfo MyObject::kWrapperInfo = { kEmbedderNativeGin };
-scoped_refptr<MyObject> MyObject::Create() {
- return make_scoped_refptr(new MyObject());
+gin::Handle<MyObject> MyObject::Create(v8::Isolate* isolate) {
+ return CreateHandle(isolate, new MyObject());
}
WrapperInfo* MyObject::GetWrapperInfo() {
@@ -92,14 +93,14 @@ TEST_F(WrappableTest, WrapAndUnwrap) {
v8::HandleScope handle_scope(isolate);
RegisterTemplate(isolate);
- scoped_refptr<MyObject> obj = MyObject::Create();
+ Handle<MyObject> obj = MyObject::Create(isolate);
- v8::Handle<v8::Value> wrapper = ConvertToV8(isolate, obj.get());
+ v8::Handle<v8::Value> wrapper = ConvertToV8(isolate, obj.Get());
EXPECT_FALSE(wrapper.IsEmpty());
MyObject* unwrapped = 0;
EXPECT_TRUE(ConvertFromV8(isolate, wrapper, &unwrapped));
- EXPECT_EQ(obj, unwrapped);
+ EXPECT_EQ(obj.Get(), unwrapped);
}
TEST_F(WrappableTest, GetAndSetProperty) {
@@ -107,7 +108,7 @@ TEST_F(WrappableTest, GetAndSetProperty) {
v8::HandleScope handle_scope(isolate);
RegisterTemplate(isolate);
- scoped_refptr<MyObject> obj = MyObject::Create();
+ gin::Handle<MyObject> obj = MyObject::Create(isolate);
obj->set_value(42);
EXPECT_EQ(42, obj->value());
@@ -126,7 +127,7 @@ TEST_F(WrappableTest, GetAndSetProperty) {
v8::Handle<v8::Function> func;
EXPECT_TRUE(ConvertFromV8(isolate, val, &func));
v8::Handle<v8::Value> argv[] = {
- ConvertToV8(isolate, obj.get()),
+ ConvertToV8(isolate, obj.Get()),
};
func->Call(v8::Undefined(isolate), 1, argv);
« gin/handle.h ('K') | « gin/wrappable.cc ('k') | mojo/apps/js/bindings/support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698