Index: Source/core/timing/ConsoleMemory.cpp |
diff --git a/Source/core/timing/ConsoleMemory.cpp b/Source/core/timing/ConsoleMemory.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9659b125d1fc30c225989dceb3088874a7d0cffe |
--- /dev/null |
+++ b/Source/core/timing/ConsoleMemory.cpp |
@@ -0,0 +1,51 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/timing/ConsoleMemory.h" |
+ |
+#include "core/frame/Console.h" |
+#include "core/timing/MemoryInfo.h" |
+ |
+namespace blink { |
+ |
+DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ConsoleMemory); |
+ |
+DEFINE_TRACE(ConsoleMemory) |
+{ |
+ visitor->trace(m_memory); |
+ WillBeHeapSupplement<Console>::trace(visitor); |
+} |
+ |
+const char* ConsoleMemory::supplementName() |
dsinclair
2015/02/24 16:18:43
If left here, should this have a // static to be c
|
+{ |
+ return "ConsoleMemory"; |
dsinclair
2015/02/24 16:18:43
Any reason to not put this in the header?
|
+} |
+ |
+// static |
+ConsoleMemory& ConsoleMemory::from(Console& console) |
+{ |
+ ConsoleMemory* supplement = static_cast<ConsoleMemory*>(WillBeHeapSupplement<Console>::from(console, supplementName())); |
+ if (!supplement) { |
+ supplement = new ConsoleMemory(); |
+ provideTo(console, supplementName(), adoptPtrWillBeNoop(supplement)); |
+ } |
+ return *supplement; |
+} |
+ |
+// static |
+MemoryInfo* ConsoleMemory::memory(Console& console) |
+{ |
+ return ConsoleMemory::from(console).memory(); |
+} |
+ |
+MemoryInfo* ConsoleMemory::memory() |
+{ |
+ if (!m_memory) |
+ m_memory = MemoryInfo::create(); |
+ |
+ return m_memory.get(); |
+} |
+ |
+} // namespace blink |