2 * Copyright (C) 2012, 2015 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
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>
39 class ContentSecurityPolicy;
43 class NetscapePlugInStreamLoader;
44 class NetscapePlugInStreamLoaderClient;
45 struct NetworkTransactionInformation;
46 class NetworkLoadMetrics;
50 class ResourceRequest;
51 class ResourceResponse;
54 class SubresourceLoader;
58 class WEBCORE_EXPORT LoaderStrategy {
60 virtual void loadResource(Frame&, CachedResource&, ResourceRequest&&, const ResourceLoaderOptions&, CompletionHandler<void(RefPtr<SubresourceLoader>&&)>&&) = 0;
61 virtual void loadResourceSynchronously(FrameLoader&, unsigned long identifier, const ResourceRequest&, ClientCredentialPolicy, const FetchOptions&, const HTTPHeaderMap&, ResourceError&, ResourceResponse&, Vector<char>& data) = 0;
62 virtual void pageLoadCompleted(Page&) = 0;
64 virtual void remove(ResourceLoader*) = 0;
65 virtual void setDefersLoading(ResourceLoader&, bool) = 0;
66 virtual void crossOriginRedirectReceived(ResourceLoader*, const URL& redirectURL) = 0;
68 virtual void servePendingRequests(ResourceLoadPriority minimumPriority = ResourceLoadPriority::VeryLow) = 0;
69 virtual void suspendPendingRequests() = 0;
70 virtual void resumePendingRequests() = 0;
72 virtual bool usePingLoad() const { return true; }
73 using PingLoadCompletionHandler = WTF::Function<void(const ResourceError&, const ResourceResponse&)>;
74 virtual void startPingLoad(Frame&, ResourceRequest&, const HTTPHeaderMap& originalRequestHeaders, const FetchOptions&, ContentSecurityPolicyImposition, PingLoadCompletionHandler&& = { }) = 0;
76 using PreconnectCompletionHandler = WTF::Function<void(const ResourceError&)>;
77 virtual void preconnectTo(FrameLoader&, const URL&, StoredCredentialsPolicy, PreconnectCompletionHandler&&) = 0;
79 virtual void setCaptureExtraNetworkLoadMetricsEnabled(bool) = 0;
81 virtual bool isOnLine() const = 0;
82 virtual void addOnlineStateChangeListener(WTF::Function<void(bool)>&&) = 0;
84 virtual bool shouldPerformSecurityChecks() const { return false; }
85 virtual bool havePerformedSecurityChecks(const ResourceResponse&) const { return false; }
87 virtual ResourceResponse responseFromResourceLoadIdentifier(uint64_t resourceLoadIdentifier);
88 virtual Vector<NetworkTransactionInformation> intermediateLoadInformationFromResourceLoadIdentifier(uint64_t resourceLoadIdentifier);
89 virtual NetworkLoadMetrics networkMetricsFromResourceLoadIdentifier(uint64_t resourceLoadIdentifier);
91 // Used for testing only.
92 virtual Vector<uint64_t> ongoingLoads() const { return { }; }
95 virtual ~LoaderStrategy();
98 } // namespace WebCore