| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/paint/DisplayItemClient.h" | 5 #include "platform/graphics/paint/DisplayItemClient.h" |
| 6 | 6 |
| 7 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 7 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 8 #include "wtf/HashMap.h" | 8 #include "wtf/HashMap.h" |
| 9 #include "wtf/HashSet.h" | 9 #include "wtf/HashSet.h" |
| 10 #endif | 10 #endif |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 DisplayItemClient::~DisplayItemClient() | 32 DisplayItemClient::~DisplayItemClient() |
| 33 { | 33 { |
| 34 if (displayItemClientsShouldKeepAlive) { | 34 if (displayItemClientsShouldKeepAlive) { |
| 35 for (auto& item : *displayItemClientsShouldKeepAlive) { | 35 for (auto& item : *displayItemClientsShouldKeepAlive) { |
| 36 CHECK(!item.value.contains(this)) | 36 CHECK(!item.value.contains(this)) |
| 37 << "Short-lived DisplayItemClient: " << item.value.get(this) | 37 << "Short-lived DisplayItemClient: " << item.value.get(this) |
| 38 << ". See crbug.com/570030."; | 38 << ". See crbug.com/570030."; |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 liveDisplayItemClients->remove(this); | 41 liveDisplayItemClients->remove(this); |
| 42 // In case this object is a subsequence owner. |
| 43 endShouldKeepAliveAllClients(this); |
| 42 } | 44 } |
| 43 | 45 |
| 44 bool DisplayItemClient::isAlive() const | 46 bool DisplayItemClient::isAlive() const |
| 45 { | 47 { |
| 46 return liveDisplayItemClients && liveDisplayItemClients->contains(this); | 48 return liveDisplayItemClients && liveDisplayItemClients->contains(this); |
| 47 } | 49 } |
| 48 | 50 |
| 49 void DisplayItemClient::beginShouldKeepAlive(const void* paintController) const | 51 void DisplayItemClient::beginShouldKeepAlive(const void* owner) const |
| 50 { | 52 { |
| 51 CHECK(isAlive()); | 53 CHECK(isAlive()); |
| 52 if (!displayItemClientsShouldKeepAlive) | 54 if (!displayItemClientsShouldKeepAlive) |
| 53 displayItemClientsShouldKeepAlive = new HashMap<const void*, HashMap<con
st DisplayItemClient*, String>>(); | 55 displayItemClientsShouldKeepAlive = new HashMap<const void*, HashMap<con
st DisplayItemClient*, String>>(); |
| 54 auto addResult = displayItemClientsShouldKeepAlive->add(paintController, Has
hMap<const DisplayItemClient*, String>()).storedValue->value.add(this, ""); | 56 auto addResult = displayItemClientsShouldKeepAlive->add(owner, HashMap<const
DisplayItemClient*, String>()).storedValue->value.add(this, ""); |
| 55 if (addResult.isNewEntry) | 57 if (addResult.isNewEntry) |
| 56 addResult.storedValue->value = debugName(); | 58 addResult.storedValue->value = debugName(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 void DisplayItemClient::endShouldKeepAliveAllClients(const void* paintController
) | 61 void DisplayItemClient::endShouldKeepAliveAllClients(const void* owner) |
| 60 { | 62 { |
| 61 if (displayItemClientsShouldKeepAlive) | 63 if (displayItemClientsShouldKeepAlive) |
| 62 displayItemClientsShouldKeepAlive->remove(paintController); | 64 displayItemClientsShouldKeepAlive->remove(owner); |
| 63 } | 65 } |
| 64 | 66 |
| 65 void DisplayItemClient::endShouldKeepAliveAllClients() | 67 void DisplayItemClient::endShouldKeepAliveAllClients() |
| 66 { | 68 { |
| 67 delete displayItemClientsShouldKeepAlive; | 69 delete displayItemClientsShouldKeepAlive; |
| 68 displayItemClientsShouldKeepAlive = nullptr; | 70 displayItemClientsShouldKeepAlive = nullptr; |
| 69 } | 71 } |
| 70 | 72 |
| 71 #endif // CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 73 #endif // CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 72 | 74 |
| 73 } // namespace blink | 75 } // namespace blink |
| OLD | NEW |