| 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 24 matching lines...) Expand all Loading... |
| 35 #include "Console.h" | 35 #include "Console.h" |
| 36 #include "DOMApplicationCache.h" | 36 #include "DOMApplicationCache.h" |
| 37 #include "DOMWindow.h" | 37 #include "DOMWindow.h" |
| 38 #include "DocumentLoader.h" | 38 #include "DocumentLoader.h" |
| 39 #include "Frame.h" | 39 #include "Frame.h" |
| 40 #include "FrameLoader.h" | 40 #include "FrameLoader.h" |
| 41 #include "FrameLoaderClient.h" | 41 #include "FrameLoaderClient.h" |
| 42 #include "InspectorInstrumentation.h" | 42 #include "InspectorInstrumentation.h" |
| 43 #include "ManifestParser.h" | 43 #include "ManifestParser.h" |
| 44 #include "Page.h" | 44 #include "Page.h" |
| 45 #include "ProgressTracker.h" |
| 45 #include "ResourceBuffer.h" | 46 #include "ResourceBuffer.h" |
| 46 #include "ResourceHandle.h" | 47 #include "ResourceHandle.h" |
| 47 #include "ScriptProfile.h" | 48 #include "ScriptProfile.h" |
| 48 #include "SecurityOrigin.h" | 49 #include "SecurityOrigin.h" |
| 49 #include "Settings.h" | 50 #include "Settings.h" |
| 50 #include <wtf/HashMap.h> | 51 #include <wtf/HashMap.h> |
| 51 #include <wtf/MainThread.h> | 52 #include <wtf/MainThread.h> |
| 52 #include <wtf/UnusedParam.h> | 53 #include <wtf/UnusedParam.h> |
| 53 | 54 |
| 54 #if ENABLE(INSPECTOR) | |
| 55 #include "ProgressTracker.h" | |
| 56 #endif | |
| 57 | |
| 58 namespace WebCore { | 55 namespace WebCore { |
| 59 | 56 |
| 60 ApplicationCacheGroup::ApplicationCacheGroup(const KURL& manifestURL, bool isCop
y) | 57 ApplicationCacheGroup::ApplicationCacheGroup(const KURL& manifestURL, bool isCop
y) |
| 61 : m_manifestURL(manifestURL) | 58 : m_manifestURL(manifestURL) |
| 62 , m_origin(SecurityOrigin::create(manifestURL)) | 59 , m_origin(SecurityOrigin::create(manifestURL)) |
| 63 , m_updateStatus(Idle) | 60 , m_updateStatus(Idle) |
| 64 , m_downloadingPendingMasterResourceLoadersCount(0) | 61 , m_downloadingPendingMasterResourceLoadersCount(0) |
| 65 , m_progressTotal(0) | 62 , m_progressTotal(0) |
| 66 , m_progressDone(0) | 63 , m_progressDone(0) |
| 67 , m_frame(0) | 64 , m_frame(0) |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 if (url.protocolIsData()) | 510 if (url.protocolIsData()) |
| 514 mimeType = mimeTypeFromDataURL(url); | 511 mimeType = mimeTypeFromDataURL(url); |
| 515 if (!mimeType.isEmpty()) | 512 if (!mimeType.isEmpty()) |
| 516 target = ResourceRequest::targetTypeFromMimeType(mimeType); | 513 target = ResourceRequest::targetTypeFromMimeType(mimeType); |
| 517 } | 514 } |
| 518 | 515 |
| 519 request.setTargetType(target); | 516 request.setTargetType(target); |
| 520 #endif | 517 #endif |
| 521 | 518 |
| 522 RefPtr<ResourceHandle> handle = ResourceHandle::create(m_frame->loader()->ne
tworkingContext(), request, this, false, true); | 519 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 | 520 // Because willSendRequest only gets called during redirects, we initialize |
| 525 // the identifier and the first willSendRequest here. | 521 // the identifier and the first willSendRequest here. |
| 526 m_currentResourceIdentifier = m_frame->page()->progress()->createUniqueIdent
ifier(); | 522 m_currentResourceIdentifier = m_frame->page()->progress()->createUniqueIdent
ifier(); |
| 527 ResourceResponse redirectResponse = ResourceResponse(); | 523 ResourceResponse redirectResponse = ResourceResponse(); |
| 528 InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifi
er, m_frame->loader()->documentLoader(), request, redirectResponse); | 524 InspectorInstrumentation::willSendRequest(m_frame, m_currentResourceIdentifi
er, m_frame->loader()->documentLoader(), request, redirectResponse); |
| 529 #endif | |
| 530 return handle; | 525 return handle; |
| 531 } | 526 } |
| 532 | 527 |
| 533 void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res
ourceResponse& response) | 528 void ApplicationCacheGroup::didReceiveResponse(ResourceHandle* handle, const Res
ourceResponse& response) |
| 534 { | 529 { |
| 535 #if ENABLE(INSPECTOR) | |
| 536 DocumentLoader* loader = (handle == m_manifestHandle) ? 0 : m_frame->loader(
)->documentLoader(); | 530 DocumentLoader* loader = (handle == m_manifestHandle) ? 0 : m_frame->loader(
)->documentLoader(); |
| 537 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiv
eResourceResponse(m_frame, m_currentResourceIdentifier, response); | 531 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiv
eResourceResponse(m_frame, m_currentResourceIdentifier, response); |
| 538 InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResour
ceIdentifier, loader, response, 0); | 532 InspectorInstrumentation::didReceiveResourceResponse(cookie, m_currentResour
ceIdentifier, loader, response, 0); |
| 539 #endif | |
| 540 | 533 |
| 541 if (handle == m_manifestHandle) { | 534 if (handle == m_manifestHandle) { |
| 542 didReceiveManifestResponse(response); | 535 didReceiveManifestResponse(response); |
| 543 return; | 536 return; |
| 544 } | 537 } |
| 545 | 538 |
| 546 ASSERT(handle == m_currentHandle); | 539 ASSERT(handle == m_currentHandle); |
| 547 | 540 |
| 548 KURL url(handle->firstRequest().url()); | 541 KURL url(handle->firstRequest().url()); |
| 549 if (url.hasFragmentIdentifier()) | 542 if (url.hasFragmentIdentifier()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 return; | 594 return; |
| 602 } | 595 } |
| 603 | 596 |
| 604 m_currentResource = ApplicationCacheResource::create(url, response, type); | 597 m_currentResource = ApplicationCacheResource::create(url, response, type); |
| 605 } | 598 } |
| 606 | 599 |
| 607 void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* d
ata, int length, int encodedDataLength) | 600 void ApplicationCacheGroup::didReceiveData(ResourceHandle* handle, const char* d
ata, int length, int encodedDataLength) |
| 608 { | 601 { |
| 609 UNUSED_PARAM(encodedDataLength); | 602 UNUSED_PARAM(encodedDataLength); |
| 610 | 603 |
| 611 #if ENABLE(INSPECTOR) | |
| 612 InspectorInstrumentation::didReceiveData(m_frame, m_currentResourceIdentifie
r, 0, length, 0); | 604 InspectorInstrumentation::didReceiveData(m_frame, m_currentResourceIdentifie
r, 0, length, 0); |
| 613 #endif | |
| 614 | 605 |
| 615 if (handle == m_manifestHandle) { | 606 if (handle == m_manifestHandle) { |
| 616 didReceiveManifestData(data, length); | 607 didReceiveManifestData(data, length); |
| 617 return; | 608 return; |
| 618 } | 609 } |
| 619 | 610 |
| 620 ASSERT(handle == m_currentHandle); | 611 ASSERT(handle == m_currentHandle); |
| 621 | 612 |
| 622 ASSERT(m_currentResource); | 613 ASSERT(m_currentResource); |
| 623 m_currentResource->data()->append(data, length); | 614 m_currentResource->data()->append(data, length); |
| 624 } | 615 } |
| 625 | 616 |
| 626 void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double fini
shTime) | 617 void ApplicationCacheGroup::didFinishLoading(ResourceHandle* handle, double fini
shTime) |
| 627 { | 618 { |
| 628 #if ENABLE(INSPECTOR) | |
| 629 InspectorInstrumentation::didFinishLoading(m_frame, m_frame->loader()->docum
entLoader(), m_currentResourceIdentifier, finishTime); | 619 InspectorInstrumentation::didFinishLoading(m_frame, m_frame->loader()->docum
entLoader(), m_currentResourceIdentifier, finishTime); |
| 630 #else | |
| 631 UNUSED_PARAM(finishTime); | |
| 632 #endif | |
| 633 | 620 |
| 634 if (handle == m_manifestHandle) { | 621 if (handle == m_manifestHandle) { |
| 635 didFinishLoadingManifest(); | 622 didFinishLoadingManifest(); |
| 636 return; | 623 return; |
| 637 } | 624 } |
| 638 | 625 |
| 639 ASSERT(m_currentHandle == handle); | 626 ASSERT(m_currentHandle == handle); |
| 640 ASSERT(m_pendingEntries.contains(handle->firstRequest().url())); | 627 ASSERT(m_pendingEntries.contains(handle->firstRequest().url())); |
| 641 | 628 |
| 642 m_pendingEntries.remove(handle->firstRequest().url()); | 629 m_pendingEntries.remove(handle->firstRequest().url()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 657 cacheUpdateFailed(); | 644 cacheUpdateFailed(); |
| 658 return; | 645 return; |
| 659 } | 646 } |
| 660 | 647 |
| 661 // Load the next resource, if any. | 648 // Load the next resource, if any. |
| 662 startLoadingEntry(); | 649 startLoadingEntry(); |
| 663 } | 650 } |
| 664 | 651 |
| 665 void ApplicationCacheGroup::didFail(ResourceHandle* handle, const ResourceError&
error) | 652 void ApplicationCacheGroup::didFail(ResourceHandle* handle, const ResourceError&
error) |
| 666 { | 653 { |
| 667 #if ENABLE(INSPECTOR) | |
| 668 InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader()->documen
tLoader(), m_currentResourceIdentifier, error); | 654 InspectorInstrumentation::didFailLoading(m_frame, m_frame->loader()->documen
tLoader(), m_currentResourceIdentifier, error); |
| 669 #else | |
| 670 UNUSED_PARAM(error); | |
| 671 #endif | |
| 672 | 655 |
| 673 if (handle == m_manifestHandle) { | 656 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. | 657 // 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(); | 658 cacheUpdateFailed(); |
| 676 return; | 659 return; |
| 677 } | 660 } |
| 678 | 661 |
| 679 ASSERT(handle == m_currentHandle); | 662 ASSERT(handle == m_currentHandle); |
| 680 | 663 |
| 681 unsigned type = m_currentResource ? m_currentResource->type() : m_pendingEnt
ries.get(handle->firstRequest().url()); | 664 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() | 1170 void ApplicationCacheGroup::clearStorageID() |
| 1188 { | 1171 { |
| 1189 m_storageID = 0; | 1172 m_storageID = 0; |
| 1190 | 1173 |
| 1191 HashSet<ApplicationCache*>::const_iterator end = m_caches.end(); | 1174 HashSet<ApplicationCache*>::const_iterator end = m_caches.end(); |
| 1192 for (HashSet<ApplicationCache*>::const_iterator it = m_caches.begin(); it !=
end; ++it) | 1175 for (HashSet<ApplicationCache*>::const_iterator it = m_caches.begin(); it !=
end; ++it) |
| 1193 (*it)->clearStorageID(); | 1176 (*it)->clearStorageID(); |
| 1194 } | 1177 } |
| 1195 | 1178 |
| 1196 } | 1179 } |
| OLD | NEW |