| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 bool DisplayItemClient::isAlive() const { | 47 bool DisplayItemClient::isAlive() const { |
| 48 return liveDisplayItemClients && liveDisplayItemClients->contains(this); | 48 return liveDisplayItemClients && liveDisplayItemClients->contains(this); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void DisplayItemClient::beginShouldKeepAlive(const void* owner) const { | 51 void DisplayItemClient::beginShouldKeepAlive(const void* owner) const { |
| 52 CHECK(isAlive()); | 52 CHECK(isAlive()); |
| 53 if (!displayItemClientsShouldKeepAlive) | 53 if (!displayItemClientsShouldKeepAlive) |
| 54 displayItemClientsShouldKeepAlive = | 54 displayItemClientsShouldKeepAlive = |
| 55 new HashMap<const void*, HashMap<const DisplayItemClient*, String>>(); | 55 new HashMap<const void*, HashMap<const DisplayItemClient*, String>>(); |
| 56 auto addResult = displayItemClientsShouldKeepAlive | 56 auto addResult = |
| 57 ->add(owner, HashMap<const DisplayItemClient*, String>()) | 57 displayItemClientsShouldKeepAlive |
| 58 .storedValue->value.add(this, ""); | 58 ->insert(owner, HashMap<const DisplayItemClient*, String>()) |
| 59 .storedValue->value.insert(this, ""); |
| 59 if (addResult.isNewEntry) | 60 if (addResult.isNewEntry) |
| 60 addResult.storedValue->value = debugName(); | 61 addResult.storedValue->value = debugName(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 void DisplayItemClient::endShouldKeepAlive() const { | 64 void DisplayItemClient::endShouldKeepAlive() const { |
| 64 if (displayItemClientsShouldKeepAlive) { | 65 if (displayItemClientsShouldKeepAlive) { |
| 65 for (auto& item : *displayItemClientsShouldKeepAlive) | 66 for (auto& item : *displayItemClientsShouldKeepAlive) |
| 66 item.value.erase(this); | 67 item.value.erase(this); |
| 67 } | 68 } |
| 68 } | 69 } |
| 69 | 70 |
| 70 void DisplayItemClient::endShouldKeepAliveAllClients(const void* owner) { | 71 void DisplayItemClient::endShouldKeepAliveAllClients(const void* owner) { |
| 71 if (displayItemClientsShouldKeepAlive) | 72 if (displayItemClientsShouldKeepAlive) |
| 72 displayItemClientsShouldKeepAlive->erase(owner); | 73 displayItemClientsShouldKeepAlive->erase(owner); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void DisplayItemClient::endShouldKeepAliveAllClients() { | 76 void DisplayItemClient::endShouldKeepAliveAllClients() { |
| 76 delete displayItemClientsShouldKeepAlive; | 77 delete displayItemClientsShouldKeepAlive; |
| 77 displayItemClientsShouldKeepAlive = nullptr; | 78 displayItemClientsShouldKeepAlive = nullptr; |
| 78 } | 79 } |
| 79 | 80 |
| 80 #endif // CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 81 #endif // CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
| 81 | 82 |
| 82 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |