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

Side by Side Diff: third_party/WebKit/Source/platform/heap/Persistent.h

Issue 2019963002: Remove get from CrossThreadPersistent to avoid accidental use Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef Persistent_h 5 #ifndef Persistent_h
6 #define Persistent_h 6 #define Persistent_h
7 7
8 #include "platform/heap/Member.h" 8 #include "platform/heap/Member.h"
9 #include "platform/heap/PersistentNode.h" 9 #include "platform/heap/PersistentNode.h"
10 #include "wtf/Allocator.h" 10 #include "wtf/Allocator.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 CrossThreadPersistent(std::nullptr_t) : Parent(nullptr) { } 376 CrossThreadPersistent(std::nullptr_t) : Parent(nullptr) { }
377 CrossThreadPersistent(T* raw) : Parent(raw) { } 377 CrossThreadPersistent(T* raw) : Parent(raw) { }
378 CrossThreadPersistent(T& raw) : Parent(raw) { } 378 CrossThreadPersistent(T& raw) : Parent(raw) { }
379 CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { } 379 CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { }
380 template<typename U> 380 template<typename U>
381 CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { } 381 CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { }
382 template<typename U> 382 template<typename U>
383 CrossThreadPersistent(const Member<U>& other) : Parent(other) { } 383 CrossThreadPersistent(const Member<U>& other) : Parent(other) { }
384 CrossThreadPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { } 384 CrossThreadPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { }
385 385
386 T* atomicGet() { return Parent::atomicGet(); } 386 T* unsafeGet() const { return Parent::get(); }
387 387
388 template<typename U> 388 template<typename U>
389 CrossThreadPersistent& operator=(U* other) 389 CrossThreadPersistent& operator=(U* other)
390 { 390 {
391 Parent::operator=(other); 391 Parent::operator=(other);
392 return *this; 392 return *this;
393 } 393 }
394 394
395 CrossThreadPersistent& operator=(std::nullptr_t) 395 CrossThreadPersistent& operator=(std::nullptr_t)
396 { 396 {
(...skipping 13 matching lines...) Expand all
410 Parent::operator=(other); 410 Parent::operator=(other);
411 return *this; 411 return *this;
412 } 412 }
413 413
414 template<typename U> 414 template<typename U>
415 CrossThreadPersistent& operator=(const Member<U>& other) 415 CrossThreadPersistent& operator=(const Member<U>& other)
416 { 416 {
417 Parent::operator=(other); 417 Parent::operator=(other);
418 return *this; 418 return *this;
419 } 419 }
420
421 protected:
422 friend class CrossThreadPersistentRegion;
423 friend struct WTF::PointerParamStorageTraits<T*, true>;
424
425 T* get() const { return Parent::get(); }
sof 2016/06/02 07:00:12 Could you add a comment (here or next to unsafeGet
426 T* atomicGet() { return Parent::atomicGet(); }
420 }; 427 };
421 428
422 // Combines the behavior of CrossThreadPersistent and WeakPersistent. 429 // Combines the behavior of CrossThreadPersistent and WeakPersistent.
423 template<typename T> 430 template<typename T>
424 class CrossThreadWeakPersistent : public PersistentBase<T, WeakPersistentConfigu ration, CrossThreadPersistentConfiguration> { 431 class CrossThreadWeakPersistent : public PersistentBase<T, WeakPersistentConfigu ration, CrossThreadPersistentConfiguration> {
425 typedef PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistent Configuration> Parent; 432 typedef PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistent Configuration> Parent;
426 public: 433 public:
427 CrossThreadWeakPersistent() : Parent() { } 434 CrossThreadWeakPersistent() : Parent() { }
428 CrossThreadWeakPersistent(std::nullptr_t) : Parent(nullptr) { } 435 CrossThreadWeakPersistent(std::nullptr_t) : Parent(nullptr) { }
429 CrossThreadWeakPersistent(T* raw) : Parent(raw) { } 436 CrossThreadWeakPersistent(T* raw) : Parent(raw) { }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 { 677 {
671 return Persistent<T>(value); 678 return Persistent<T>(value);
672 } 679 }
673 680
674 template <typename T> 681 template <typename T>
675 CrossThreadPersistent<T> wrapCrossThreadPersistent(T* value) 682 CrossThreadPersistent<T> wrapCrossThreadPersistent(T* value)
676 { 683 {
677 return CrossThreadPersistent<T>(value); 684 return CrossThreadPersistent<T>(value);
678 } 685 }
679 686
687 template <typename T>
688 CrossThreadPersistent<T> wrapCrossThreadPersistent(CrossThreadPersistent<T> valu e)
689 {
690 return CrossThreadPersistent<T>(value);
691 }
692
680 // Comparison operators between (Weak)Members, Persistents, and UntracedMembers. 693 // Comparison operators between (Weak)Members, Persistents, and UntracedMembers.
681 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t Member<U>& b) { return a.get() == b.get(); } 694 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t Member<U>& b) { return a.get() == b.get(); }
682 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t Member<U>& b) { return a.get() != b.get(); } 695 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t Member<U>& b) { return a.get() != b.get(); }
683 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Persistent<U>& b) { return a.get() == b.get(); } 696 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Persistent<U>& b) { return a.get() == b.get(); }
684 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Persistent<U>& b) { return a.get() != b.get(); } 697 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Persistent<U>& b) { return a.get() != b.get(); }
685 698
686 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t Persistent<U>& b) { return a.get() == b.get(); } 699 template<typename T, typename U> inline bool operator==(const Member<T>& a, cons t Persistent<U>& b) { return a.get() == b.get(); }
687 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t Persistent<U>& b) { return a.get() != b.get(); } 700 template<typename T, typename U> inline bool operator!=(const Member<T>& a, cons t Persistent<U>& b) { return a.get() != b.get(); }
688 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Member<U>& b) { return a.get() == b.get(); } 701 template<typename T, typename U> inline bool operator==(const Persistent<T>& a, const Member<U>& b) { return a.get() == b.get(); }
689 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Member<U>& b) { return a.get() != b.get(); } 702 template<typename T, typename U> inline bool operator!=(const Persistent<T>& a, const Member<U>& b) { return a.get() != b.get(); }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 // into it. 755 // into it.
743 // 756 //
744 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like 757 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty pe like
745 // CrossThreadWeakPersistent<>. 758 // CrossThreadWeakPersistent<>.
746 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); } 759 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); }
747 }; 760 };
748 761
749 } // namespace WTF 762 } // namespace WTF
750 763
751 #endif // Persistent_h 764 #endif // Persistent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698