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

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

Issue 2453813004: WebFonts cache-aware timeout adaptation (Closed)
Patch Set: unit test, rebase, grammar Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef MockResourceClients_h 31 #ifndef MockResourceClients_h
32 #define MockResourceClients_h 32 #define MockResourceClients_h
33 33
34 #include "core/fetch/FontResource.h"
34 #include "core/fetch/ImageResourceObserver.h" 35 #include "core/fetch/ImageResourceObserver.h"
35 #include "core/fetch/Resource.h" 36 #include "core/fetch/Resource.h"
36 #include "core/fetch/ResourceClient.h" 37 #include "core/fetch/ResourceClient.h"
37 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 class MockResourceClient : public GarbageCollectedFinalized<MockResourceClient>, 42 class MockResourceClient : public GarbageCollectedFinalized<MockResourceClient>,
42 public ResourceClient { 43 public ResourceClient {
43 USING_PRE_FINALIZER(MockResourceClient, dispose); 44 USING_PRE_FINALIZER(MockResourceClient, dispose);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return m_encodedSizeOnImageNotifyFinished; 92 return m_encodedSizeOnImageNotifyFinished;
92 } 93 }
93 94
94 private: 95 private:
95 int m_imageChangedCount; 96 int m_imageChangedCount;
96 size_t m_encodedSizeOnLastImageChanged; 97 size_t m_encodedSizeOnLastImageChanged;
97 int m_imageNotifyFinishedCount; 98 int m_imageNotifyFinishedCount;
98 size_t m_encodedSizeOnImageNotifyFinished; 99 size_t m_encodedSizeOnImageNotifyFinished;
99 }; 100 };
100 101
102 class MockFontResourceClient final
103 : public GarbageCollectedFinalized<MockFontResourceClient>,
104 public FontResourceClient {
105 USING_PRE_FINALIZER(MockFontResourceClient, dispose);
106 USING_GARBAGE_COLLECTED_MIXIN(MockFontResourceClient);
107
108 public:
109 explicit MockFontResourceClient(Resource*);
110 ~MockFontResourceClient() override;
111
112 void fontLoadShortLimitExceeded(FontResource*) override;
113 void fontLoadLongLimitExceeded(FontResource*) override;
114
115 bool fontLoadShortLimitExceededCalled() const {
116 return m_fontLoadShortLimitExceededCalled;
117 }
118
119 bool fontLoadLongLimitExceededCalled() const {
120 return m_fontLoadLongLimitExceededCalled;
121 }
122
123 void removeAsClient();
yhirano 2016/11/09 07:29:52 The only caller is dispose(). Can you remove this
Shao-Chuan Lee 2016/11/09 08:04:31 Done.
124 void dispose();
yhirano 2016/11/09 07:29:52 Can this function be private?
Shao-Chuan Lee 2016/11/09 08:04:31 Done. Didn't notice pre-finalizers can be private.
125
126 DEFINE_INLINE_TRACE() {
127 visitor->trace(m_resource);
128 FontResourceClient::trace(visitor);
129 }
130
131 String debugName() const override { return "MockFontResourceClient"; }
132
133 protected:
yhirano 2016/11/09 07:29:52 private
Shao-Chuan Lee 2016/11/09 08:04:31 Done.
134 Member<Resource> m_resource;
135 bool m_fontLoadShortLimitExceededCalled;
136 bool m_fontLoadLongLimitExceededCalled;
137 };
138
101 } // namespace blink 139 } // namespace blink
102 140
103 #endif // MockResourceClients_h 141 #endif // MockResourceClients_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698