Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "core/timing/ConsoleMemory.h" | |
| 7 | |
| 8 #include "core/frame/Console.h" | |
| 9 #include "core/timing/MemoryInfo.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ConsoleMemory); | |
| 14 | |
| 15 DEFINE_TRACE(ConsoleMemory) | |
| 16 { | |
| 17 visitor->trace(m_memory); | |
| 18 WillBeHeapSupplement<Console>::trace(visitor); | |
| 19 } | |
| 20 | |
| 21 // static | |
| 22 ConsoleMemory& ConsoleMemory::from(Console& console) | |
| 23 { | |
| 24 ConsoleMemory* supplement = static_cast<ConsoleMemory*>(WillBeHeapSupplement <Console>::from(console, supplementName())); | |
| 25 if (!supplement) { | |
| 26 supplement = new ConsoleMemory(); | |
| 27 provideTo(console, supplementName(), adoptPtrWillBeNoop(supplement)); | |
| 28 } | |
| 29 return *supplement; | |
| 30 } | |
| 31 | |
| 32 // static | |
| 33 MemoryInfo* ConsoleMemory::memory(Console& console) | |
| 34 { | |
| 35 return ConsoleMemory::from(console).memory(); | |
| 36 } | |
| 37 | |
| 38 MemoryInfo* ConsoleMemory::memory() | |
| 39 { | |
| 40 if (!m_memory) | |
| 41 m_memory = MemoryInfo::create(); | |
| 42 | |
| 43 return m_memory.get(); | |
|
sof
2015/07/13 14:02:48
Sharing MemoryInfo across accesses is subtly incor
| |
| 44 } | |
| 45 | |
| 46 } // namespace blink | |
| OLD | NEW |