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

Unified Diff: third_party/WebKit/Source/platform/heap/Persistent.h

Issue 2702243003: Disallow cross-thread Persistent<> read access. (Closed)
Patch Set: rebased upto r451733 Created 3 years, 10 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: third_party/WebKit/Source/platform/heap/Persistent.h
diff --git a/third_party/WebKit/Source/platform/heap/Persistent.h b/third_party/WebKit/Source/platform/heap/Persistent.h
index 0f9e0a59bf7e6ec7a7b1fe85ab7ff1675aa3bc90..94f67dfdb37e738173897503cba8beb19bd4a9d9 100644
--- a/third_party/WebKit/Source/platform/heap/Persistent.h
+++ b/third_party/WebKit/Source/platform/heap/Persistent.h
@@ -109,11 +109,21 @@ class PersistentBase {
}
void clear() { assign(nullptr); }
- T& operator*() const { return *m_raw; }
+ T& operator*() const {
+ checkPointer();
+ return *m_raw;
+ }
explicit operator bool() const { return m_raw; }
- operator T*() const { return m_raw; }
+ operator T*() const {
+ checkPointer();
+ return m_raw;
+ }
T* operator->() const { return *this; }
- T* get() const { return m_raw; }
+
+ T* get() const {
+ checkPointer();
+ return m_raw;
+ }
template <typename U>
PersistentBase& operator=(U* other) {
@@ -243,7 +253,7 @@ class PersistentBase {
m_persistentNode = nullptr;
}
- void checkPointer() {
+ void checkPointer() const {
#if DCHECK_IS_ON()
if (!m_raw || isHashTableDeletedValue())
return;

Powered by Google App Engine
This is Rietveld 408576698