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 BlobRegistrationData; 45class NetworkConnectionToWebProcess; 46class NetworkResourceLoader; 47class SyncNetworkResourceLoader; 48typedef uint64_t ResourceLoadIdentifier; 49 50class NetworkConnectionToWebProcess : public RefCounted<NetworkConnectionToWebProcess>, CoreIPC::Connection::Client { 51public: 52 static PassRefPtr<NetworkConnectionToWebProcess> create(CoreIPC::Connection::Identifier); 53 virtual ~NetworkConnectionToWebProcess(); 54 55 CoreIPC::Connection* connection() const { return m_connection.get(); } 56 57 bool isSerialLoadingEnabled() const { return m_serialLoadingEnabled; } 58 59private: 60 NetworkConnectionToWebProcess(CoreIPC::Connection::Identifier); 61 62 // CoreIPC::Connection::Client 63 virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&); 64 virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&); 65 virtual void didClose(CoreIPC::Connection*); 66 virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference messageReceiverName, CoreIPC::StringReference messageName); 67 68 // Message handlers. 69 void didReceiveNetworkConnectionToWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&); 70 void didReceiveSyncNetworkConnectionToWebProcessMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&); 71 72 void scheduleResourceLoad(const NetworkResourceLoadParameters&); 73 void performSynchronousLoad(const NetworkResourceLoadParameters&, PassRefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply>); 74 75 void removeLoadIdentifier(ResourceLoadIdentifier); 76 void crossOriginRedirectReceived(ResourceLoadIdentifier, const WebCore::KURL& redirectURL); 77 void servePendingRequests(uint32_t resourceLoadPriority); 78 void setSerialLoadingEnabled(bool); 79 void startDownload(bool privateBrowsingEnabled, 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(bool privateBrowsingEnabled, const WebCore::KURL& firstParty, const WebCore::KURL&, String& result); 83 void setCookiesFromDOM(bool privateBrowsingEnabled, const WebCore::KURL& firstParty, const WebCore::KURL&, const String&); 84 void cookiesEnabled(bool privateBrowsingEnabled, const WebCore::KURL& firstParty, const WebCore::KURL&, bool& result); 85 void cookieRequestHeaderFieldValue(bool privateBrowsingEnabled, const WebCore::KURL& firstParty, const WebCore::KURL&, String& result); 86 void getRawCookies(bool privateBrowsingEnabled, const WebCore::KURL& firstParty, const WebCore::KURL&, Vector<WebCore::Cookie>&); 87 void deleteCookie(bool privateBrowsingEnabled, const WebCore::KURL&, const String& cookieName); 88 89 void registerBlobURL(const WebCore::KURL&, const BlobRegistrationData&); 90 void registerBlobURLFromURL(const WebCore::KURL&, const WebCore::KURL& srcURL); 91 void unregisterBlobURL(const WebCore::KURL&); 92 93 RefPtr<CoreIPC::Connection> m_connection; 94 95 HashMap<ResourceLoadIdentifier, RefPtr<NetworkResourceLoader>> m_networkResourceLoaders; 96 97 bool m_serialLoadingEnabled; 98}; 99 100} // namespace WebKit 101 102#endif // ENABLE(NETWORK_PROCESS) 103 104#endif // NetworkConnectionToWebProcess_h 105