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

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

Issue 15271012: Clean up WebDOMEvent ownership of WebCore::Event. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: merge Created 7 years, 7 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 /* 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // wrap a reference counted WebCore class. 44 // wrap a reference counted WebCore class.
45 template <typename T> 45 template <typename T>
46 class WebPrivatePtr { 46 class WebPrivatePtr {
47 public: 47 public:
48 WebPrivatePtr() : m_ptr(0) { } 48 WebPrivatePtr() : m_ptr(0) { }
49 ~WebPrivatePtr() { WEBKIT_ASSERT(!m_ptr); } 49 ~WebPrivatePtr() { WEBKIT_ASSERT(!m_ptr); }
50 50
51 bool isNull() const { return !m_ptr; } 51 bool isNull() const { return !m_ptr; }
52 52
53 #if WEBKIT_IMPLEMENTATION 53 #if WEBKIT_IMPLEMENTATION
54 WebPrivatePtr(const WebPrivatePtr& other)
55 : m_ptr(other.m_ptr)
56 {
57 if (m_ptr)
58 m_ptr->ref();
59 }
60
abarth-chromium 2013/05/22 16:21:49 We shouldn't need to modify WebPrivatePtr
54 WebPrivatePtr(const PassRefPtr<T>& prp) 61 WebPrivatePtr(const PassRefPtr<T>& prp)
55 : m_ptr(prp.leakRef()) 62 : m_ptr(prp.leakRef())
56 { 63 {
57 } 64 }
58 65
59 void reset() 66 void reset()
60 { 67 {
61 assign(0); 68 assign(0);
62 } 69 }
63 70
(...skipping 26 matching lines...) Expand all
90 97
91 private: 98 private:
92 #if WEBKIT_IMPLEMENTATION 99 #if WEBKIT_IMPLEMENTATION
93 void assign(T* p) 100 void assign(T* p)
94 { 101 {
95 // p is already ref'd for us by the caller 102 // p is already ref'd for us by the caller
96 if (m_ptr) 103 if (m_ptr)
97 m_ptr->deref(); 104 m_ptr->deref();
98 m_ptr = p; 105 m_ptr = p;
99 } 106 }
107 #else
108 // Disable copy and assign; we define them above for the implementation, but
109 // we need to make sure that they aren't used outside there; the compiler-
110 // provided versions won't handle reference counting properly.
111 WebPrivatePtr(const WebPrivatePtr<T>&);
112 WebPrivatePtr<T>& operator=(const WebPrivatePtr<T>& other);
100 #endif 113 #endif
101 114
102 T* m_ptr; 115 T* m_ptr;
103 }; 116 };
104 117
105 } // namespace WebKit 118 } // namespace WebKit
106 119
107 #endif 120 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698