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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 rights reserved. | 6 rights reserved. |
7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 response.SetTextEncodingName(substitute_data.TextEncoding()); | 406 response.SetTextEncodingName(substitute_data.TextEncoding()); |
407 } else if (url.ProtocolIsData()) { | 407 } else if (url.ProtocolIsData()) { |
408 data = NetworkUtils::ParseDataURLAndPopulateResponse(url, response); | 408 data = NetworkUtils::ParseDataURLAndPopulateResponse(url, response); |
409 if (!data) | 409 if (!data) |
410 return nullptr; | 410 return nullptr; |
411 // |response| is modified by parseDataURLAndPopulateResponse() and is | 411 // |response| is modified by parseDataURLAndPopulateResponse() and is |
412 // ready to be used. | 412 // ready to be used. |
413 } else { | 413 } else { |
414 ArchiveResource* archive_resource = | 414 ArchiveResource* archive_resource = |
415 archive_->SubresourceForURL(params.Url()); | 415 archive_->SubresourceForURL(params.Url()); |
416 // Fall back to the network if the archive doesn't contain the resource. | 416 // The archive doesn't contain the resource, the request must be aborted. |
417 if (!archive_resource) | 417 if (!archive_resource) |
418 return nullptr; | 418 return nullptr; |
419 data = archive_resource->Data(); | 419 data = archive_resource->Data(); |
420 response.SetURL(url); | 420 response.SetURL(url); |
421 response.SetMimeType(archive_resource->MimeType()); | 421 response.SetMimeType(archive_resource->MimeType()); |
422 response.SetExpectedContentLength(data->size()); | 422 response.SetExpectedContentLength(data->size()); |
423 response.SetTextEncodingName(archive_resource->TextEncoding()); | 423 response.SetTextEncodingName(archive_resource->TextEncoding()); |
424 } | 424 } |
425 | 425 |
426 Resource* resource = factory.Create(params.GetResourceRequest(), | 426 Resource* resource = factory.Create(params.GetResourceRequest(), |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
571 if (result == kBlock) | 571 if (result == kBlock) |
572 return ResourceForBlockedRequest(params, factory, blocked_reason); | 572 return ResourceForBlockedRequest(params, factory, blocked_reason); |
573 | 573 |
574 if (!params.IsSpeculativePreload()) { | 574 if (!params.IsSpeculativePreload()) { |
575 // Only log if it's not for speculative preload. | 575 // Only log if it's not for speculative preload. |
576 Context().RecordLoadingActivity(identifier, resource_request, | 576 Context().RecordLoadingActivity(identifier, resource_request, |
577 factory.GetType(), | 577 factory.GetType(), |
578 params.Options().initiator_info.name); | 578 params.Options().initiator_info.name); |
579 } | 579 } |
580 | 580 |
581 // An URL with the "cid" scheme can only be handled by an MHTML Archive. | |
582 // Abort the request when there is none. | |
583 if (resource_request.Url().ProtocolIs(kContentIdScheme) && !archive_) { | |
pfeldman
2017/05/05 20:45:36
[perf]: check !archive_ first
[style nit]: drop {}
| |
584 return nullptr; | |
585 } | |
586 | |
581 bool is_data_url = resource_request.Url().ProtocolIsData(); | 587 bool is_data_url = resource_request.Url().ProtocolIsData(); |
582 bool is_static_data = is_data_url || substitute_data.IsValid() || archive_; | 588 bool is_static_data = is_data_url || substitute_data.IsValid() || archive_; |
583 if (is_static_data) { | 589 if (is_static_data) { |
584 resource = ResourceForStaticData(params, factory, substitute_data); | 590 resource = ResourceForStaticData(params, factory, substitute_data); |
585 // Abort the request if the archive doesn't contain the resource, except in | 591 // Abort the request if the archive doesn't contain the resource, except in |
586 // the case of data URLs which might have resources such as fonts that need | 592 // the case of data URLs which might have resources such as fonts that need |
587 // to be decoded only on demand. These data URLs are allowed to be | 593 // to be decoded only on demand. These data URLs are allowed to be |
588 // processed using the normal ResourceFetcher machinery. | 594 // processed using the normal ResourceFetcher machinery. |
589 if (!resource && !is_data_url && archive_) | 595 if (!resource && !is_data_url && archive_) |
590 return nullptr; | 596 return nullptr; |
591 } | 597 } |
592 if (!resource) { | 598 if (!resource) { |
593 resource = | 599 resource = |
594 GetMemoryCache()->ResourceForURL(params.Url(), GetCacheIdentifier()); | 600 GetMemoryCache()->ResourceForURL(params.Url(), GetCacheIdentifier()); |
595 } | 601 } |
596 | 602 |
597 // If we got a preloaded resource from the cache for a non-preload request, | 603 // If we got a preloaded resource from the cache for a non-preload request, |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1527 visitor->Trace(context_); | 1533 visitor->Trace(context_); |
1528 visitor->Trace(archive_); | 1534 visitor->Trace(archive_); |
1529 visitor->Trace(loaders_); | 1535 visitor->Trace(loaders_); |
1530 visitor->Trace(non_blocking_loaders_); | 1536 visitor->Trace(non_blocking_loaders_); |
1531 visitor->Trace(document_resources_); | 1537 visitor->Trace(document_resources_); |
1532 visitor->Trace(preloads_); | 1538 visitor->Trace(preloads_); |
1533 visitor->Trace(resource_timing_info_map_); | 1539 visitor->Trace(resource_timing_info_map_); |
1534 } | 1540 } |
1535 | 1541 |
1536 } // namespace blink | 1542 } // namespace blink |
OLD | NEW |