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

Side by Side Diff: third_party/WebKit/Source/core/fetch/MockResourceClients.cpp

Issue 2527353002: Phase II Step 3: Reload LoFi/placeholder images via new ImageResource
Patch Set: tests Created 4 years 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 unified diff | Download patch
OLDNEW
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/MockResourceClients.h" 5 #include "core/fetch/MockResourceClients.h"
6 6
7 #include "core/fetch/ImageResource.h" 7 #include "core/fetch/ImageResource.h"
8 #include "core/fetch/ImageResourceContent.h" 8 #include "core/fetch/ImageResourceContent.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 30 matching lines...) Expand all
41 DEFINE_TRACE(MockResourceClient) { 41 DEFINE_TRACE(MockResourceClient) {
42 visitor->trace(m_resource); 42 visitor->trace(m_resource);
43 ResourceClient::trace(visitor); 43 ResourceClient::trace(visitor);
44 } 44 }
45 45
46 MockImageResourceClient::MockImageResourceClient(ImageResource* resource) 46 MockImageResourceClient::MockImageResourceClient(ImageResource* resource)
47 : MockResourceClient(resource), 47 : MockResourceClient(resource),
48 m_imageChangedCount(0), 48 m_imageChangedCount(0),
49 m_encodedSizeOnLastImageChanged(0), 49 m_encodedSizeOnLastImageChanged(0),
50 m_imageNotifyFinishedCount(0), 50 m_imageNotifyFinishedCount(0),
51 m_encodedSizeOnImageNotifyFinished(0) { 51 m_encodedSizeOnImageNotifyFinished(0),
52 toImageResource(m_resource)->getContent()->addObserver(this); 52 m_content(resource->getContent()) {
53 m_content->addObserver(this);
53 } 54 }
54 55
55 MockImageResourceClient::~MockImageResourceClient() {} 56 MockImageResourceClient::~MockImageResourceClient() {}
56 57
57 void MockImageResourceClient::removeAsClient() { 58 void MockImageResourceClient::removeAsClientAndObserver() {
58 toImageResource(m_resource)->getContent()->removeObserver(this); 59 m_content->removeObserver(this);
59 MockResourceClient::removeAsClient(); 60 MockResourceClient::removeAsClient();
60 } 61 }
61 62
62 void MockImageResourceClient::dispose() { 63 void MockImageResourceClient::dispose() {
63 if (m_resource) 64 if (m_content)
64 toImageResource(m_resource)->getContent()->removeObserver(this); 65 m_content->removeObserver(this);
65 MockResourceClient::dispose(); 66 MockResourceClient::dispose();
66 } 67 }
67 68
68 void MockImageResourceClient::imageChanged(ImageResourceContent* image, 69 void MockImageResourceClient::imageChanged(ImageResourceContent* image,
69 const IntRect*) { 70 const IntRect*) {
70 m_imageChangedCount++; 71 m_imageChangedCount++;
71 m_encodedSizeOnLastImageChanged = m_resource->encodedSize(); 72 m_encodedSizeOnLastImageChanged = m_content->resourceForTest()->encodedSize();
72 } 73 }
73 74
74 void MockImageResourceClient::imageNotifyFinished(ImageResourceContent* image) { 75 void MockImageResourceClient::imageNotifyFinished(ImageResourceContent* image) {
75 ASSERT_EQ(0, m_imageNotifyFinishedCount); 76 ASSERT_EQ(0, m_imageNotifyFinishedCount);
76 m_imageNotifyFinishedCount++; 77 m_imageNotifyFinishedCount++;
77 m_encodedSizeOnImageNotifyFinished = m_resource->encodedSize(); 78 m_encodedSizeOnImageNotifyFinished =
79 m_content->resourceForTest()->encodedSize();
78 } 80 }
79 81
80 bool MockImageResourceClient::notifyFinishedCalled() const { 82 bool MockImageResourceClient::notifyFinishedCalled() const {
81 return m_notifyFinishedCalled; 83 return m_notifyFinishedCalled;
82 } 84 }
83 85
84 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698