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/MockImageResourceClient.h" | 5 #include "core/fetch/MockImageResourceClient.h" |
6 | 6 |
7 #include "core/fetch/ImageResource.h" | 7 #include "core/fetch/ImageResource.h" |
8 #include "core/fetch/ResourcePtr.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
10 | 9 |
11 namespace blink { | 10 namespace blink { |
12 | 11 |
13 MockImageResourceClient::MockImageResourceClient(const ResourcePtr<Resource>& re
source) | 12 MockImageResourceClient::MockImageResourceClient(PassRefPtrWillBeRawPtr<Resource
> resource) |
14 : m_resource(resource.get()) | 13 : m_resource(resource.get()) |
15 , m_imageChangedCount(0) | 14 , m_imageChangedCount(0) |
16 , m_notifyFinishedCalled(false) | 15 , m_notifyFinishedCalled(false) |
17 { | 16 { |
18 m_resource->addClient(this); | 17 m_resource->addClient(this); |
19 } | 18 } |
20 | 19 |
21 MockImageResourceClient::~MockImageResourceClient() | 20 MockImageResourceClient::~MockImageResourceClient() |
22 { | 21 { |
23 if (m_resource) | 22 if (m_resource) |
24 m_resource->removeClient(this); | 23 m_resource->removeClient(this); |
25 } | 24 } |
26 | 25 |
27 void MockImageResourceClient::notifyFinished(Resource*) | 26 void MockImageResourceClient::notifyFinished(Resource*) |
28 { | 27 { |
29 ASSERT_FALSE(m_notifyFinishedCalled); | 28 ASSERT_FALSE(m_notifyFinishedCalled); |
30 m_notifyFinishedCalled = true; | 29 m_notifyFinishedCalled = true; |
31 } | 30 } |
32 | 31 |
33 void MockImageResourceClient::removeAsClient() | 32 void MockImageResourceClient::removeAsClient() |
34 { | 33 { |
35 m_resource->removeClient(this); | 34 m_resource->removeClient(this); |
36 m_resource = nullptr; | 35 m_resource = nullptr; |
37 } | 36 } |
38 | 37 |
39 } // namespace blink | 38 } // namespace blink |
OLD | NEW |