2 * Copyright (C) 2013 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.
26 #ifndef SchedulableLoader_h
27 #define SchedulableLoader_h
29 #include "HostRecord.h"
30 #include <WebCore/ResourceLoaderOptions.h>
31 #include <WebCore/ResourceRequest.h>
32 #include <wtf/MainThread.h>
33 #include <wtf/RefCounted.h>
35 #if ENABLE(NETWORK_PROCESS)
39 class NetworkConnectionToWebProcess;
40 class NetworkResourceLoadParameters;
41 class SandboxExtension;
43 class SchedulableLoader : public RefCounted<SchedulableLoader> {
45 virtual ~SchedulableLoader();
47 ResourceLoadIdentifier identifier() const { return m_identifier; }
48 uint64_t webPageID() const { return m_webPageID; }
49 uint64_t webFrameID() const { return m_webFrameID; }
50 const WebCore::ResourceRequest& request() const { return m_request; }
51 WebCore::ResourceLoadPriority priority() const { return m_priority; }
52 WebCore::ContentSniffingPolicy contentSniffingPolicy() const { return m_contentSniffingPolicy; }
53 WebCore::StoredCredentials allowStoredCredentials() const { return m_allowStoredCredentials; }
54 WebCore::ClientCredentialPolicy clientCredentialPolicy() const { return m_clientCredentialPolicy; }
55 bool inPrivateBrowsingMode() const { return m_inPrivateBrowsingMode; }
56 bool isLoadingMainResource() const { return m_isLoadingMainResource; }
58 NetworkConnectionToWebProcess* connectionToWebProcess() const { return m_connection.get(); }
59 virtual void connectionToWebProcessDidClose() = 0;
61 virtual void start() = 0;
63 virtual bool isSynchronous() { return false; }
65 void setHostRecord(HostRecord* hostRecord) { ASSERT(isMainThread()); m_hostRecord = hostRecord; }
66 HostRecord* hostRecord() const { ASSERT(isMainThread()); return m_hostRecord.get(); }
69 SchedulableLoader(const NetworkResourceLoadParameters&, NetworkConnectionToWebProcess*);
71 void consumeSandboxExtensions();
72 void invalidateSandboxExtensions();
74 bool shouldClearReferrerOnHTTPSToHTTPRedirect() const { return m_shouldClearReferrerOnHTTPSToHTTPRedirect; }
77 ResourceLoadIdentifier m_identifier;
79 uint64_t m_webFrameID;
80 WebCore::ResourceRequest m_request;
81 WebCore::ResourceLoadPriority m_priority;
82 WebCore::ContentSniffingPolicy m_contentSniffingPolicy;
83 WebCore::StoredCredentials m_allowStoredCredentials;
84 WebCore::ClientCredentialPolicy m_clientCredentialPolicy;
85 bool m_inPrivateBrowsingMode;
86 bool m_shouldClearReferrerOnHTTPSToHTTPRedirect;
87 bool m_isLoadingMainResource;
89 Vector<RefPtr<SandboxExtension> > m_requestBodySandboxExtensions;
90 Vector<RefPtr<SandboxExtension> > m_resourceSandboxExtensions;
92 RefPtr<NetworkConnectionToWebProcess> m_connection;
94 RefPtr<HostRecord> m_hostRecord;
99 #endif // ENABLE(NETWORK_PROCESS)
101 #endif // SchedulableLoader_h