| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/fetch/MockResourceClient.h" | 5 #include "platform/loader/fetch/MockResourceClient.h" |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | 6 |
| 9 namespace blink { | 7 namespace blink { |
| 10 | 8 |
| 11 MockResourceClient::MockResourceClient(Resource* resource) | 9 MockResourceClient::MockResourceClient(Resource* resource) |
| 12 : m_resource(resource), | 10 : m_resource(resource), |
| 13 m_notifyFinishedCalled(false), | 11 m_notifyFinishedCalled(false), |
| 14 m_encodedSizeOnNotifyFinished(0) { | 12 m_encodedSizeOnNotifyFinished(0) { |
| 15 m_resource->addClient(this); | 13 m_resource->addClient(this); |
| 16 } | 14 } |
| 17 | 15 |
| 18 MockResourceClient::~MockResourceClient() {} | 16 MockResourceClient::~MockResourceClient() {} |
| 19 | 17 |
| 20 void MockResourceClient::notifyFinished(Resource* resource) { | 18 void MockResourceClient::notifyFinished(Resource* resource) { |
| 21 ASSERT_FALSE(m_notifyFinishedCalled); | 19 CHECK(!m_notifyFinishedCalled); |
| 22 m_notifyFinishedCalled = true; | 20 m_notifyFinishedCalled = true; |
| 23 m_encodedSizeOnNotifyFinished = resource->encodedSize(); | 21 m_encodedSizeOnNotifyFinished = resource->encodedSize(); |
| 24 } | 22 } |
| 25 | 23 |
| 26 void MockResourceClient::removeAsClient() { | 24 void MockResourceClient::removeAsClient() { |
| 27 m_resource->removeClient(this); | 25 m_resource->removeClient(this); |
| 28 m_resource = nullptr; | 26 m_resource = nullptr; |
| 29 } | 27 } |
| 30 | 28 |
| 31 void MockResourceClient::dispose() { | 29 void MockResourceClient::dispose() { |
| 32 if (m_resource) { | 30 if (m_resource) { |
| 33 m_resource->removeClient(this); | 31 m_resource->removeClient(this); |
| 34 m_resource = nullptr; | 32 m_resource = nullptr; |
| 35 } | 33 } |
| 36 } | 34 } |
| 37 | 35 |
| 38 DEFINE_TRACE(MockResourceClient) { | 36 DEFINE_TRACE(MockResourceClient) { |
| 39 visitor->trace(m_resource); | 37 visitor->trace(m_resource); |
| 40 ResourceClient::trace(visitor); | 38 ResourceClient::trace(visitor); |
| 41 } | 39 } |
| 42 | 40 |
| 43 } // namespace blink | 41 } // namespace blink |
| OLD | NEW |