| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 334 } |
| 335 | 335 |
| 336 void Resource::setLoader(ResourceLoader* loader) | 336 void Resource::setLoader(ResourceLoader* loader) |
| 337 { | 337 { |
| 338 RELEASE_ASSERT(!m_loader); | 338 RELEASE_ASSERT(!m_loader); |
| 339 ASSERT(stillNeedsLoad()); | 339 ASSERT(stillNeedsLoad()); |
| 340 m_loader = loader; | 340 m_loader = loader; |
| 341 m_status = Pending; | 341 m_status = Pending; |
| 342 } | 342 } |
| 343 | 343 |
| 344 void Resource::checkNotify() | 344 void Resource::checkNotify(MarkFinishedOption markFinishedOption) |
| 345 { | 345 { |
| 346 if (isLoading()) | 346 if (isLoading()) |
| 347 return; | 347 return; |
| 348 | 348 |
| 349 ResourceClientWalker<ResourceClient> w(m_clients); | 349 ResourceClientWalker<ResourceClient> w(m_clients); |
| 350 while (ResourceClient* c = w.next()) | 350 while (ResourceClient* c = w.next()) { |
| 351 if (markFinishedOption == MarkFinishedOption::ShouldMarkFinished) |
| 352 markClientFinished(c); |
| 351 c->notifyFinished(this); | 353 c->notifyFinished(this); |
| 354 } |
| 355 } |
| 356 |
| 357 void Resource::markClientFinished(ResourceClient* client) |
| 358 { |
| 359 if (m_clients.contains(client)) { |
| 360 m_finishedClients.add(client); |
| 361 m_clients.remove(client); |
| 362 } |
| 352 } | 363 } |
| 353 | 364 |
| 354 void Resource::appendData(const char* data, size_t length) | 365 void Resource::appendData(const char* data, size_t length) |
| 355 { | 366 { |
| 356 TRACE_EVENT0("blink", "Resource::appendData"); | 367 TRACE_EVENT0("blink", "Resource::appendData"); |
| 357 DCHECK(!m_isRevalidating); | 368 DCHECK(!m_isRevalidating); |
| 358 ASSERT(!errorOccurred()); | 369 ASSERT(!errorOccurred()); |
| 359 if (m_options.dataBufferingPolicy == DoNotBufferData) | 370 if (m_options.dataBufferingPolicy == DoNotBufferData) |
| 360 return; | 371 return; |
| 361 if (m_data) | 372 if (m_data) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 374 setEncodedSize(m_data->size()); | 385 setEncodedSize(m_data->size()); |
| 375 } | 386 } |
| 376 | 387 |
| 377 void Resource::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy) | 388 void Resource::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy) |
| 378 { | 389 { |
| 379 m_options.dataBufferingPolicy = dataBufferingPolicy; | 390 m_options.dataBufferingPolicy = dataBufferingPolicy; |
| 380 m_data.clear(); | 391 m_data.clear(); |
| 381 setEncodedSize(0); | 392 setEncodedSize(0); |
| 382 } | 393 } |
| 383 | 394 |
| 384 void Resource::markClientsAndObserversFinished() | |
| 385 { | |
| 386 HashCountedSet<ResourceClient*> clients; | |
| 387 m_clients.swap(clients); | |
| 388 for (const auto& it : clients) | |
| 389 m_finishedClients.add(it.key, it.value); | |
| 390 } | |
| 391 | |
| 392 void Resource::error(const ResourceError& error) | 395 void Resource::error(const ResourceError& error) |
| 393 { | 396 { |
| 394 ASSERT(!error.isNull()); | 397 ASSERT(!error.isNull()); |
| 395 m_error = error; | 398 m_error = error; |
| 396 m_isRevalidating = false; | 399 m_isRevalidating = false; |
| 397 | 400 |
| 398 if (m_error.isCancellation() || !isPreloaded()) | 401 if (m_error.isCancellation() || !isPreloaded()) |
| 399 memoryCache()->remove(this); | 402 memoryCache()->remove(this); |
| 400 | 403 |
| 401 if (!errorOccurred()) | 404 if (!errorOccurred()) |
| 402 setStatus(LoadError); | 405 setStatus(LoadError); |
| 403 ASSERT(errorOccurred()); | 406 ASSERT(errorOccurred()); |
| 404 m_data.clear(); | 407 m_data.clear(); |
| 405 m_loader = nullptr; | 408 m_loader = nullptr; |
| 406 checkNotify(); | 409 checkNotify(MarkFinishedOption::ShouldMarkFinished); |
| 407 markClientsAndObserversFinished(); | |
| 408 } | 410 } |
| 409 | 411 |
| 410 void Resource::finish(double loadFinishTime) | 412 void Resource::finish(double loadFinishTime) |
| 411 { | 413 { |
| 412 DCHECK(!m_isRevalidating); | 414 DCHECK(!m_isRevalidating); |
| 413 m_loadFinishTime = loadFinishTime; | 415 m_loadFinishTime = loadFinishTime; |
| 414 if (!errorOccurred()) | 416 if (!errorOccurred()) |
| 415 m_status = Cached; | 417 m_status = Cached; |
| 416 m_loader = nullptr; | 418 m_loader = nullptr; |
| 417 checkNotify(); | 419 checkNotify(MarkFinishedOption::ShouldMarkFinished); |
| 418 markClientsAndObserversFinished(); | |
| 419 } | 420 } |
| 420 | 421 |
| 421 AtomicString Resource::httpContentType() const | 422 AtomicString Resource::httpContentType() const |
| 422 { | 423 { |
| 423 return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPNames::Co
ntent_Type).lower()); | 424 return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPNames::Co
ntent_Type).lower()); |
| 424 } | 425 } |
| 425 | 426 |
| 426 bool Resource::passesAccessControlCheck(SecurityOrigin* securityOrigin) const | 427 bool Resource::passesAccessControlCheck(SecurityOrigin* securityOrigin) const |
| 427 { | 428 { |
| 428 String ignoredErrorDescription; | 429 String ignoredErrorDescription; |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 case Resource::TextTrack: | 1113 case Resource::TextTrack: |
| 1113 case Resource::Media: | 1114 case Resource::Media: |
| 1114 case Resource::Manifest: | 1115 case Resource::Manifest: |
| 1115 return false; | 1116 return false; |
| 1116 } | 1117 } |
| 1117 ASSERT_NOT_REACHED(); | 1118 ASSERT_NOT_REACHED(); |
| 1118 return false; | 1119 return false; |
| 1119 } | 1120 } |
| 1120 | 1121 |
| 1121 } // namespace blink | 1122 } // namespace blink |
| OLD | NEW |