summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/content_shell.gypi1
-rw-r--r--content/shell/renderer/test_runner/unsafe_persistent.h50
-rw-r--r--content/shell/renderer/test_runner/web_ax_object_proxy.cc23
-rw-r--r--content/shell/renderer/test_runner/web_ax_object_proxy.h5
4 files changed, 12 insertions, 67 deletions
diff --git a/content/content_shell.gypi b/content/content_shell.gypi
index e10b6e7..b54eb86 100644
--- a/content/content_shell.gypi
+++ b/content/content_shell.gypi
@@ -240,7 +240,6 @@
'shell/renderer/test_runner/test_runner.h',
'shell/renderer/test_runner/text_input_controller.cc',
'shell/renderer/test_runner/text_input_controller.h',
- 'shell/renderer/test_runner/unsafe_persistent.h',
'shell/renderer/test_runner/web_ax_object_proxy.cc',
'shell/renderer/test_runner/web_ax_object_proxy.h',
'shell/renderer/webkit_test_runner.cc',
diff --git a/content/shell/renderer/test_runner/unsafe_persistent.h b/content/shell/renderer/test_runner/unsafe_persistent.h
deleted file mode 100644
index b47a33e..0000000
--- a/content/shell/renderer/test_runner/unsafe_persistent.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_UNSAFE_PERSISTENT_H_
-#define CONTENT_SHELL_RENDERER_TEST_RUNNER_UNSAFE_PERSISTENT_H_
-
-#include "v8/include/v8.h"
-
-namespace content {
-
-// An unsafe way to pass Persistent handles around. Do not use unless you know
-// what you're doing. UnsafePersistent is only safe to use when we know that the
-// memory pointed by it is not going away: 1) When GC cannot happen while the
-// UnsafePersistent is alive or 2) when there is a strong Persistent keeping the
-// memory alive while the UnsafePersistent is alive.
-template<typename T> class UnsafePersistent {
- public:
- UnsafePersistent() : value_(0) { }
-
- explicit UnsafePersistent(v8::Persistent<T>* handle) {
- value_ = handle->ClearAndLeak();
- }
-
- UnsafePersistent(v8::Isolate* isolate, const v8::Handle<T>& handle) {
- v8::Persistent<T> persistent(isolate, handle);
- value_ = persistent.ClearAndLeak();
- }
-
- // Usage of this function requires
- // V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR to be defined
- void Dispose() {
- v8::Persistent<T> handle(value_);
- handle.Reset();
- value_ = 0;
- }
-
- // Usage of this function requires
- // V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR to be defined
- v8::Local<T> NewLocal(v8::Isolate* isolate) {
- return v8::Local<T>::New(isolate, v8::Local<T>(value_));
- }
-
- private:
- T* value_;
-};
-
-} // namespace content
-
-#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_UNSAFE_PERSISTENT_H_
diff --git a/content/shell/renderer/test_runner/web_ax_object_proxy.cc b/content/shell/renderer/test_runner/web_ax_object_proxy.cc
index 3fcafba..6f9a85f 100644
--- a/content/shell/renderer/test_runner/web_ax_object_proxy.cc
+++ b/content/shell/renderer/test_runner/web_ax_object_proxy.cc
@@ -980,7 +980,8 @@ bool RootWebAXObjectProxy::IsRoot() const {
return true;
}
-WebAXObjectProxyList::WebAXObjectProxyList() {
+WebAXObjectProxyList::WebAXObjectProxyList()
+ : elements_(blink::mainThreadIsolate()) {
}
WebAXObjectProxyList::~WebAXObjectProxyList() {
@@ -988,9 +989,7 @@ WebAXObjectProxyList::~WebAXObjectProxyList() {
}
void WebAXObjectProxyList::Clear() {
- for (ElementList::iterator i = elements_.begin(); i != elements_.end(); ++i)
- i->Dispose();
- elements_.clear();
+ elements_.Clear();
}
v8::Handle<v8::Object> WebAXObjectProxyList::GetOrCreate(
@@ -1000,15 +999,15 @@ v8::Handle<v8::Object> WebAXObjectProxyList::GetOrCreate(
v8::Isolate* isolate = blink::mainThreadIsolate();
- size_t elementCount = elements_.size();
+ size_t elementCount = elements_.Size();
for (size_t i = 0; i < elementCount; i++) {
WebAXObjectProxy* unwrapped_object = NULL;
- bool result = gin::ConvertFromV8(isolate, elements_[i].NewLocal(isolate),
+ bool result = gin::ConvertFromV8(isolate, elements_.Get(i),
&unwrapped_object);
DCHECK(result);
DCHECK(unwrapped_object);
if (unwrapped_object->IsEqualToObject(object))
- return elements_[i].NewLocal(isolate);
+ return elements_.Get(i);
}
v8::Handle<v8::Value> value_handle = gin::CreateHandle(
@@ -1016,9 +1015,8 @@ v8::Handle<v8::Object> WebAXObjectProxyList::GetOrCreate(
if (value_handle.IsEmpty())
return v8::Handle<v8::Object>();
v8::Handle<v8::Object> handle = value_handle->ToObject();
- UnsafePersistent<v8::Object> unsafe_handle(isolate, handle);
- elements_.push_back(unsafe_handle);
- return unsafe_handle.NewLocal(isolate);
+ elements_.Append(handle);
+ return handle;
}
v8::Handle<v8::Object> WebAXObjectProxyList::CreateRoot(
@@ -1029,9 +1027,8 @@ v8::Handle<v8::Object> WebAXObjectProxyList::CreateRoot(
if (value_handle.IsEmpty())
return v8::Handle<v8::Object>();
v8::Handle<v8::Object> handle = value_handle->ToObject();
- UnsafePersistent<v8::Object> unsafe_handle(isolate, handle);
- elements_.push_back(unsafe_handle);
- return unsafe_handle.NewLocal(isolate);
+ elements_.Append(handle);
+ return handle;
}
} // namespace content
diff --git a/content/shell/renderer/test_runner/web_ax_object_proxy.h b/content/shell/renderer/test_runner/web_ax_object_proxy.h
index b10b5e8..e8bc25b 100644
--- a/content/shell/renderer/test_runner/web_ax_object_proxy.h
+++ b/content/shell/renderer/test_runner/web_ax_object_proxy.h
@@ -6,13 +6,12 @@
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_
#include <string>
-#include <vector>
#include "base/basictypes.h"
-#include "content/shell/renderer/test_runner/unsafe_persistent.h"
#include "gin/object_template_builder.h"
#include "gin/wrappable.h"
#include "third_party/WebKit/public/web/WebAXObject.h"
+#include "v8/include/v8-util.h"
#include "v8/include/v8.h"
namespace blink {
@@ -159,7 +158,7 @@ class WebAXObjectProxyList : public WebAXObjectProxy::Factory {
v8::Handle<v8::Object> CreateRoot(const blink::WebAXObject&);
private:
- typedef std::vector<UnsafePersistent<v8::Object> > ElementList;
+ typedef v8::PersistentValueVector<v8::Object> ElementList;
ElementList elements_;
};