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

Side by Side Diff: public/platform/WebPrivatePtr.h

Issue 401973003: Rename WebCore namespace to blink in Public (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « public/platform/WebPrerender.h ('k') | public/platform/WebRTCConfiguration.h » ('j') | 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef WebPrivatePtr_h 31 #ifndef WebPrivatePtr_h
32 #define WebPrivatePtr_h 32 #define WebPrivatePtr_h
33 33
34 #include "WebCommon.h" 34 #include "WebCommon.h"
35 35
36 #if INSIDE_BLINK 36 #if INSIDE_BLINK
37 37
38 namespace WebCore { template<typename T> class TreeShared; } 38 namespace blink { template<typename T> class TreeShared; }
39 39
40 #include "platform/heap/Handle.h" 40 #include "platform/heap/Handle.h"
41 #include "wtf/PassRefPtr.h" 41 #include "wtf/PassRefPtr.h"
42 #include "wtf/TypeTraits.h" 42 #include "wtf/TypeTraits.h"
43 #endif 43 #endif
44 44
45 namespace blink { 45 namespace blink {
46 46
47 #if INSIDE_BLINK 47 #if INSIDE_BLINK
48 enum LifetimeManagementType { 48 enum LifetimeManagementType {
49 RefCountedLifetime, 49 RefCountedLifetime,
50 GarbageCollectedLifetime, 50 GarbageCollectedLifetime,
51 RefCountedGarbageCollectedLifetime 51 RefCountedGarbageCollectedLifetime
52 }; 52 };
53 53
54 template<typename T> 54 template<typename T>
55 class LifetimeOf { 55 class LifetimeOf {
56 static const bool isGarbageCollected = WTF::IsSubclassOfTemplate<T, WebCore: :GarbageCollected>::value; 56 static const bool isGarbageCollected = WTF::IsSubclassOfTemplate<T, blink::G arbageCollected>::value;
57 static const bool isRefCountedGarbageCollected = WTF::IsSubclassOfTemplate<T , WebCore::RefCountedGarbageCollected>::value; 57 static const bool isRefCountedGarbageCollected = WTF::IsSubclassOfTemplate<T , blink::RefCountedGarbageCollected>::value;
58 public: 58 public:
59 static const LifetimeManagementType value = 59 static const LifetimeManagementType value =
60 !isGarbageCollected ? RefCountedLifetime : 60 !isGarbageCollected ? RefCountedLifetime :
61 isRefCountedGarbageCollected ? RefCountedGarbageCollectedLifetime : Garb ageCollectedLifetime; 61 isRefCountedGarbageCollected ? RefCountedGarbageCollectedLifetime : Garb ageCollectedLifetime;
62 }; 62 };
63 63
64 template<typename T, LifetimeManagementType lifetime> 64 template<typename T, LifetimeManagementType lifetime>
65 class PtrStorageImpl; 65 class PtrStorageImpl;
66 66
67 template<typename T> 67 template<typename T>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 class PtrStorageImpl<T, GarbageCollectedLifetime> { 99 class PtrStorageImpl<T, GarbageCollectedLifetime> {
100 public: 100 public:
101 void assign(const RawPtr<T>& val) 101 void assign(const RawPtr<T>& val)
102 { 102 {
103 if (!val) { 103 if (!val) {
104 release(); 104 release();
105 return; 105 return;
106 } 106 }
107 107
108 if (!m_handle) 108 if (!m_handle)
109 m_handle = new WebCore::Persistent<T>(); 109 m_handle = new blink::Persistent<T>();
110 110
111 (*m_handle) = val; 111 (*m_handle) = val;
112 } 112 }
113 113
114 void assign(T* ptr) { assign(RawPtr<T>(ptr)); } 114 void assign(T* ptr) { assign(RawPtr<T>(ptr)); }
115 template<typename U> void assign(const RawPtr<U>& val) { assign(RawPtr<T>(va l)); } 115 template<typename U> void assign(const RawPtr<U>& val) { assign(RawPtr<T>(va l)); }
116 116
117 void assign(const PtrStorageImpl& other) { assign(other.get()); } 117 void assign(const PtrStorageImpl& other) { assign(other.get()); }
118 118
119 T* get() const { return m_handle ? m_handle->get() : 0; } 119 T* get() const { return m_handle ? m_handle->get() : 0; }
120 120
121 void release() 121 void release()
122 { 122 {
123 delete m_handle; 123 delete m_handle;
124 m_handle = 0; 124 m_handle = 0;
125 } 125 }
126 126
127 private: 127 private:
128 WebCore::Persistent<T>* m_handle; 128 blink::Persistent<T>* m_handle;
129 }; 129 };
130 130
131 template<typename T> 131 template<typename T>
132 class PtrStorageImpl<T, RefCountedGarbageCollectedLifetime> : public PtrStorageI mpl<T, GarbageCollectedLifetime> { 132 class PtrStorageImpl<T, RefCountedGarbageCollectedLifetime> : public PtrStorageI mpl<T, GarbageCollectedLifetime> {
133 public: 133 public:
134 void assign(const PassRefPtrWillBeRawPtr<T>& val) { PtrStorageImpl<T, Garbag eCollectedLifetime>::assign(val.get()); } 134 void assign(const PassRefPtrWillBeRawPtr<T>& val) { PtrStorageImpl<T, Garbag eCollectedLifetime>::assign(val.get()); }
135 135
136 void assign(const PtrStorageImpl& other) { PtrStorageImpl<T, GarbageCollecte dLifetime>::assign(other.get()); } 136 void assign(const PtrStorageImpl& other) { PtrStorageImpl<T, GarbageCollecte dLifetime>::assign(other.get()); }
137 }; 137 };
138 138
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // } 177 // }
178 // BLINK_EXPORT void assign(const WebFoo&); // Implemented in the body. 178 // BLINK_EXPORT void assign(const WebFoo&); // Implemented in the body.
179 // 179 //
180 // // Methods that are exposed to Chromium and which are specific to 180 // // Methods that are exposed to Chromium and which are specific to
181 // // WebFoo go here. 181 // // WebFoo go here.
182 // BLINK_EXPORT doWebFooThing(); 182 // BLINK_EXPORT doWebFooThing();
183 // 183 //
184 // // Methods that are used only by other Blink classes should only be 184 // // Methods that are used only by other Blink classes should only be
185 // // declared when INSIDE_BLINK is set. 185 // // declared when INSIDE_BLINK is set.
186 // #if INSIDE_BLINK 186 // #if INSIDE_BLINK
187 // WebFoo(const WTF::PassRefPtr<WebCore::Foo>&); 187 // WebFoo(const WTF::PassRefPtr<blink::Foo>&);
188 // #endif 188 // #endif
189 // 189 //
190 // private: 190 // private:
191 // WebPrivatePtr<WebCore::Foo> m_private; 191 // WebPrivatePtr<blink::Foo> m_private;
192 // }; 192 // };
193 // 193 //
194 // // WebFoo.cpp 194 // // WebFoo.cpp
195 // WebFoo::~WebFoo() { m_private.reset(); } 195 // WebFoo::~WebFoo() { m_private.reset(); }
196 // void WebFoo::assign(const WebFoo& other) { ... } 196 // void WebFoo::assign(const WebFoo& other) { ... }
197 // 197 //
198 template <typename T> 198 template <typename T>
199 class WebPrivatePtr { 199 class WebPrivatePtr {
200 public: 200 public:
201 WebPrivatePtr() : m_storage(0) { } 201 WebPrivatePtr() : m_storage(0) { }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // Disable the copy constructor; classes that contain a WebPrivatePtr 264 // Disable the copy constructor; classes that contain a WebPrivatePtr
265 // should implement their copy constructor using assign(). 265 // should implement their copy constructor using assign().
266 WebPrivatePtr(const WebPrivatePtr<T>&); 266 WebPrivatePtr(const WebPrivatePtr<T>&);
267 267
268 void* m_storage; 268 void* m_storage;
269 }; 269 };
270 270
271 } // namespace blink 271 } // namespace blink
272 272
273 #endif 273 #endif
OLDNEW
« no previous file with comments | « public/platform/WebPrerender.h ('k') | public/platform/WebRTCConfiguration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698