| Index: third_party/WebKit/Source/platform/heap/PersistentNode.h
|
| diff --git a/third_party/WebKit/Source/platform/heap/PersistentNode.h b/third_party/WebKit/Source/platform/heap/PersistentNode.h
|
| index 9ed41b0db03c42f9093034a87bf8e58ca1d55606..60d179c602368d33fe3575897f2b0debf9f74f52 100644
|
| --- a/third_party/WebKit/Source/platform/heap/PersistentNode.h
|
| +++ b/third_party/WebKit/Source/platform/heap/PersistentNode.h
|
| @@ -202,14 +202,27 @@ class CrossThreadPersistentRegion final {
|
| STACK_ALLOCATED();
|
|
|
| public:
|
| - LockScope(CrossThreadPersistentRegion& persistent_region)
|
| - : persistent_region_(persistent_region) {
|
| - persistent_region_.lock();
|
| + LockScope(CrossThreadPersistentRegion& persistent_region,
|
| + bool try_lock = false)
|
| + : persistent_region_(persistent_region), locked_(true) {
|
| + if (try_lock)
|
| + locked_ = persistent_region_.TryLock();
|
| + else
|
| + persistent_region_.lock();
|
| }
|
| - ~LockScope() { persistent_region_.unlock(); }
|
| + ~LockScope() {
|
| + if (locked_)
|
| + persistent_region_.unlock();
|
| + }
|
| +
|
| + // If the lock scope is set up with |try_lock| set to |true|, caller/user
|
| + // is responsible for checking whether the GC lock was taken via
|
| + // |HasLock()|.
|
| + bool HasLock() const { return locked_; }
|
|
|
| private:
|
| CrossThreadPersistentRegion& persistent_region_;
|
| + bool locked_;
|
| };
|
|
|
| void TracePersistentNodes(Visitor* visitor) {
|
| @@ -237,6 +250,8 @@ class CrossThreadPersistentRegion final {
|
|
|
| void unlock() { mutex_.unlock(); }
|
|
|
| + bool TryLock() { return mutex_.TryLock(); }
|
| +
|
| // We don't make CrossThreadPersistentRegion inherit from PersistentRegion
|
| // because we don't want to virtualize performance-sensitive methods
|
| // such as PersistentRegion::allocate/freePersistentNode.
|
|
|