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

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

Issue 14698008: Remove RetainPtrObjectHash and RetainPtrObjectHashTraits (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 | « no previous file | 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) 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library 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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 template<typename P> struct HashTraits<RetainPtr<P> > : SimpleClassHashTrait s<RetainPtr<P> > { }; 287 template<typename P> struct HashTraits<RetainPtr<P> > : SimpleClassHashTrait s<RetainPtr<P> > { };
288 288
289 template<typename P> struct PtrHash<RetainPtr<P> > : PtrHash<typename Retain Ptr<P>::PtrType> { 289 template<typename P> struct PtrHash<RetainPtr<P> > : PtrHash<typename Retain Ptr<P>::PtrType> {
290 using PtrHash<typename RetainPtr<P>::PtrType>::hash; 290 using PtrHash<typename RetainPtr<P>::PtrType>::hash;
291 static unsigned hash(const RetainPtr<P>& key) { return hash(key.get()); } 291 static unsigned hash(const RetainPtr<P>& key) { return hash(key.get()); }
292 using PtrHash<typename RetainPtr<P>::PtrType>::equal; 292 using PtrHash<typename RetainPtr<P>::PtrType>::equal;
293 static bool equal(const RetainPtr<P>& a, const RetainPtr<P>& b) { return a == b; } 293 static bool equal(const RetainPtr<P>& a, const RetainPtr<P>& b) { return a == b; }
294 static bool equal(typename RetainPtr<P>::PtrType a, const RetainPtr<P>& b) { return a == b; } 294 static bool equal(typename RetainPtr<P>::PtrType a, const RetainPtr<P>& b) { return a == b; }
295 static bool equal(const RetainPtr<P>& a, typename RetainPtr<P>::PtrType b) { return a == b; } 295 static bool equal(const RetainPtr<P>& a, typename RetainPtr<P>::PtrType b) { return a == b; }
296 }; 296 };
297 297
298 template<typename P> struct DefaultHash<RetainPtr<P> > { typedef PtrHash<Ret ainPtr<P> > Hash; }; 298 template<typename P> struct DefaultHash<RetainPtr<P> > { typedef PtrHash<Ret ainPtr<P> > Hash; };
299
300 template <typename P>
301 struct RetainPtrObjectHashTraits : GenericHashTraits<RetainPtr<P> > {
302 static const bool emptyValueIsZero = true;
303 static const RetainPtr<P>& emptyValue()
304 {
305 static RetainPtr<P>& null = *(new RetainPtr<P>);
306 return null;
307 }
308 static const bool needsDestruction = true;
309 static void constructDeletedValue(RetainPtr<P>& slot) { new (&slot) Reta inPtr<P>(HashTableDeletedValue); }
310 static bool isDeletedValue(const RetainPtr<P>& value) { return value.isH ashTableDeletedValue(); }
311 };
312
313 template <typename P>
314 struct RetainPtrObjectHash {
315 static unsigned hash(const RetainPtr<P>& o)
316 {
317 ASSERT_WITH_MESSAGE(o.get(), "attempt to use null RetainPtr in HashT able");
318 return CFHash(o.get());
319 }
320 static bool equal(const RetainPtr<P>& a, const RetainPtr<P>& b)
321 {
322 return CFEqual(a.get(), b.get());
323 }
324 static const bool safeToCompareToEmptyOrDeleted = false;
325 };
326 } // namespace WTF 299 } // namespace WTF
327 300
328 using WTF::AdoptCF; 301 using WTF::AdoptCF;
329 using WTF::AdoptNS; 302 using WTF::AdoptNS;
330 using WTF::adoptCF; 303 using WTF::adoptCF;
331 using WTF::adoptNS; 304 using WTF::adoptNS;
332 using WTF::RetainPtr; 305 using WTF::RetainPtr;
333 using WTF::retainPtr; 306 using WTF::retainPtr;
334 307
335 #endif // WTF_RetainPtr_h 308 #endif // WTF_RetainPtr_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698