| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/timing/ConsoleMemory.h" | 6 #include "core/timing/ConsoleMemory.h" |
| 7 | 7 |
| 8 #include "core/frame/Console.h" | 8 #include "core/frame/Console.h" |
| 9 #include "core/timing/MemoryInfo.h" | 9 #include "core/timing/MemoryInfo.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 DEFINE_TRACE(ConsoleMemory) | |
| 14 { | |
| 15 visitor->trace(m_memory); | |
| 16 HeapSupplement<Console>::trace(visitor); | |
| 17 } | |
| 18 | |
| 19 // static | 13 // static |
| 20 ConsoleMemory& ConsoleMemory::from(Console& console) | 14 ConsoleMemory& ConsoleMemory::from(Console& console) |
| 21 { | 15 { |
| 22 ConsoleMemory* supplement = static_cast<ConsoleMemory*>(HeapSupplement<Conso
le>::from(console, supplementName())); | 16 ConsoleMemory* supplement = static_cast<ConsoleMemory*>(HeapSupplement<Conso
le>::from(console, supplementName())); |
| 23 if (!supplement) { | 17 if (!supplement) { |
| 24 supplement = new ConsoleMemory(); | 18 supplement = new ConsoleMemory(); |
| 25 provideTo(console, supplementName(), supplement); | 19 provideTo(console, supplementName(), supplement); |
| 26 } | 20 } |
| 27 return *supplement; | 21 return *supplement; |
| 28 } | 22 } |
| 29 | 23 |
| 30 // static | 24 // static |
| 31 MemoryInfo* ConsoleMemory::memory(Console& console) | 25 MemoryInfo* ConsoleMemory::memory(Console& console) |
| 32 { | 26 { |
| 33 return ConsoleMemory::from(console).memory(); | 27 return ConsoleMemory::from(console).memory(); |
| 34 } | 28 } |
| 35 | 29 |
| 36 MemoryInfo* ConsoleMemory::memory() | 30 MemoryInfo* ConsoleMemory::memory() |
| 37 { | 31 { |
| 38 if (!m_memory) | 32 return MemoryInfo::create(); |
| 39 m_memory = MemoryInfo::create(); | |
| 40 | |
| 41 return m_memory.get(); | |
| 42 } | 33 } |
| 43 | 34 |
| 44 } // namespace blink | 35 } // namespace blink |
| OLD | NEW |