1 | /* |
2 | * Copyright (C) 2012, 2015 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #include "FetchOptions.h" |
29 | #include "PageIdentifier.h" |
30 | #include "ResourceLoadPriority.h" |
31 | #include "ResourceLoaderOptions.h" |
32 | #include "StoredCredentialsPolicy.h" |
33 | #include <pal/SessionID.h> |
34 | #include <wtf/Forward.h> |
35 | |
36 | namespace WebCore { |
37 | |
38 | class CachedResource; |
39 | class ContentSecurityPolicy; |
40 | class Frame; |
41 | class FrameLoader; |
42 | class ; |
43 | class NetscapePlugInStreamLoader; |
44 | class NetscapePlugInStreamLoaderClient; |
45 | struct NetworkTransactionInformation; |
46 | class NetworkLoadMetrics; |
47 | class ResourceError; |
48 | class ResourceLoader; |
49 | class ResourceRequest; |
50 | class ResourceResponse; |
51 | class SecurityOrigin; |
52 | class SharedBuffer; |
53 | class SubresourceLoader; |
54 | |
55 | struct FetchOptions; |
56 | |
57 | class WEBCORE_EXPORT LoaderStrategy { |
58 | public: |
59 | virtual void loadResource(Frame&, CachedResource&, ResourceRequest&&, const ResourceLoaderOptions&, CompletionHandler<void(RefPtr<SubresourceLoader>&&)>&&) = 0; |
60 | virtual void loadResourceSynchronously(FrameLoader&, unsigned long identifier, const ResourceRequest&, ClientCredentialPolicy, const FetchOptions&, const HTTPHeaderMap&, ResourceError&, ResourceResponse&, Vector<char>& data) = 0; |
61 | virtual void pageLoadCompleted(PageIdentifier) = 0; |
62 | |
63 | virtual void remove(ResourceLoader*) = 0; |
64 | virtual void setDefersLoading(ResourceLoader&, bool) = 0; |
65 | virtual void crossOriginRedirectReceived(ResourceLoader*, const URL& redirectURL) = 0; |
66 | |
67 | virtual void servePendingRequests(ResourceLoadPriority minimumPriority = ResourceLoadPriority::VeryLow) = 0; |
68 | virtual void suspendPendingRequests() = 0; |
69 | virtual void resumePendingRequests() = 0; |
70 | |
71 | virtual bool usePingLoad() const { return true; } |
72 | using PingLoadCompletionHandler = WTF::Function<void(const ResourceError&, const ResourceResponse&)>; |
73 | virtual void (Frame&, ResourceRequest&, const HTTPHeaderMap& , const FetchOptions&, ContentSecurityPolicyImposition, PingLoadCompletionHandler&& = { }) = 0; |
74 | |
75 | using PreconnectCompletionHandler = WTF::Function<void(const ResourceError&)>; |
76 | virtual void preconnectTo(FrameLoader&, const URL&, StoredCredentialsPolicy, PreconnectCompletionHandler&&) = 0; |
77 | |
78 | virtual void (bool) = 0; |
79 | |
80 | virtual bool isOnLine() const = 0; |
81 | virtual void addOnlineStateChangeListener(WTF::Function<void(bool)>&&) = 0; |
82 | |
83 | virtual bool shouldPerformSecurityChecks() const { return false; } |
84 | virtual bool havePerformedSecurityChecks(const ResourceResponse&) const { return false; } |
85 | |
86 | virtual ResourceResponse responseFromResourceLoadIdentifier(uint64_t resourceLoadIdentifier); |
87 | virtual Vector<NetworkTransactionInformation> intermediateLoadInformationFromResourceLoadIdentifier(uint64_t resourceLoadIdentifier); |
88 | virtual NetworkLoadMetrics networkMetricsFromResourceLoadIdentifier(uint64_t resourceLoadIdentifier); |
89 | |
90 | // Used for testing only. |
91 | virtual Vector<uint64_t> ongoingLoads() const { return { }; } |
92 | |
93 | protected: |
94 | virtual ~LoaderStrategy(); |
95 | }; |
96 | |
97 | } // namespace WebCore |
98 | |