| Index: third_party/WebKit/Source/core/fetch/MockResourceClient.cpp
|
| diff --git a/third_party/WebKit/Source/core/fetch/MockResourceClient.cpp b/third_party/WebKit/Source/core/fetch/MockResourceClient.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..0d956bc4558502fb9ee6c4b196a523009911ed38
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/core/fetch/MockResourceClient.cpp
|
| @@ -0,0 +1,44 @@
|
| +// 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 "core/fetch/MockResourceClient.h"
|
| +
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace blink {
|
| +
|
| +MockResourceClient::MockResourceClient(Resource* resource)
|
| + : m_resource(resource),
|
| + m_notifyFinishedCalled(false),
|
| + m_encodedSizeOnNotifyFinished(0) {
|
| + ThreadState::current()->registerPreFinalizer(this);
|
| + m_resource->addClient(this);
|
| +}
|
| +
|
| +MockResourceClient::~MockResourceClient() {}
|
| +
|
| +void MockResourceClient::notifyFinished(Resource* resource) {
|
| + ASSERT_FALSE(m_notifyFinishedCalled);
|
| + m_notifyFinishedCalled = true;
|
| + m_encodedSizeOnNotifyFinished = resource->encodedSize();
|
| +}
|
| +
|
| +void MockResourceClient::removeAsClient() {
|
| + m_resource->removeClient(this);
|
| + m_resource = nullptr;
|
| +}
|
| +
|
| +void MockResourceClient::dispose() {
|
| + if (m_resource) {
|
| + m_resource->removeClient(this);
|
| + m_resource = nullptr;
|
| + }
|
| +}
|
| +
|
| +DEFINE_TRACE(MockResourceClient) {
|
| + visitor->trace(m_resource);
|
| + ResourceClient::trace(visitor);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|