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

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

Issue 2559703002: Loading: split MockResourceClients into multiple files type by type (Closed)
Patch Set: [rebase to trunk] 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 2016 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/MockImageResourceClient.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
11 namespace blink { 11 namespace blink {
12 12
13 MockResourceClient::MockResourceClient(Resource* resource)
14 : m_resource(resource),
15 m_notifyFinishedCalled(false),
16 m_encodedSizeOnNotifyFinished(0) {
17 ThreadState::current()->registerPreFinalizer(this);
18 m_resource->addClient(this);
19 }
20
21 MockResourceClient::~MockResourceClient() {}
22
23 void MockResourceClient::notifyFinished(Resource* resource) {
24 ASSERT_FALSE(m_notifyFinishedCalled);
25 m_notifyFinishedCalled = true;
26 m_encodedSizeOnNotifyFinished = resource->encodedSize();
27 }
28
29 void MockResourceClient::removeAsClient() {
30 m_resource->removeClient(this);
31 m_resource = nullptr;
32 }
33
34 void MockResourceClient::dispose() {
35 if (m_resource) {
36 m_resource->removeClient(this);
37 m_resource = nullptr;
38 }
39 }
40
41 DEFINE_TRACE(MockResourceClient) {
42 visitor->trace(m_resource);
43 ResourceClient::trace(visitor);
44 }
45
46 MockImageResourceClient::MockImageResourceClient(ImageResource* resource) 13 MockImageResourceClient::MockImageResourceClient(ImageResource* resource)
47 : MockResourceClient(resource), 14 : MockResourceClient(resource),
48 m_imageChangedCount(0), 15 m_imageChangedCount(0),
49 m_encodedSizeOnLastImageChanged(0), 16 m_encodedSizeOnLastImageChanged(0),
50 m_imageNotifyFinishedCount(0), 17 m_imageNotifyFinishedCount(0),
51 m_encodedSizeOnImageNotifyFinished(0) { 18 m_encodedSizeOnImageNotifyFinished(0) {
52 toImageResource(m_resource)->getContent()->addObserver(this); 19 toImageResource(m_resource)->getContent()->addObserver(this);
53 } 20 }
54 21
55 MockImageResourceClient::~MockImageResourceClient() {} 22 MockImageResourceClient::~MockImageResourceClient() {}
(...skipping 19 matching lines...) Expand all
75 ASSERT_EQ(0, m_imageNotifyFinishedCount); 42 ASSERT_EQ(0, m_imageNotifyFinishedCount);
76 m_imageNotifyFinishedCount++; 43 m_imageNotifyFinishedCount++;
77 m_encodedSizeOnImageNotifyFinished = m_resource->encodedSize(); 44 m_encodedSizeOnImageNotifyFinished = m_resource->encodedSize();
78 } 45 }
79 46
80 bool MockImageResourceClient::notifyFinishedCalled() const { 47 bool MockImageResourceClient::notifyFinishedCalled() const {
81 return m_notifyFinishedCalled; 48 return m_notifyFinishedCalled;
82 } 49 }
83 50
84 } // namespace blink 51 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698