Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/intrusive_ptr.h

Issue 29385742: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 2 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Rebased Created April 13, 2017, 1:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/filter/Filter.cpp ('k') | compiled/subscription/Subscription.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 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 template<typename T, 63 template<typename T,
64 class = typename std::enable_if<std::is_base_of<ref_counted,T>::value>::type > 64 class = typename std::enable_if<std::is_base_of<ref_counted,T>::value>::type >
65 class intrusive_ptr 65 class intrusive_ptr
66 { 66 {
67 public: 67 public:
68 explicit intrusive_ptr() 68 explicit intrusive_ptr()
69 : mPointer(nullptr) 69 : mPointer(nullptr)
70 { 70 {
71 } 71 }
72 72
73 explicit intrusive_ptr(T* pointer) 73 explicit intrusive_ptr(T* pointer, bool addRef = true)
74 : mPointer(pointer) 74 : mPointer(pointer)
75 { 75 {
76 // Raw pointers always had their reference count increased by whatever gave 76 if (mPointer && addRef)
77 // us the pointer so we don't need to do it here. 77 mPointer->AddRef();
78 } 78 }
79 79
80 intrusive_ptr(const intrusive_ptr& other) 80 intrusive_ptr(const intrusive_ptr& other)
81 : mPointer(other.mPointer) 81 : mPointer(other.mPointer)
82 { 82 {
83 if (mPointer) 83 if (mPointer)
84 mPointer->AddRef(); 84 mPointer->AddRef();
85 } 85 }
86 86
87 intrusive_ptr(intrusive_ptr&& other) 87 intrusive_ptr(intrusive_ptr&& other)
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 inline bool operator==(const T* a, const intrusive_ptr<U>& b) 208 inline bool operator==(const T* a, const intrusive_ptr<U>& b)
209 { 209 {
210 return a == b.get(); 210 return a == b.get();
211 } 211 }
212 212
213 template<typename T, typename U> 213 template<typename T, typename U>
214 inline bool operator!=(const T* a, intrusive_ptr<U> const& b) 214 inline bool operator!=(const T* a, intrusive_ptr<U> const& b)
215 { 215 {
216 return a != b.get(); 216 return a != b.get();
217 } 217 }
OLDNEW
« no previous file with comments | « compiled/filter/Filter.cpp ('k') | compiled/subscription/Subscription.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld