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

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

Issue 2469873002: [ImageResource 4] Split ImageResource into Resource and Image parts (Closed)
Patch Set: style 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 "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 namespace blink { 11 namespace blink {
11 12
12 MockResourceClient::MockResourceClient(Resource* resource) 13 MockResourceClient::MockResourceClient(Resource* resource)
13 : m_resource(resource), 14 : m_resource(resource),
14 m_notifyFinishedCalled(false), 15 m_notifyFinishedCalled(false),
15 m_encodedSizeOnNotifyFinished(0) { 16 m_encodedSizeOnNotifyFinished(0) {
16 ThreadState::current()->registerPreFinalizer(this); 17 ThreadState::current()->registerPreFinalizer(this);
17 m_resource->addClient(this); 18 m_resource->addClient(this);
(...skipping 23 matching lines...) Expand all
41 visitor->trace(m_resource); 42 visitor->trace(m_resource);
42 ResourceClient::trace(visitor); 43 ResourceClient::trace(visitor);
43 } 44 }
44 45
45 MockImageResourceClient::MockImageResourceClient(ImageResource* resource) 46 MockImageResourceClient::MockImageResourceClient(ImageResource* resource)
46 : MockResourceClient(resource), 47 : MockResourceClient(resource),
47 m_imageChangedCount(0), 48 m_imageChangedCount(0),
48 m_encodedSizeOnLastImageChanged(0), 49 m_encodedSizeOnLastImageChanged(0),
49 m_imageNotifyFinishedCount(0), 50 m_imageNotifyFinishedCount(0),
50 m_encodedSizeOnImageNotifyFinished(0) { 51 m_encodedSizeOnImageNotifyFinished(0) {
51 toImageResource(m_resource.get())->addObserver(this); 52 toImageResource(m_resource)->getContent()->addObserver(this);
52 } 53 }
53 54
54 MockImageResourceClient::~MockImageResourceClient() {} 55 MockImageResourceClient::~MockImageResourceClient() {}
55 56
56 void MockImageResourceClient::removeAsClient() { 57 void MockImageResourceClient::removeAsClient() {
57 toImageResource(m_resource.get())->removeObserver(this); 58 toImageResource(m_resource)->getContent()->removeObserver(this);
58 MockResourceClient::removeAsClient(); 59 MockResourceClient::removeAsClient();
59 } 60 }
60 61
61 void MockImageResourceClient::dispose() { 62 void MockImageResourceClient::dispose() {
62 if (m_resource) 63 if (m_resource)
63 toImageResource(m_resource.get())->removeObserver(this); 64 toImageResource(m_resource)->getContent()->removeObserver(this);
64 MockResourceClient::dispose(); 65 MockResourceClient::dispose();
65 } 66 }
66 67
67 void MockImageResourceClient::imageChanged(ImageResource* image, 68 void MockImageResourceClient::imageChanged(ImageResourceContent* image,
68 const IntRect*) { 69 const IntRect*) {
69 m_imageChangedCount++; 70 m_imageChangedCount++;
70 m_encodedSizeOnLastImageChanged = image->encodedSize(); 71 m_encodedSizeOnLastImageChanged = m_resource->encodedSize();
71 } 72 }
72 73
73 void MockImageResourceClient::imageNotifyFinished(ImageResource* image) { 74 void MockImageResourceClient::imageNotifyFinished(ImageResourceContent* image) {
74 ASSERT_EQ(0, m_imageNotifyFinishedCount); 75 ASSERT_EQ(0, m_imageNotifyFinishedCount);
75 m_imageNotifyFinishedCount++; 76 m_imageNotifyFinishedCount++;
76 m_encodedSizeOnImageNotifyFinished = image->encodedSize(); 77 m_encodedSizeOnImageNotifyFinished = m_resource->encodedSize();
77 } 78 }
78 79
79 bool MockImageResourceClient::notifyFinishedCalled() const { 80 bool MockImageResourceClient::notifyFinishedCalled() const {
80 return m_notifyFinishedCalled; 81 return m_notifyFinishedCalled;
81 } 82 }
82 83
83 } // namespace blink 84 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MockResourceClients.h ('k') | third_party/WebKit/Source/core/frame/FrameSerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698