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

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: code review (jyasskin)' 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_);
}
+ v8::Handle<T> NewHandle(v8::Isolate* isolate) const {
+ 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) {
« no previous file with comments | « chrome/renderer/extensions/render_view_observer_natives.cc ('k') | chrome/renderer/extensions/v8_schema_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698