1/* 2 * Copyright (C) 2012 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#ifndef NetworkConnectionToWebProcess_h 27#define NetworkConnectionToWebProcess_h 28 29#if ENABLE(NETWORK_PROCESS) 30 31#include "BlockingResponseMap.h" 32#include "Connection.h" 33#include "NetworkConnectionToWebProcessMessages.h" 34#include <WebCore/ResourceLoadPriority.h> 35#include <wtf/HashSet.h> 36#include <wtf/RefCounted.h> 37 38namespace WebCore { 39class ResourceRequest; 40} 41 42namespace WebKit { 43 44class NetworkConnectionToWebProcess; 45class NetworkResourceLoader; 46class SyncNetworkResourceLoader; 47typedef uint64_t ResourceLoadIdentifier; 48 49class NetworkConnectionToWebProcess : public RefCounted<NetworkConnectionToWebProcess>, IPC::Connection::Client { 50public: 51 static PassRefPtr<NetworkConnectionToWebProcess> create(IPC::Connection::Identifier); 52 virtual ~NetworkConnectionToWebProcess(); 53 54 IPC::Connection* connection() const { return m_connection.get(); } 55 56 bool isSerialLoadingEnabled() const { return m_serialLoadingEnabled; } 57 58private: 59 NetworkConnectionToWebProcess(IPC::Connection::Identifier); 60 61 // IPC::Connection::Client 62 virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&); 63 virtual void didReceiveSyncMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&); 64 virtual void didClose(IPC::Connection*); 65 virtual void didReceiveInvalidMessage(IPC::Connection*, IPC::StringReference messageReceiverName, IPC::StringReference messageName); 66 67 // Message handlers. 68 void didReceiveNetworkConnectionToWebProcessMessage(IPC::Connection*, IPC::MessageDecoder&); 69 void didReceiveSyncNetworkConnectionToWebProcessMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&); 70 71 void scheduleResourceLoad(const NetworkResourceLoadParameters&); 72 void performSynchronousLoad(const NetworkResourceLoadParameters&, PassRefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>); 73 74 void removeLoadIdentifier(ResourceLoadIdentifier); 75 void setDefersLoading(ResourceLoadIdentifier, bool); 76 void crossOriginRedirectReceived(ResourceLoadIdentifier, const WebCore::URL& redirectURL); 77 void servePendingRequests(uint32_t resourceLoadPriority); 78 void setSerialLoadingEnabled(bool); 79 void startDownload(WebCore::SessionID, uint64_t downloadID, const WebCore::ResourceRequest&); 80 void convertMainResourceLoadToDownload(uint64_t mainResourceLoadIdentifier, uint64_t downloadID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&); 81 82 void cookiesForDOM(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, String& result); 83 void setCookiesFromDOM(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, const String&); 84 void cookiesEnabled(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, bool& result); 85 void cookieRequestHeaderFieldValue(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, String& result); 86 void getRawCookies(WebCore::SessionID, const WebCore::URL& firstParty, const WebCore::URL&, Vector<WebCore::Cookie>&); 87 void deleteCookie(WebCore::SessionID, const WebCore::URL&, const String& cookieName); 88 89 void registerFileBlobURL(const WebCore::URL&, const String& path, const SandboxExtension::Handle&, const String& contentType); 90 void registerBlobURL(const WebCore::URL&, Vector<WebCore::BlobPart>, const String& contentType); 91 void registerBlobURLFromURL(const WebCore::URL&, const WebCore::URL& srcURL); 92 void registerBlobURLForSlice(const WebCore::URL&, const WebCore::URL& srcURL, int64_t start, int64_t end); 93 void blobSize(const WebCore::URL&, uint64_t& resultSize); 94 void unregisterBlobURL(const WebCore::URL&); 95 96 RefPtr<IPC::Connection> m_connection; 97 98 HashMap<ResourceLoadIdentifier, RefPtr<NetworkResourceLoader>> m_networkResourceLoaders; 99 100 bool m_serialLoadingEnabled; 101}; 102 103} // namespace WebKit 104 105#endif // ENABLE(NETWORK_PROCESS) 106 107#endif // NetworkConnectionToWebProcess_h 108