| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2009, 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "Page.h" | 44 #include "Page.h" |
| 45 #include "ResourceBuffer.h" | 45 #include "ResourceBuffer.h" |
| 46 #include "ResourceHandle.h" | 46 #include "ResourceHandle.h" |
| 47 #include "ScriptProfile.h" | 47 #include "ScriptProfile.h" |
| 48 #include "SecurityOrigin.h" | 48 #include "SecurityOrigin.h" |
| 49 #include "Settings.h" | 49 #include "Settings.h" |
| 50 #include <wtf/HashMap.h> | 50 #include <wtf/HashMap.h> |
| 51 #include <wtf/MainThread.h> | 51 #include <wtf/MainThread.h> |
| 52 #include <wtf/UnusedParam.h> | 52 #include <wtf/UnusedParam.h> |
| 53 | 53 |
| 54 #if ENABLE(INSPECTOR) | |
| 55 #include "ProgressTracker.h" | 54 #include "ProgressTracker.h" |
| 56 #endif | |
| 57 | 55 |
| 58 namespace WebCore { | 56 namespace WebCore { |
| 59 | 57 |
| 60 ApplicationCacheGroup::ApplicationCacheGroup(const KURL& manifestURL, bool isCop
y) | 58 ApplicationCacheGroup::ApplicationCacheGroup(const KURL& manifestURL, bool isCop
y) |
| 61 : m_manifestURL(manifestURL) | 59 : m_manifestURL(manifestURL) |
| 62 , m_origin(SecurityOrigin::create(manifestURL)) | 60 , m_origin(SecurityOrigin::create(manifestURL)) |
| 63 , m_updateStatus(Idle) | 61 , m_updateStatus(Idle) |
| 64 , m_downloadingPendingMasterResourceLoadersCount(0) | 62 , m_downloadingPendingMasterResourceLoadersCount(0) |
| 65 , m_progressTotal(0) | 63 , m_progressTotal(0) |
| 66 , m_progressDone(0) | 64 , m_progressDone(0) |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 if (url.protocolIsData()) | 511 if (url.protocolIsData()) |
| 514 mimeType = mimeTypeFromDataURL(url); | 512 mimeType = mimeTypeFromDataURL(url); |
| 515 if (!mimeType.isEmpty()) | 513 if (!mimeType.isEmpty()) |
| 516 target = ResourceRequest::targetTypeFromMimeType(mimeType); | 514 target = ResourceRequest::targetTypeFromMimeType(mimeType); |
| 517 } | 515 } |
| 518 | 516 |
| 519 request.setTargetType(target); | 517 request.setTargetType(target); |
| 520 #endif | 518 #endif |
| 521 | 519 |
| 522 RefPtr<ResourceHandle> handle = ResourceHandle::create(m_frame->loader()->ne
tworkingContext(), request, this, false, true); | 520 RefPtr<ResourceHandle> handle = ResourceHandle::create(m_frame->loader()->ne
tworkingContext(), request, this, false, true); |
| 523 #if ENABLE(INSPECTOR) | |
| 524 // Because willSendRequest only gets called during redirects, we initialize | 521 // Because willSendRequest only gets called during redirects, we initialize |
| 525 // the identifier and the first willSendRequest here. | 522 // the identifier and the first willSendRequest here. |
| 526 m_currentResourceIdentifier = m_frame->page()->progress()->createUniqueIdent
ifier(); | 523 m_currentResourceIdentifier = m_frame->page()->progress()->createUniqueIdent
ifier(); |
| 527 ResourceResponse redirectResponse = ResourceResponse(); | 524 ResourceResponse redirectResponse = ResourceResponse(); |
| 528 InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifi
er, m_frame->loader()->documentLoader(), request, redirectResponse); | 525 InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifi
er, m_frame->loader()->documentLoader(), request, redirectResponse); |
| 529 #endif | |
| 530 return handle; | 526 return handle; |
| 531 } | 527 } |
| 532 | 528 |
| 533 void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res
ourceResponse& response) | 529 void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res
ourceResponse& response) |
| 534 { | 530 { |
| 535 #if ENABLE(INSPECTOR) | |
| 536 DocumentLoader* loader = (handle == m_manifestHandle) ? 0 : m_frame->loader(
)->documentLoader(); | 531 DocumentLoader* loader = (handle == m_manifestHandle) ? 0 : m_frame->loader(
)->documentLoader(); |
| 537 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiv
eResourceResponse(m_frame, m_currentResourceIdentifier, response); | 532 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiv
eResourceResponse(m_frame, m_currentResourceIdentifier, response); |
| 538 InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResour
ceIdentifier, loader, response, 0); | 533 InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResour
ceIdentifier, loader, response, 0); |
| 539 #endif | |
| 540 | 534 |
| 541 if (handle == m_manifestHandle) { | 535 if (handle == m_manifestHandle) { |
| 542 didReceiveManifestResponse(response); | 536 didReceiveManifestResponse(response); |
| 543 return; | 537 return; |
| 544 } | 538 } |
| 545 | 539 |
| 546 ASSERT(handle == m_currentHandle); | 540 ASSERT(handle == m_currentHandle); |
| 547 | 541 |
| 548 KURL url(handle->firstRequest().url()); | 542 KURL url(handle->firstRequest().url()); |
| 549 if (url.hasFragmentIdentifier()) | 543 if (url.hasFragmentIdentifier()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 return; | 595 return; |
| 602 } | 596 } |
| 603 | 597 |
| 604 m_currentResource = ApplicationCacheResource::create(url, response, type); | 598 m_currentResource = ApplicationCacheResource::create(url, response, type); |
| 605 } | 599 } |
| 606 | 600 |
| 607 void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* d
ata, int length, int encodedDataLength) | 601 void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* d
ata, int length, int encodedDataLength) |
| 608 { | 602 { |
| 609 UNUSED_PARAM(encodedDataLength); | 603 UNUSED_PARAM(encodedDataLength); |
| 610 | 604 |
| 611 #if ENABLE(INSPECTOR) | |
| 612 InspectorInstrumentation::didReceiveData(m_frame, m_currentResourceIdentifie
r, 0, length, 0); | 605 InspectorInstrumentation::didReceiveData(m_frame, m_currentResourceIdentifie
r, 0, length, 0); |
| 613 #endif | |
| 614 | 606 |
| 615 if (handle == m_manifestHandle) { | 607 if (handle == m_manifestHandle) { |
| 616 didReceiveManifestData(data, length); | 608 didReceiveManifestData(data, length); |
| 617 return; | 609 return; |
| 618 } | 610 } |
| 619 | 611 |
| 620 ASSERT(handle == m_currentHandle); | 612 ASSERT(handle == m_currentHandle); |
| 621 | 613 |
| 622 ASSERT(m_currentResource); | 614 ASSERT(m_currentResource); |
| 623 m_currentResource->data()->append(data, length); | 615 m_currentResource->data()->append(data, length); |
| 624 } | 616 } |
| 625 | 617 |
| 626 void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double fini
shTime) | 618 void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double fini
shTime) |
| 627 { | 619 { |
| 628 #if ENABLE(INSPECTOR) | |
| 629 InspectorInstrumentation::didFinishLoading(m_frame, m_frame->loader()->docum
entLoader(), m_currentResourceIdentifier, finishTime); | 620 InspectorInstrumentation::didFinishLoading(m_frame, m_frame->loader()->docum
entLoader(), m_currentResourceIdentifier, finishTime); |
| 630 #else | |
| 631 UNUSED_PARAM(finishTime); | |
| 632 #endif | |
| 633 | 621 |
| 634 if (handle == m_manifestHandle) { | 622 if (handle == m_manifestHandle) { |
| 635 didFinishLoadingManifest(); | 623 didFinishLoadingManifest(); |
| 636 return; | 624 return; |
| 637 } | 625 } |
| 638 | 626 |
| 639 ASSERT(m_currentHandle == handle); | 627 ASSERT(m_currentHandle == handle); |
| 640 ASSERT(m_pendingEntries.contains(handle->firstRequest().url())); | 628 ASSERT(m_pendingEntries.contains(handle->firstRequest().url())); |
| 641 | 629 |
| 642 m_pendingEntries.remove(handle->firstRequest().url()); | 630 m_pendingEntries.remove(handle->firstRequest().url()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 657 cacheUpdateFailed(); | 645 cacheUpdateFailed(); |
| 658 return; | 646 return; |
| 659 } | 647 } |
| 660 | 648 |
| 661 // Load the next resource, if any. | 649 // Load the next resource, if any. |
| 662 startLoadingEntry(); | 650 startLoadingEntry(); |
| 663 } | 651 } |
| 664 | 652 |
| 665 void ApplicationCacheGroup::didFail(ResourceHandle* handle, const ResourceError&
error) | 653 void ApplicationCacheGroup::didFail(ResourceHandle* handle, const ResourceError&
error) |
| 666 { | 654 { |
| 667 #if ENABLE(INSPECTOR) | |
| 668 InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader()->documen
tLoader(), m_currentResourceIdentifier, error); | 655 InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader()->documen
tLoader(), m_currentResourceIdentifier, error); |
| 669 #else | |
| 670 UNUSED_PARAM(error); | |
| 671 #endif | |
| 672 | 656 |
| 673 if (handle == m_manifestHandle) { | 657 if (handle == m_manifestHandle) { |
| 674 // A network error is logged elsewhere, no need to log again. Also, it's
normal for manifest fetching to fail when working offline. | 658 // A network error is logged elsewhere, no need to log again. Also, it's
normal for manifest fetching to fail when working offline. |
| 675 cacheUpdateFailed(); | 659 cacheUpdateFailed(); |
| 676 return; | 660 return; |
| 677 } | 661 } |
| 678 | 662 |
| 679 ASSERT(handle == m_currentHandle); | 663 ASSERT(handle == m_currentHandle); |
| 680 | 664 |
| 681 unsigned type = m_currentResource ? m_currentResource->type() : m_pendingEnt
ries.get(handle->firstRequest().url()); | 665 unsigned type = m_currentResource ? m_currentResource->type() : m_pendingEnt
ries.get(handle->firstRequest().url()); |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 void ApplicationCacheGroup::clearStorageID() | 1171 void ApplicationCacheGroup::clearStorageID() |
| 1188 { | 1172 { |
| 1189 m_storageID = 0; | 1173 m_storageID = 0; |
| 1190 | 1174 |
| 1191 HashSet<ApplicationCache*>::const_iterator end = m_caches.end(); | 1175 HashSet<ApplicationCache*>::const_iterator end = m_caches.end(); |
| 1192 for (HashSet<ApplicationCache*>::const_iterator it = m_caches.begin(); it !=
end; ++it) | 1176 for (HashSet<ApplicationCache*>::const_iterator it = m_caches.begin(); it !=
end; ++it) |
| 1193 (*it)->clearStorageID(); | 1177 (*it)->clearStorageID(); |
| 1194 } | 1178 } |
| 1195 | 1179 |
| 1196 } | 1180 } |
| OLD | NEW |