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

Side by Side Diff: third_party/WebKit/Source/wtf/WeakPtr.h

Issue 2371663002: Introduce an injection point to configure the internal pointer of WeakPtr
Patch Set: fix Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Persistent.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #ifndef WTF_WeakPtr_h 26 #ifndef WTF_WeakPtr_h
27 #define WTF_WeakPtr_h 27 #define WTF_WeakPtr_h
28 28
29 #include "base/memory/weak_ptr.h" 29 #include "base/memory/weak_ptr.h"
30 #include "wtf/Noncopyable.h" 30 #include "wtf/Noncopyable.h"
31 31
32 namespace WTF { 32 namespace WTF {
33 33
34 template<typename T> 34 template <typename T, typename Traits = base::DefaultWeakPtrTraits>
35 using WeakPtr = base::WeakPtr<T>; 35 using WeakPtr = base::WeakPtr<T, Traits>;
36 36
37 template<typename T> 37 template <typename T, typename Traits = base::DefaultWeakPtrTraits>
38 class WeakPtrFactory { 38 class WeakPtrFactory : public base::WeakPtrFactory<T, Traits> {
39 WTF_MAKE_NONCOPYABLE(WeakPtrFactory<T>); 39 WTF_MAKE_NONCOPYABLE(WeakPtrFactory);
40 USING_FAST_MALLOC(WeakPtrFactory); 40 DISALLOW_NEW();
41
42 private:
43 using Base = base::WeakPtrFactory<T, Traits>;
44
41 public: 45 public:
42 explicit WeakPtrFactory(T* ptr) : m_factory(ptr) { } 46 explicit WeakPtrFactory(T* ptr)
47 : Base(ptr)
48 {
49 }
43 50
44 WeakPtr<T> createWeakPtr() { return m_factory.GetWeakPtr(); } 51 WeakPtr<T, Traits> createWeakPtr() { return this->GetWeakPtr(); }
45 52
46 void revokeAll() 53 void revokeAll()
47 { 54 {
48 m_factory.InvalidateWeakPtrs(); 55 this->InvalidateWeakPtrs();
49 } 56 }
50 57
51 bool hasWeakPtrs() const 58 bool hasWeakPtrs() const
52 { 59 {
53 return m_factory.HasWeakPtrs(); 60 return this->HasWeakPtrs();
54 } 61 }
55
56 private:
57 base::WeakPtrFactory<T> m_factory;
58 }; 62 };
59 63
60 } // namespace WTF 64 } // namespace WTF
61 65
62 using WTF::WeakPtr; 66 using WTF::WeakPtr;
63 using WTF::WeakPtrFactory; 67 using WTF::WeakPtrFactory;
64 68
65 #endif 69 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Persistent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698