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

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

Issue 2550373005: Make WebTaskRunner ThreadSafeRefCounted (Closed)
Patch Set: mac fix 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 /* 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 bool canRequest(Resource::Type, 174 bool canRequest(Resource::Type,
175 const ResourceRequest&, 175 const ResourceRequest&,
176 const KURL&, 176 const KURL&,
177 const ResourceLoaderOptions&, 177 const ResourceLoaderOptions&,
178 bool forPreload, 178 bool forPreload,
179 FetchRequest::OriginRestriction) const override { 179 FetchRequest::OriginRestriction) const override {
180 return true; 180 return true;
181 } 181 }
182 bool shouldLoadNewResource(Resource::Type) const override { return true; } 182 bool shouldLoadNewResource(Resource::Type) const override { return true; }
183 WebTaskRunner* loadingTaskRunner() const override { return m_runner.get(); } 183 RefPtr<WebTaskRunner> loadingTaskRunner() const override { return m_runner; }
184 184
185 private: 185 private:
186 ImageResourceTestMockFetchContext() 186 ImageResourceTestMockFetchContext()
187 : m_runner(wrapUnique(new scheduler::FakeWebTaskRunner)) {} 187 : m_runner(adoptRef(new scheduler::FakeWebTaskRunner)) {}
188 188
189 std::unique_ptr<scheduler::FakeWebTaskRunner> m_runner; 189 RefPtr<scheduler::FakeWebTaskRunner> m_runner;
190 }; 190 };
191 191
192 // Convenience class that registers a mocked URL load on construction, and 192 // Convenience class that registers a mocked URL load on construction, and
193 // unregisters it on destruction. This allows for a test to use constructs like 193 // unregisters it on destruction. This allows for a test to use constructs like
194 // ASSERT_TRUE() without needing to worry about unregistering the mocked URL 194 // ASSERT_TRUE() without needing to worry about unregistering the mocked URL
195 // load to avoid putting other tests into inconsistent states in case the 195 // load to avoid putting other tests into inconsistent states in case the
196 // assertion fails. 196 // assertion fails.
197 class ScopedRegisteredURL { 197 class ScopedRegisteredURL {
198 public: 198 public:
199 ScopedRegisteredURL(const KURL& url, 199 ScopedRegisteredURL(const KURL& url,
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 EXPECT_TRUE(client->notifyFinishedCalled()); 1212 EXPECT_TRUE(client->notifyFinishedCalled());
1213 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage()); 1213 EXPECT_TRUE(cachedImage->getImage()->isBitmapImage());
1214 EXPECT_EQ(50, cachedImage->getImage()->width()); 1214 EXPECT_EQ(50, cachedImage->getImage()->width());
1215 EXPECT_EQ(50, cachedImage->getImage()->height()); 1215 EXPECT_EQ(50, cachedImage->getImage()->height());
1216 1216
1217 WTF::setTimeFunctionsForTesting(nullptr); 1217 WTF::setTimeFunctionsForTesting(nullptr);
1218 } 1218 }
1219 1219
1220 } // namespace 1220 } // namespace
1221 } // namespace blink 1221 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698