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

Unified Diff: chrome/renderer/extensions/scoped_persistent.h

Issue 23636015: Remove unsafe access hacks from ScopedPersistent. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/extensions/scoped_persistent.h
diff --git a/chrome/renderer/extensions/scoped_persistent.h b/chrome/renderer/extensions/scoped_persistent.h
index 6f60fad185b67eff8a944bde5a314921fad4422c..f3048eb509dee0c887b96713ac1fc42d80de81ab 100644
--- a/chrome/renderer/extensions/scoped_persistent.h
+++ b/chrome/renderer/extensions/scoped_persistent.h
@@ -40,15 +40,8 @@ class ScopedPersistent {
handle_.Clear();
}
- v8::Handle<T> operator->() const {
- return get();
- }
-
- // TODO(dcarney): Remove this function
- // This is an unsafe access to the underlying handle
- v8::Handle<T> get() const {
- return *reinterpret_cast<v8::Handle<T>*>(
- const_cast<v8::Persistent<T>* >(&handle_));
+ bool IsEmpty() const {
+ return handle_.IsEmpty();
}
v8::Handle<T> NewHandle() const {
@@ -57,6 +50,12 @@ class ScopedPersistent {
return v8::Local<T>::New(GetIsolate(handle_), handle_);
Jeffrey Yasskin 2013/09/09 17:45:07 I assume this method is going away soon too?
marja 2013/09/09 18:16:18 v8::Isolate::GetCurrent is going away; ideally we'
}
+ v8::Handle<T> NewHandle(v8::Isolate* isolate) const {
Jeffrey Yasskin 2013/09/09 17:45:07 I've never quite understood when to use Local vs H
marja 2013/09/09 18:16:18 They're basically the same thing - ATM Local is th
+ if (handle_.IsEmpty())
+ return v8::Local<T>();
+ return v8::Local<T>::New(isolate, handle_);
+ }
+
template<typename P>
void MakeWeak(P* parameters,
typename v8::WeakReferenceCallbacks<T, P>::Revivable callback) {

Powered by Google App Engine
This is Rietveld 408576698