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

Unified Diff: Source/core/fetch/MockImageResourceClient.cpp

Issue 1327653004: Have uses of MockImageResourceClient leak less. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Clean up MockImageResourceClient somewhat Created 5 years, 3 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
« no previous file with comments | « Source/core/fetch/MockImageResourceClient.h ('k') | Source/core/fetch/RawResourceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/MockImageResourceClient.cpp
diff --git a/Source/core/fetch/MockImageResourceClient.cpp b/Source/core/fetch/MockImageResourceClient.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6c15a45a5d8e0d3ffd350d7e1856d51b0dc0e410
--- /dev/null
+++ b/Source/core/fetch/MockImageResourceClient.cpp
@@ -0,0 +1,41 @@
+// 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/fetch/MockImageResourceClient.h"
+
+#include "core/fetch/ImageResource.h"
+#include "core/fetch/ResourcePtr.h"
+
+#include <gtest/gtest.h>
+
+namespace blink {
+
+MockImageResourceClient::MockImageResourceClient(const ResourcePtr<Resource>& resource)
+ : m_resource(resource.get())
+ , m_imageChangedCount(0)
+ , m_notifyFinishedCalled(false)
+{
+ m_resource->addClient(this);
+}
+
+MockImageResourceClient::~MockImageResourceClient()
+{
+ if (m_resource)
+ m_resource->removeClient(this);
+}
+
+void MockImageResourceClient::notifyFinished(Resource*)
+{
+ ASSERT_FALSE(m_notifyFinishedCalled);
+ m_notifyFinishedCalled = true;
+}
+
+void MockImageResourceClient::removeAsClient()
+{
+ m_resource->removeClient(this);
+ m_resource = nullptr;
+}
+
+} // namespace blink
« no previous file with comments | « Source/core/fetch/MockImageResourceClient.h ('k') | Source/core/fetch/RawResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698