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

Side by Side Diff: third_party/WebKit/Source/platform/heap/Handle.h

Issue 1573283004: Oilpan: provide a weak 'this' pointer abstraction for cancellable closures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.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 * 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 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 { 1293 {
1294 ASSERT(!m_keepAlive || m_keepAlive.get() == self); 1294 ASSERT(!m_keepAlive || m_keepAlive.get() == self);
1295 m_keepAlive = self; 1295 m_keepAlive = self;
1296 } 1296 }
1297 1297
1298 GC_PLUGIN_IGNORE("420515") 1298 GC_PLUGIN_IGNORE("420515")
1299 Persistent<Self> m_keepAlive; 1299 Persistent<Self> m_keepAlive;
1300 }; 1300 };
1301 1301
1302 template<typename T> 1302 template<typename T>
1303 class AllowCrossThreadWeakPersistent { 1303 class CrossThreadWeakPersistentThisPointer {
1304 STACK_ALLOCATED(); 1304 STACK_ALLOCATED();
1305 public: 1305 public:
1306 explicit AllowCrossThreadWeakPersistent(T* value) : m_value(value) { } 1306 explicit CrossThreadWeakPersistentThisPointer(T* value) : m_value(value) { }
1307 CrossThreadWeakPersistent<T> value() const { return m_value; } 1307 CrossThreadWeakPersistent<T> value() const { return m_value; }
1308 private: 1308 private:
1309 CrossThreadWeakPersistent<T> m_value; 1309 CrossThreadWeakPersistent<T> m_value;
1310 }; 1310 };
1311 1311
1312 // LEAK_SANITIZER_DISABLED_SCOPE: all allocations made in the current scope 1312 // LEAK_SANITIZER_DISABLED_SCOPE: all allocations made in the current scope
1313 // will be exempted from LSan consideration. 1313 // will be exempted from LSan consideration.
1314 // 1314 //
1315 // TODO(sof): move this to wtf/LeakAnnotations.h (LeakSanitizer.h?) once 1315 // TODO(sof): move this to wtf/LeakAnnotations.h (LeakSanitizer.h?) once
1316 // wtf/ can freely call upon Oilpan functionality. 1316 // wtf/ can freely call upon Oilpan functionality.
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa rbageCollectedType<T>::value> { 1562 struct ParamStorageTraits<T*> : public PointerParamStorageTraits<T*, blink::IsGa rbageCollectedType<T>::value> {
1563 static_assert(sizeof(T), "T must be fully defined"); 1563 static_assert(sizeof(T), "T must be fully defined");
1564 }; 1564 };
1565 1565
1566 template<typename T> 1566 template<typename T>
1567 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> { 1567 struct ParamStorageTraits<RawPtr<T>> : public PointerParamStorageTraits<T*, blin k::IsGarbageCollectedType<T>::value> {
1568 static_assert(sizeof(T), "T must be fully defined"); 1568 static_assert(sizeof(T), "T must be fully defined");
1569 }; 1569 };
1570 1570
1571 template<typename T> 1571 template<typename T>
1572 struct ParamStorageTraits<blink::AllowCrossThreadWeakPersistent<T>> { 1572 struct ParamStorageTraits<blink::CrossThreadWeakPersistentThisPointer<T>> {
haraken 2016/01/12 00:04:57 CrossThreadWeakPersistentThisPointer => WeakPersis
sof 2016/01/12 07:23:40 That name promises a little bit more than I want i
1573 static_assert(sizeof(T), "T must be fully defined"); 1573 static_assert(sizeof(T), "T must be fully defined");
1574 using StorageType = blink::CrossThreadWeakPersistent<T>; 1574 using StorageType = blink::CrossThreadWeakPersistent<T>;
1575 1575
1576 static StorageType wrap(const blink::AllowCrossThreadWeakPersistent<T>& valu e) { return value.value(); } 1576 static StorageType wrap(const blink::CrossThreadWeakPersistentThisPointer<T> & value) { return value.value(); }
1577 1577
1578 // Currently assume that the call sites of this unwrap() account for cleared weak references also. 1578 // WTF::FunctionWrapper<> handles WeakPtr<>, so recast this weak persistent
1579 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent. 1579 // into it.
1580 static T* unwrap(const StorageType& value) { return value.get(); } 1580 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR eference<T>::create(value.get())); }
1581 }; 1581 };
1582 1582
1583 template<typename T> 1583 template<typename T>
1584 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; 1584 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete;
1585 1585
1586 } // namespace WTF 1586 } // namespace WTF
1587 1587
1588 #endif 1588 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/CancellableTaskFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698