Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1944)

Unified Diff: Source/core/timing/ConsoleMemory.cpp

Issue 950343002: Decouple memory() from Console (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: wrapperinfo and idl fixes Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698