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

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: Revise WebPrivatePtr copy-ctor comment 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
« no previous file with comments | « Source/WebKit/chromium/src/WebDOMMessageEvent.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) 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 23 matching lines...) Expand all
34 #include "WebCommon.h" 34 #include "WebCommon.h"
35 35
36 #if WEBKIT_IMPLEMENTATION 36 #if WEBKIT_IMPLEMENTATION
37 #include <wtf/PassRefPtr.h> 37 #include <wtf/PassRefPtr.h>
38 #endif 38 #endif
39 39
40 namespace WebKit { 40 namespace WebKit {
41 41
42 // This class is an implementation detail of the WebKit API. It exists 42 // This class is an implementation detail of the WebKit API. It exists
43 // to help simplify the implementation of WebKit interfaces that merely 43 // to help simplify the implementation of WebKit interfaces that merely
44 // wrap a reference counted WebCore class. 44 // wrap a reference counted WebCore class.
darin (slow to review) 2013/05/22 20:28:22 optional: it might be nice to provide sample code
dmichael (off chromium) 2013/05/22 20:54:29 Good suggestion. Done.
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 PassRefPtr<T>& prp) 54 WebPrivatePtr(const PassRefPtr<T>& prp)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 private: 91 private:
92 #if WEBKIT_IMPLEMENTATION 92 #if WEBKIT_IMPLEMENTATION
93 void assign(T* p) 93 void assign(T* p)
94 { 94 {
95 // p is already ref'd for us by the caller 95 // p is already ref'd for us by the caller
96 if (m_ptr) 96 if (m_ptr)
97 m_ptr->deref(); 97 m_ptr->deref();
98 m_ptr = p; 98 m_ptr = p;
99 } 99 }
100 #else
101 // Disable assign; we define it above for when WEBKIT_IMPLEMENTATION is set,
darin (slow to review) 2013/05/22 20:28:22 nit: confusing to call this operator "assign" sinc
dmichael (off chromium) 2013/05/22 20:54:29 Good point, done.
102 // but we need to make sure that it is not used outside there; the
103 // compiler-provided version won't handle reference counting properly.
104 WebPrivatePtr<T>& operator=(const WebPrivatePtr<T>& other);
100 #endif 105 #endif
106 // Disable copy; classes that contain a WebPrivatePtr should implement their
darin (slow to review) 2013/05/22 20:28:22 ditto: copy -> copy constructor
dmichael (off chromium) 2013/05/22 20:54:29 Done.
107 // copy constructor using assign().
108 WebPrivatePtr(const WebPrivatePtr<T>&);
101 109
102 T* m_ptr; 110 T* m_ptr;
103 }; 111 };
104 112
105 } // namespace WebKit 113 } // namespace WebKit
106 114
107 #endif 115 #endif
OLDNEW
« no previous file with comments | « Source/WebKit/chromium/src/WebDOMMessageEvent.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698