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

Side by Side Diff: Source/wtf/RawPtr.h

Issue 166443003: Move CSSCalcExpressionNode and subclasses to the oilpan heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review feedback Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSCalculationValueTest.cpp ('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) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 27 matching lines...) Expand all
38 // use reference counting or garbage collection based on a 38 // use reference counting or garbage collection based on a
39 // compile-time flag. 39 // compile-time flag.
40 40
41 namespace WTF { 41 namespace WTF {
42 42
43 template<typename T> 43 template<typename T>
44 class RawPtr { 44 class RawPtr {
45 public: 45 public:
46 RawPtr() : m_ptr(0) { } 46 RawPtr() : m_ptr(0) { }
47 RawPtr(T* ptr) : m_ptr(ptr) { } 47 RawPtr(T* ptr) : m_ptr(ptr) { }
48 48 RawPtr(const RawPtr& other)
49 template<typename U>
50 explicit RawPtr(const RawPtr<U>& other)
51 : m_ptr(other.get()) 49 : m_ptr(other.get())
52 { 50 {
53 } 51 }
52 template<typename U>
53 RawPtr(const RawPtr<U>& other)
54 : m_ptr(other.get())
55 {
56 }
54 57
55 T* get() const { return m_ptr; } 58 T* get() const { return m_ptr; }
56 void clear() { m_ptr = 0; } 59 void clear() { m_ptr = 0; }
57 // FIXME: oilpan: Remove release and leakRef once we remove RefPtrWillBeRawP tr. 60 // FIXME: oilpan: Remove release and leakRef once we remove RefPtrWillBeRawP tr.
58 RawPtr<T> release() 61 RawPtr<T> release()
59 { 62 {
60 RawPtr<T> tmp = m_ptr; 63 RawPtr<T> tmp = m_ptr;
61 m_ptr = 0; 64 m_ptr = 0;
62 return tmp; 65 return tmp;
63 } 66 }
64 T* leakRef() 67 T* leakRef()
65 { 68 {
66 T* ptr = m_ptr; 69 T* ptr = m_ptr;
67 m_ptr = 0; 70 m_ptr = 0;
68 return ptr; 71 return ptr;
69 } 72 }
70 73
71 RawPtr& operator=(T* ptr) 74 template<typename U>
75 RawPtr& operator=(U* ptr)
72 { 76 {
73 m_ptr = ptr; 77 m_ptr = ptr;
74 return *this; 78 return *this;
75 } 79 }
76 80
81 template<typename U>
82 RawPtr& operator=(RawPtr<U> ptr)
83 {
84 m_ptr = ptr.get();
85 return *this;
86 }
87
77 operator T*() const { return m_ptr; } 88 operator T*() const { return m_ptr; }
78 T& operator*() const { return *m_ptr; } 89 T& operator*() const { return *m_ptr; }
79 T* operator->() const { return m_ptr; } 90 T* operator->() const { return m_ptr; }
80 91
81 private: 92 private:
82 T* m_ptr; 93 T* m_ptr;
83 }; 94 };
84 95
85 } // namespace WTF 96 } // namespace WTF
86 97
87 using WTF::RawPtr; 98 using WTF::RawPtr;
88 99
89 #endif 100 #endif
OLDNEW
« no previous file with comments | « Source/core/css/CSSCalculationValueTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698