| OLD | NEW |
| 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
rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 void Resource::setLoader(ResourceLoader* loader) | 335 void Resource::setLoader(ResourceLoader* loader) |
| 336 { | 336 { |
| 337 RELEASE_ASSERT(!m_loader); | 337 RELEASE_ASSERT(!m_loader); |
| 338 ASSERT(stillNeedsLoad()); | 338 ASSERT(stillNeedsLoad()); |
| 339 m_loader = loader; | 339 m_loader = loader; |
| 340 m_status = Pending; | 340 m_status = Pending; |
| 341 } | 341 } |
| 342 | 342 |
| 343 void Resource::checkNotify() | 343 void Resource::checkNotify() |
| 344 { | 344 { |
| 345 notifyClientsInternal(MarkFinishedOption::ShouldMarkFinished); |
| 346 } |
| 347 |
| 348 void Resource::notifyClientsInternal(MarkFinishedOption markFinishedOption) |
| 349 { |
| 345 if (isLoading()) | 350 if (isLoading()) |
| 346 return; | 351 return; |
| 347 | 352 |
| 348 ResourceClientWalker<ResourceClient> w(m_clients); | 353 ResourceClientWalker<ResourceClient> w(m_clients); |
| 349 while (ResourceClient* c = w.next()) | 354 while (ResourceClient* c = w.next()) { |
| 355 if (markFinishedOption == MarkFinishedOption::ShouldMarkFinished) |
| 356 markClientFinished(c); |
| 350 c->notifyFinished(this); | 357 c->notifyFinished(this); |
| 358 } |
| 359 } |
| 360 |
| 361 void Resource::markClientFinished(ResourceClient* client) |
| 362 { |
| 363 if (m_clients.contains(client)) { |
| 364 m_finishedClients.add(client); |
| 365 m_clients.remove(client); |
| 366 } |
| 351 } | 367 } |
| 352 | 368 |
| 353 void Resource::appendData(const char* data, size_t length) | 369 void Resource::appendData(const char* data, size_t length) |
| 354 { | 370 { |
| 355 TRACE_EVENT0("blink", "Resource::appendData"); | 371 TRACE_EVENT0("blink", "Resource::appendData"); |
| 356 DCHECK(!m_isRevalidating); | 372 DCHECK(!m_isRevalidating); |
| 357 ASSERT(!errorOccurred()); | 373 ASSERT(!errorOccurred()); |
| 358 if (m_options.dataBufferingPolicy == DoNotBufferData) | 374 if (m_options.dataBufferingPolicy == DoNotBufferData) |
| 359 return; | 375 return; |
| 360 if (m_data) | 376 if (m_data) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 373 setEncodedSize(m_data->size()); | 389 setEncodedSize(m_data->size()); |
| 374 } | 390 } |
| 375 | 391 |
| 376 void Resource::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy) | 392 void Resource::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy) |
| 377 { | 393 { |
| 378 m_options.dataBufferingPolicy = dataBufferingPolicy; | 394 m_options.dataBufferingPolicy = dataBufferingPolicy; |
| 379 m_data.clear(); | 395 m_data.clear(); |
| 380 setEncodedSize(0); | 396 setEncodedSize(0); |
| 381 } | 397 } |
| 382 | 398 |
| 383 void Resource::markClientsAndObserversFinished() | |
| 384 { | |
| 385 HashCountedSet<ResourceClient*> clients; | |
| 386 m_clients.swap(clients); | |
| 387 for (const auto& it : clients) | |
| 388 m_finishedClients.add(it.key, it.value); | |
| 389 } | |
| 390 | |
| 391 void Resource::error(const ResourceError& error) | 399 void Resource::error(const ResourceError& error) |
| 392 { | 400 { |
| 393 ASSERT(!error.isNull()); | 401 ASSERT(!error.isNull()); |
| 394 m_error = error; | 402 m_error = error; |
| 395 m_isRevalidating = false; | 403 m_isRevalidating = false; |
| 396 | 404 |
| 397 if (m_error.isCancellation() || !isPreloaded()) | 405 if (m_error.isCancellation() || !isPreloaded()) |
| 398 memoryCache()->remove(this); | 406 memoryCache()->remove(this); |
| 399 | 407 |
| 400 setStatus(LoadError); | 408 setStatus(LoadError); |
| 401 ASSERT(errorOccurred()); | 409 ASSERT(errorOccurred()); |
| 402 m_data.clear(); | 410 m_data.clear(); |
| 403 m_loader = nullptr; | 411 m_loader = nullptr; |
| 404 checkNotify(); | 412 checkNotify(); |
| 405 markClientsAndObserversFinished(); | |
| 406 } | 413 } |
| 407 | 414 |
| 408 void Resource::finish(double loadFinishTime) | 415 void Resource::finish(double loadFinishTime) |
| 409 { | 416 { |
| 410 DCHECK(!m_isRevalidating); | 417 DCHECK(!m_isRevalidating); |
| 411 m_loadFinishTime = loadFinishTime; | 418 m_loadFinishTime = loadFinishTime; |
| 412 if (!errorOccurred()) | 419 if (!errorOccurred()) |
| 413 m_status = Cached; | 420 m_status = Cached; |
| 414 m_loader = nullptr; | 421 m_loader = nullptr; |
| 415 checkNotify(); | 422 checkNotify(); |
| 416 markClientsAndObserversFinished(); | |
| 417 } | 423 } |
| 418 | 424 |
| 419 AtomicString Resource::httpContentType() const | 425 AtomicString Resource::httpContentType() const |
| 420 { | 426 { |
| 421 return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPNames::Co
ntent_Type).lower()); | 427 return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPNames::Co
ntent_Type).lower()); |
| 422 } | 428 } |
| 423 | 429 |
| 424 bool Resource::passesAccessControlCheck(SecurityOrigin* securityOrigin) const | 430 bool Resource::passesAccessControlCheck(SecurityOrigin* securityOrigin) const |
| 425 { | 431 { |
| 426 String ignoredErrorDescription; | 432 String ignoredErrorDescription; |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 case Resource::Media: | 1134 case Resource::Media: |
| 1129 return "Media"; | 1135 return "Media"; |
| 1130 case Resource::Manifest: | 1136 case Resource::Manifest: |
| 1131 return "Manifest"; | 1137 return "Manifest"; |
| 1132 } | 1138 } |
| 1133 ASSERT_NOT_REACHED(); | 1139 ASSERT_NOT_REACHED(); |
| 1134 return "Unknown"; | 1140 return "Unknown"; |
| 1135 } | 1141 } |
| 1136 | 1142 |
| 1137 } // namespace blink | 1143 } // namespace blink |
| OLD | NEW |