1/*
2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Igalia S.L.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "config.h"
22#include "LegacyCustomProtocolManagerProxy.h"
23
24#include "APICustomProtocolManagerClient.h"
25#include "LegacyCustomProtocolManagerMessages.h"
26#include "LegacyCustomProtocolManagerProxyMessages.h"
27#include "NetworkProcessProxy.h"
28#include "WebProcessPool.h"
29#include <WebCore/ResourceRequest.h>
30
31namespace WebKit {
32
33LegacyCustomProtocolManagerProxy::LegacyCustomProtocolManagerProxy(NetworkProcessProxy& networkProcessProxy)
34 : m_networkProcessProxy(networkProcessProxy)
35{
36 m_networkProcessProxy.addMessageReceiver(Messages::LegacyCustomProtocolManagerProxy::messageReceiverName(), *this);
37}
38
39LegacyCustomProtocolManagerProxy::~LegacyCustomProtocolManagerProxy()
40{
41 m_networkProcessProxy.removeMessageReceiver(Messages::LegacyCustomProtocolManagerProxy::messageReceiverName());
42 invalidate();
43}
44
45void LegacyCustomProtocolManagerProxy::startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest& request)
46{
47 m_networkProcessProxy.processPool().customProtocolManagerClient().startLoading(*this, customProtocolID, request);
48}
49
50void LegacyCustomProtocolManagerProxy::stopLoading(uint64_t customProtocolID)
51{
52 m_networkProcessProxy.processPool().customProtocolManagerClient().stopLoading(*this, customProtocolID);
53}
54
55void LegacyCustomProtocolManagerProxy::invalidate()
56{
57 m_networkProcessProxy.processPool().customProtocolManagerClient().invalidate(*this);
58}
59
60void LegacyCustomProtocolManagerProxy::wasRedirectedToRequest(uint64_t customProtocolID, const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& redirectResponse)
61{
62 m_networkProcessProxy.send(Messages::LegacyCustomProtocolManager::WasRedirectedToRequest(customProtocolID, request, redirectResponse), 0);
63}
64
65void LegacyCustomProtocolManagerProxy::didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse& response, uint32_t cacheStoragePolicy)
66{
67 m_networkProcessProxy.send(Messages::LegacyCustomProtocolManager::DidReceiveResponse(customProtocolID, response, cacheStoragePolicy), 0);
68}
69
70void LegacyCustomProtocolManagerProxy::didLoadData(uint64_t customProtocolID, const IPC::DataReference& data)
71{
72 m_networkProcessProxy.send(Messages::LegacyCustomProtocolManager::DidLoadData(customProtocolID, data), 0);
73}
74
75void LegacyCustomProtocolManagerProxy::didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError& error)
76{
77 m_networkProcessProxy.send(Messages::LegacyCustomProtocolManager::DidFailWithError(customProtocolID, error), 0);
78}
79
80void LegacyCustomProtocolManagerProxy::didFinishLoading(uint64_t customProtocolID)
81{
82 m_networkProcessProxy.send(Messages::LegacyCustomProtocolManager::DidFinishLoading(customProtocolID), 0);
83}
84
85} // namespace WebKit
86