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

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

Issue 2184263003: Move RawResourceClient to Oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@onheap-threadable-loader
Patch Set: rebase Created 4 years, 4 months 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo()); 232 FetchRequest fetchRequest = FetchRequest(url, FetchInitiatorInfo());
233 Resource* newResource = fetcher->requestResource(fetchRequest, TestResourceF actory(Resource::Image)); 233 Resource* newResource = fetcher->requestResource(fetchRequest, TestResourceF actory(Resource::Image));
234 EXPECT_EQ(resource, newResource); 234 EXPECT_EQ(resource, newResource);
235 235
236 memoryCache()->remove(newResource); 236 memoryCache()->remove(newResource);
237 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url); 237 Platform::current()->getURLLoaderMockFactory()->unregisterURL(url);
238 } 238 }
239 239
240 class RequestSameResourceOnComplete : public GarbageCollectedFinalized<RequestSa meResourceOnComplete>, public RawResourceClient { 240 class RequestSameResourceOnComplete : public GarbageCollectedFinalized<RequestSa meResourceOnComplete>, public RawResourceClient {
241 USING_GARBAGE_COLLECTED_MIXIN(RequestSameResourceOnComplete);
241 public: 242 public:
242 explicit RequestSameResourceOnComplete(Resource* resource) 243 explicit RequestSameResourceOnComplete(Resource* resource)
243 : m_resource(resource) 244 : m_resource(resource)
244 , m_notifyFinishedCalled(false) 245 , m_notifyFinishedCalled(false)
245 { 246 {
246 } 247 }
247 248
248 void notifyFinished(Resource* resource) override 249 void notifyFinished(Resource* resource) override
249 { 250 {
250 ASSERT_EQ(m_resource, resource); 251 ASSERT_EQ(m_resource, resource);
251 ResourceFetcherTestMockFetchContext* context = ResourceFetcherTestMockFe tchContext::create(); 252 ResourceFetcherTestMockFetchContext* context = ResourceFetcherTestMockFe tchContext::create();
252 context->setCachePolicy(CachePolicyRevalidate); 253 context->setCachePolicy(CachePolicyRevalidate);
253 ResourceFetcher* fetcher2 = ResourceFetcher::create(context); 254 ResourceFetcher* fetcher2 = ResourceFetcher::create(context);
254 FetchRequest fetchRequest2(m_resource->url(), FetchInitiatorInfo()); 255 FetchRequest fetchRequest2(m_resource->url(), FetchInitiatorInfo());
255 Resource* resource2 = fetcher2->requestResource(fetchRequest2, TestResou rceFactory(Resource::Image)); 256 Resource* resource2 = fetcher2->requestResource(fetchRequest2, TestResou rceFactory(Resource::Image));
256 EXPECT_EQ(m_resource, resource2); 257 EXPECT_EQ(m_resource, resource2);
257 m_notifyFinishedCalled = true; 258 m_notifyFinishedCalled = true;
258 } 259 }
259 bool notifyFinishedCalled() const { return m_notifyFinishedCalled; } 260 bool notifyFinishedCalled() const { return m_notifyFinishedCalled; }
260 261
261 DEFINE_INLINE_TRACE() 262 DEFINE_INLINE_TRACE()
262 { 263 {
263 visitor->trace(m_resource); 264 visitor->trace(m_resource);
265 RawResourceClient::trace(visitor);
264 } 266 }
265 267
266 String debugName() const override { return "RequestSameResourceOnComplete"; } 268 String debugName() const override { return "RequestSameResourceOnComplete"; }
267 269
268 private: 270 private:
269 Member<Resource> m_resource; 271 Member<Resource> m_resource;
270 bool m_notifyFinishedCalled; 272 bool m_notifyFinishedCalled;
271 }; 273 };
272 274
273 TEST_F(ResourceFetcherTest, RevalidateWhileFinishingLoading) 275 TEST_F(ResourceFetcherTest, RevalidateWhileFinishingLoading)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 ResourceLoaderOptions options; 358 ResourceLoaderOptions options;
357 options.dataBufferingPolicy = DoNotBufferData; 359 options.dataBufferingPolicy = DoNotBufferData;
358 FetchRequest fetchRequest = FetchRequest(request, FetchInitiatorTypeNames::i nternal, options); 360 FetchRequest fetchRequest = FetchRequest(request, FetchInitiatorTypeNames::i nternal, options);
359 Resource* resource1 = fetcher->requestResource(fetchRequest, TestResourceFac tory(Resource::Media)); 361 Resource* resource1 = fetcher->requestResource(fetchRequest, TestResourceFac tory(Resource::Media));
360 Resource* resource2 = fetcher->requestResource(fetchRequest, TestResourceFac tory(Resource::Media)); 362 Resource* resource2 = fetcher->requestResource(fetchRequest, TestResourceFac tory(Resource::Media));
361 EXPECT_NE(resource1, resource2); 363 EXPECT_NE(resource1, resource2);
362 memoryCache()->remove(resource2); 364 memoryCache()->remove(resource2);
363 } 365 }
364 366
365 class ServeRequestsOnCompleteClient final : public GarbageCollectedFinalized<Ser veRequestsOnCompleteClient>, public RawResourceClient { 367 class ServeRequestsOnCompleteClient final : public GarbageCollectedFinalized<Ser veRequestsOnCompleteClient>, public RawResourceClient {
368 USING_GARBAGE_COLLECTED_MIXIN(ServeRequestsOnCompleteClient);
366 public: 369 public:
367 void notifyFinished(Resource*) override 370 void notifyFinished(Resource*) override
368 { 371 {
369 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequest s(); 372 Platform::current()->getURLLoaderMockFactory()->serveAsynchronousRequest s();
370 } 373 }
371 374
372 // No callbacks should be received except for the notifyFinished() 375 // No callbacks should be received except for the notifyFinished()
373 // triggered by ResourceLoader::cancel(). 376 // triggered by ResourceLoader::cancel().
374 void dataSent(Resource*, unsigned long long, unsigned long long) override { ASSERT_TRUE(false); } 377 void dataSent(Resource*, unsigned long long, unsigned long long) override { ASSERT_TRUE(false); }
375 void responseReceived(Resource*, const ResourceResponse&, std::unique_ptr<We bDataConsumerHandle>) override { ASSERT_TRUE(false); } 378 void responseReceived(Resource*, const ResourceResponse&, std::unique_ptr<We bDataConsumerHandle>) override { ASSERT_TRUE(false); }
376 void setSerializedCachedMetadata(Resource*, const char*, size_t) override { ASSERT_TRUE(false); } 379 void setSerializedCachedMetadata(Resource*, const char*, size_t) override { ASSERT_TRUE(false); }
377 void dataReceived(Resource*, const char*, size_t) override { ASSERT_TRUE(fal se); } 380 void dataReceived(Resource*, const char*, size_t) override { ASSERT_TRUE(fal se); }
378 void redirectReceived(Resource*, ResourceRequest&, const ResourceResponse&) override { ASSERT_TRUE(false); } 381 void redirectReceived(Resource*, ResourceRequest&, const ResourceResponse&) override { ASSERT_TRUE(false); }
379 void dataDownloaded(Resource*, int) override { ASSERT_TRUE(false); } 382 void dataDownloaded(Resource*, int) override { ASSERT_TRUE(false); }
380 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) override { ASSERT_TRUE(false); } 383 void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&) override { ASSERT_TRUE(false); }
381 384
382 DEFINE_INLINE_TRACE() {} 385 DEFINE_INLINE_TRACE()
386 {
387 RawResourceClient::trace(visitor);
388 }
383 389
384 String debugName() const override { return "ServeRequestsOnCompleteClient"; } 390 String debugName() const override { return "ServeRequestsOnCompleteClient"; }
385 }; 391 };
386 392
387 // Regression test for http://crbug.com/594072. 393 // Regression test for http://crbug.com/594072.
388 // This emulates a modal dialog triggering a nested run loop inside 394 // This emulates a modal dialog triggering a nested run loop inside
389 // ResourceLoader::cancel(). If the ResourceLoader doesn't promptly cancel its 395 // ResourceLoader::cancel(). If the ResourceLoader doesn't promptly cancel its
390 // WebURLLoader before notifying its clients, a nested run loop may send a 396 // WebURLLoader before notifying its clients, a nested run loop may send a
391 // network response, leading to an invalid state transition in ResourceLoader. 397 // network response, leading to an invalid state transition in ResourceLoader.
392 TEST_F(ResourceFetcherTest, ResponseOnCancel) 398 TEST_F(ResourceFetcherTest, ResponseOnCancel)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 requester.registerRedirect(redirectURL1, redirectURL2); 503 requester.registerRedirect(redirectURL1, redirectURL2);
498 requester.registerRedirect(redirectURL2, redirectURL3); 504 requester.registerRedirect(redirectURL2, redirectURL3);
499 requester.registerRedirect(redirectURL3, finalURL); 505 requester.registerRedirect(redirectURL3, finalURL);
500 requester.registerFinalResource(finalURL); 506 requester.registerFinalResource(finalURL);
501 requester.request(redirectURL1); 507 requester.request(redirectURL1);
502 508
503 EXPECT_EQ(testImageSize, requester.context()->getTransferSize()); 509 EXPECT_EQ(testImageSize, requester.context()->getTransferSize());
504 } 510 }
505 511
506 } // namespace blink 512 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698