Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 | 48 | 
| 49 template<typename U> | 49 template<typename U> | 
| 50 explicit RawPtr(const RawPtr<U>& other) | 50 explicit RawPtr(const RawPtr<U>& other) | 
| 51 : m_ptr(other.get()) | 51 : m_ptr(other.get()) | 
| 52 { | 52 { | 
| 53 } | 53 } | 
| 54 | 54 | 
| 55 T* get() const { return m_ptr; } | 55 T* get() const { return m_ptr; } | 
| 56 void clear() { m_ptr = 0; } | 56 void clear() { m_ptr = 0; } | 
| 57 // FIXME: oilpan: Remove release and leakRef once we remove RefPtrWillBeRawP tr. | 57 // FIXME: oilpan: Remove release and leakRef once we remove RefPtrWillBeRawP tr. | 
| 58 RawPtr<T> release() const { return m_ptr; } | 58 RawPtr<T> release() | 
| 59 { | |
| 60 RawPtr<T> tmp = m_ptr; | |
| 61 m_ptr = 0; | |
| 
 
haraken
2014/02/12 14:05:45
Nice catch!
 
 | |
| 62 return tmp; | |
| 63 } | |
| 59 T* leakRef() | 64 T* leakRef() | 
| 60 { | 65 { | 
| 61 T* ptr = m_ptr; | 66 T* ptr = m_ptr; | 
| 62 m_ptr = 0; | 67 m_ptr = 0; | 
| 63 return ptr; | 68 return ptr; | 
| 64 } | 69 } | 
| 65 | 70 | 
| 66 RawPtr& operator=(T* ptr) | 71 RawPtr& operator=(T* ptr) | 
| 67 { | 72 { | 
| 68 m_ptr = ptr; | 73 m_ptr = ptr; | 
| 69 return *this; | 74 return *this; | 
| 70 } | 75 } | 
| 71 | 76 | 
| 72 operator T*() const { return m_ptr; } | 77 operator T*() const { return m_ptr; } | 
| 73 T& operator*() const { return *m_ptr; } | 78 T& operator*() const { return *m_ptr; } | 
| 74 T* operator->() const { return m_ptr; } | 79 T* operator->() const { return m_ptr; } | 
| 75 | 80 | 
| 76 private: | 81 private: | 
| 77 T* m_ptr; | 82 T* m_ptr; | 
| 78 }; | 83 }; | 
| 79 | 84 | 
| 80 } // namespace WTF | 85 } // namespace WTF | 
| 81 | 86 | 
| 82 using WTF::RawPtr; | 87 using WTF::RawPtr; | 
| 83 | 88 | 
| 84 #endif | 89 #endif | 
| OLD | NEW |