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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/Resource.cpp

Issue 2642383003: Replace Resource::Status with ResourceStatus (Closed)
Patch Set: Rebase. Created 3 years, 10 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) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
7 rights reserved. 7 rights reserved.
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 void Resource::ResourceCallback::runTask() { 295 void Resource::ResourceCallback::runTask() {
296 HeapVector<Member<Resource>> resources; 296 HeapVector<Member<Resource>> resources;
297 for (const Member<Resource>& resource : m_resourcesWithPendingClients) 297 for (const Member<Resource>& resource : m_resourcesWithPendingClients)
298 resources.push_back(resource.get()); 298 resources.push_back(resource.get());
299 m_resourcesWithPendingClients.clear(); 299 m_resourcesWithPendingClients.clear();
300 300
301 for (const auto& resource : resources) 301 for (const auto& resource : resources)
302 resource->finishPendingClients(); 302 resource->finishPendingClients();
303 } 303 }
304 304
305 constexpr Resource::Status Resource::NotStarted;
306 constexpr Resource::Status Resource::Pending;
307 constexpr Resource::Status Resource::Cached;
308 constexpr Resource::Status Resource::LoadError;
309 constexpr Resource::Status Resource::DecodeError;
310
311 Resource::Resource(const ResourceRequest& request, 305 Resource::Resource(const ResourceRequest& request,
312 Type type, 306 Type type,
313 const ResourceLoaderOptions& options) 307 const ResourceLoaderOptions& options)
314 : m_loadFinishTime(0), 308 : m_loadFinishTime(0),
315 m_identifier(0), 309 m_identifier(0),
316 m_encodedSize(0), 310 m_encodedSize(0),
317 m_encodedSizeMemoryUsage(0), 311 m_encodedSizeMemoryUsage(0),
318 m_decodedSize(0), 312 m_decodedSize(0),
319 m_overheadSize(calculateOverheadSize()), 313 m_overheadSize(calculateOverheadSize()),
320 m_preloadCount(0), 314 m_preloadCount(0),
321 m_preloadDiscoveryTime(0.0), 315 m_preloadDiscoveryTime(0.0),
322 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), 316 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()),
323 m_preloadResult(PreloadNotReferenced), 317 m_preloadResult(PreloadNotReferenced),
324 m_type(type), 318 m_type(type),
325 m_status(NotStarted), 319 m_status(ResourceStatus::NotStarted),
326 m_needsSynchronousCacheHit(false), 320 m_needsSynchronousCacheHit(false),
327 m_linkPreload(false), 321 m_linkPreload(false),
328 m_isRevalidating(false), 322 m_isRevalidating(false),
329 m_isAlive(false), 323 m_isAlive(false),
330 m_isAddRemoveClientProhibited(false), 324 m_isAddRemoveClientProhibited(false),
331 m_integrityDisposition(ResourceIntegrityDisposition::NotChecked), 325 m_integrityDisposition(ResourceIntegrityDisposition::NotChecked),
332 m_options(options), 326 m_options(options),
333 m_responseTimestamp(currentTime()), 327 m_responseTimestamp(currentTime()),
334 m_cancelTimer(Platform::current()->mainThread()->getWebTaskRunner(), 328 m_cancelTimer(Platform::current()->mainThread()->getWebTaskRunner(),
335 this, 329 this,
(...skipping 17 matching lines...) Expand all
353 visitor->trace(m_clients); 347 visitor->trace(m_clients);
354 visitor->trace(m_clientsAwaitingCallback); 348 visitor->trace(m_clientsAwaitingCallback);
355 visitor->trace(m_finishedClients); 349 visitor->trace(m_finishedClients);
356 MemoryCoordinatorClient::trace(visitor); 350 MemoryCoordinatorClient::trace(visitor);
357 } 351 }
358 352
359 void Resource::setLoader(ResourceLoader* loader) { 353 void Resource::setLoader(ResourceLoader* loader) {
360 CHECK(!m_loader); 354 CHECK(!m_loader);
361 DCHECK(stillNeedsLoad()); 355 DCHECK(stillNeedsLoad());
362 m_loader = loader; 356 m_loader = loader;
363 m_status = Pending; 357 m_status = ResourceStatus::Pending;
364 } 358 }
365 359
366 void Resource::checkNotify() { 360 void Resource::checkNotify() {
367 if (isLoading()) 361 if (isLoading())
368 return; 362 return;
369 363
370 ResourceClientWalker<ResourceClient> w(m_clients); 364 ResourceClientWalker<ResourceClient> w(m_clients);
371 while (ResourceClient* c = w.next()) { 365 while (ResourceClient* c = w.next()) {
372 markClientFinished(c); 366 markClientFinished(c);
373 c->notifyFinished(this); 367 c->notifyFinished(this);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 409
416 void Resource::error(const ResourceError& error) { 410 void Resource::error(const ResourceError& error) {
417 DCHECK(!error.isNull()); 411 DCHECK(!error.isNull());
418 m_error = error; 412 m_error = error;
419 m_isRevalidating = false; 413 m_isRevalidating = false;
420 414
421 if (m_error.isCancellation() || !isPreloaded()) 415 if (m_error.isCancellation() || !isPreloaded())
422 memoryCache()->remove(this); 416 memoryCache()->remove(this);
423 417
424 if (!errorOccurred()) 418 if (!errorOccurred())
425 setStatus(LoadError); 419 setStatus(ResourceStatus::LoadError);
426 DCHECK(errorOccurred()); 420 DCHECK(errorOccurred());
427 clearData(); 421 clearData();
428 m_loader = nullptr; 422 m_loader = nullptr;
429 checkNotify(); 423 checkNotify();
430 } 424 }
431 425
432 void Resource::finish(double loadFinishTime) { 426 void Resource::finish(double loadFinishTime) {
433 DCHECK(!m_isRevalidating); 427 DCHECK(!m_isRevalidating);
434 m_loadFinishTime = loadFinishTime; 428 m_loadFinishTime = loadFinishTime;
435 if (!errorOccurred()) 429 if (!errorOccurred())
436 m_status = Cached; 430 m_status = ResourceStatus::Cached;
437 m_loader = nullptr; 431 m_loader = nullptr;
438 checkNotify(); 432 checkNotify();
439 } 433 }
440 434
441 AtomicString Resource::httpContentType() const { 435 AtomicString Resource::httpContentType() const {
442 return extractMIMETypeFromMediaType( 436 return extractMIMETypeFromMediaType(
443 response().httpHeaderField(HTTPNames::Content_Type).lower()); 437 response().httpHeaderField(HTTPNames::Content_Type).lower());
444 } 438 }
445 439
446 bool Resource::passesAccessControlCheck(SecurityOrigin* securityOrigin) const { 440 bool Resource::passesAccessControlCheck(SecurityOrigin* securityOrigin) const {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 return resourceRequest(); 563 return resourceRequest();
570 return m_redirectChain.back().m_request; 564 return m_redirectChain.back().m_request;
571 } 565 }
572 566
573 void Resource::setRevalidatingRequest(const ResourceRequest& request) { 567 void Resource::setRevalidatingRequest(const ResourceRequest& request) {
574 SECURITY_CHECK(m_redirectChain.isEmpty()); 568 SECURITY_CHECK(m_redirectChain.isEmpty());
575 DCHECK(!request.isNull()); 569 DCHECK(!request.isNull());
576 CHECK(!m_isRevalidationStartForbidden); 570 CHECK(!m_isRevalidationStartForbidden);
577 m_isRevalidating = true; 571 m_isRevalidating = true;
578 m_resourceRequest = request; 572 m_resourceRequest = request;
579 m_status = NotStarted; 573 m_status = ResourceStatus::NotStarted;
580 } 574 }
581 575
582 bool Resource::willFollowRedirect(const ResourceRequest& newRequest, 576 bool Resource::willFollowRedirect(const ResourceRequest& newRequest,
583 const ResourceResponse& redirectResponse) { 577 const ResourceResponse& redirectResponse) {
584 if (m_isRevalidating) 578 if (m_isRevalidating)
585 revalidationFailed(); 579 revalidationFailed();
586 m_redirectChain.push_back(RedirectPair(newRequest, redirectResponse)); 580 m_redirectChain.push_back(RedirectPair(newRequest, redirectResponse));
587 return true; 581 return true;
588 } 582 }
589 583
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 case Resource::Media: 1109 case Resource::Media:
1116 case Resource::Manifest: 1110 case Resource::Manifest:
1117 case Resource::Mock: 1111 case Resource::Mock:
1118 return false; 1112 return false;
1119 } 1113 }
1120 NOTREACHED(); 1114 NOTREACHED();
1121 return false; 1115 return false;
1122 } 1116 }
1123 1117
1124 } // namespace blink 1118 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698