Commit d06a84ec authored by andersca@apple.com's avatar andersca@apple.com

Add the ability to send messages to DownloadProxy objects

https://bugs.webkit.org/show_bug.cgi?id=49213

Reviewed by Adam Roben.

* DerivedSources.make:
* DerivedSources.pro:
Add Download.messages.in.

* Platform/CoreIPC/MessageID.h:
Add MessageClassDownloadProxy message class.

* Platform/CoreIPC/MessageSender.h:
Include Connection.h directly since it's required.

* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::didBegin):
(WebKit::DownloadProxy::didCreateDestination):
(WebKit::DownloadProxy::didFinish):
Add stubs.

* UIProcess/Downloads/DownloadProxy.messages.in: Added.

* UIProcess/WebContext.cpp:
(WebKit::WebContext::didReceiveMessage):
Handle DownloadProxy messages.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didReceiveMessage):
Hand DownloadProxy messages off to the context.

* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
Add new files.

* WebProcess/Downloads/Download.cpp:
(WebKit::Download::didBegin):
(WebKit::Download::didReceiveData):
(WebKit::Download::didCreateDestination):
(WebKit::Download::didFinish):
Send messages.

* WebProcess/Downloads/mac/DownloadMac.mm:
(-[WKDownloadAsDelegate download:didCreateDestination:]):
Call Download::didCreateDestination.

* win/WebKit2.vcproj:
Add new files.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71581 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 6a1f9591
2010-11-08 Anders Carlsson <andersca@apple.com>
Reviewed by Adam Roben.
Add the ability to send messages to DownloadProxy objects
https://bugs.webkit.org/show_bug.cgi?id=49213
* DerivedSources.make:
* DerivedSources.pro:
Add Download.messages.in.
* Platform/CoreIPC/MessageID.h:
Add MessageClassDownloadProxy message class.
* Platform/CoreIPC/MessageSender.h:
Include Connection.h directly since it's required.
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::didBegin):
(WebKit::DownloadProxy::didCreateDestination):
(WebKit::DownloadProxy::didFinish):
Add stubs.
* UIProcess/Downloads/DownloadProxy.messages.in: Added.
* UIProcess/WebContext.cpp:
(WebKit::WebContext::didReceiveMessage):
Handle DownloadProxy messages.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didReceiveMessage):
Hand DownloadProxy messages off to the context.
* WebKit2.pro:
* WebKit2.xcodeproj/project.pbxproj:
Add new files.
* WebProcess/Downloads/Download.cpp:
(WebKit::Download::didBegin):
(WebKit::Download::didReceiveData):
(WebKit::Download::didCreateDestination):
(WebKit::Download::didFinish):
Send messages.
* WebProcess/Downloads/mac/DownloadMac.mm:
(-[WKDownloadAsDelegate download:didCreateDestination:]):
Call Download::didCreateDestination.
* win/WebKit2.vcproj:
Add new files.
2010-11-08 Anders Carlsson <andersca@apple.com>
Reviewed by Adam Roben.
......
......@@ -5,10 +5,12 @@ VPATH = \
$(WebKit2)/WebProcess/WebPage \
$(WebKit2)/WebProcess \
$(WebKit2)/UIProcess \
$(WebKit2)/UIProcess/Downloads \
$(WebKit2)/UIProcess/Plugins \
#
MESSAGE_RECEIVERS = \
DownloadProxy \
NPObjectMessageReceiver \
PluginControllerProxy \
PluginProcess \
......
......@@ -85,9 +85,11 @@ VPATH = \
WebProcess/WebPage \
WebProcess \
UIProcess \
UIProcess/Downloads \
UIProcess/Plugins
MESSAGE_RECEIVERS = \
DownloadProxy.messages.in \
PluginControllerProxy.messages.in \
PluginProcess.messages.in \
PluginProcessProxy.messages.in \
......
......@@ -43,6 +43,7 @@ enum MessageClass {
// Messages sent by the web process to the UI process.
MessageClassDrawingAreaProxy,
MessageClassDownloadProxy,
MessageClassWebContext,
MessageClassWebInspectorProxy,
MessageClassWebPageProxy,
......
......@@ -27,10 +27,9 @@
#define MessageSender_h
#include <wtf/Assertions.h>
#include "Connection.h"
namespace CoreIPC {
class Connection;
template<typename T> class MessageSender {
public:
......
......@@ -25,6 +25,10 @@
#include "DownloadProxy.h"
#include "NotImplemented.h"
#include <wtf/text/WTFString.h>
#include <wtf/text/CString.h>
namespace WebKit {
static uint64_t generateDownloadID()
......@@ -54,5 +58,30 @@ void DownloadProxy::invalidate()
m_webContext = 0;
}
void DownloadProxy::didBegin()
{
if (!m_webContext)
return;
notImplemented();
}
void DownloadProxy::didCreateDestination(const String& path)
{
if (!m_webContext)
return;
printf("path: %s\n", path.ascii().data());
notImplemented();
}
void DownloadProxy::didFinish()
{
if (!m_webContext)
return;
notImplemented();
}
} // namespace WebKit
......@@ -27,8 +27,15 @@
#define DownloadProxy_h
#include "APIObject.h"
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
namespace CoreIPC {
class ArgumentDecoder;
class Connection;
class MessageID;
}
namespace WebKit {
class WebContext;
......@@ -44,11 +51,18 @@ public:
void invalidate();
void didReceiveDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
private:
explicit DownloadProxy(WebContext*);
virtual Type type() const { return APIType; }
// Message handlers.
void didBegin();
void didCreateDestination(const String& path);
void didFinish();
WebContext* m_webContext;
uint64_t m_downloadID;
};
......
# Copyright (C) 2010 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messages -> DownloadProxy {
DidBegin()
DidCreateDestination(WTF::String path)
DidFinish()
}
......@@ -410,8 +410,15 @@ uint64_t WebContext::createDownloadProxy()
return downloadID;
}
void WebContext::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
void WebContext::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
{
if (messageID.is<CoreIPC::MessageClassDownloadProxy>()) {
if (DownloadProxy* downloadProxy = m_downloads.get(arguments->destinationID()).get())
downloadProxy->didReceiveDownloadProxyMessage(connection, messageID, arguments);
return;
}
switch (messageID.get<WebContextMessage::Kind>()) {
case WebContextMessage::PostMessage: {
String messageName;
......
......@@ -247,7 +247,7 @@ void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC
didReceiveWebProcessProxyMessage(connection, messageID, arguments);
return;
}
if (messageID.is<CoreIPC::MessageClassWebContext>()) {
if (messageID.is<CoreIPC::MessageClassWebContext>() || messageID.is<CoreIPC::MessageClassDownloadProxy>()) {
m_context->didReceiveMessage(connection, messageID, arguments);
return;
}
......
......@@ -149,6 +149,7 @@ QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER"
DEFINES += BUILDING_QT__
WEBKIT2_GENERATED_HEADERS = \
$$OUTPUT_DIR/WebKit2/generated/DownloadProxyMessages.h \
$$OUTPUT_DIR/WebKit2/generated/PluginControllerProxyMessages.h \
$$OUTPUT_DIR/WebKit2/generated/PluginProcessMessages.h \
$$OUTPUT_DIR/WebKit2/generated/PluginProcessProxyMessages.h \
......@@ -161,6 +162,7 @@ WEBKIT2_GENERATED_HEADERS = \
$$OUTPUT_DIR/WebKit2/generated/WebProcessProxyMessages.h
WEBKIT2_GENERATED_SOURCES = \
$$OUTPUT_DIR/WebKit2/generated/DownloadProxyMessageReceiver.cpp \
$$OUTPUT_DIR/WebKit2/generated/PluginControllerProxyMessageReceiver.cpp \
$$OUTPUT_DIR/WebKit2/generated/PluginProcessMessageReceiver.cpp \
$$OUTPUT_DIR/WebKit2/generated/PluginProcessProxyMessageReceiver.cpp \
......
......@@ -159,6 +159,8 @@
1AADE6FF10D855FC00D3D63D /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */; };
1AB7D4CA1288AAA700CFD08C /* DownloadProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB7D4C81288AAA700CFD08C /* DownloadProxy.h */; };
1AB7D4CB1288AAA700CFD08C /* DownloadProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB7D4C91288AAA700CFD08C /* DownloadProxy.cpp */; };
1AB7D6191288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AB7D6171288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp */; };
1AB7D61A1288B9D900CFD08C /* DownloadProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AB7D6181288B9D900CFD08C /* DownloadProxyMessages.h */; };
1AC41AC71263C88300054E94 /* BinarySemaphore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AC41AC51263C88300054E94 /* BinarySemaphore.h */; };
1AC41AC81263C88300054E94 /* BinarySemaphore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC41AC61263C88300054E94 /* BinarySemaphore.cpp */; };
1AE117F611DBB30900981615 /* ProcessLauncher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE117F511DBB30900981615 /* ProcessLauncher.cpp */; };
......@@ -692,6 +694,9 @@
1AADE6FE10D855FC00D3D63D /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
1AB7D4C81288AAA700CFD08C /* DownloadProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadProxy.h; sourceTree = "<group>"; };
1AB7D4C91288AAA700CFD08C /* DownloadProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadProxy.cpp; sourceTree = "<group>"; };
1AB7D5E91288B8C000CFD08C /* DownloadProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DownloadProxy.messages.in; sourceTree = "<group>"; };
1AB7D6171288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DownloadProxyMessageReceiver.cpp; sourceTree = "<group>"; };
1AB7D6181288B9D900CFD08C /* DownloadProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadProxyMessages.h; sourceTree = "<group>"; };
1AC41AC51263C88300054E94 /* BinarySemaphore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BinarySemaphore.h; sourceTree = "<group>"; };
1AC41AC61263C88300054E94 /* BinarySemaphore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinarySemaphore.cpp; sourceTree = "<group>"; };
1AE117F511DBB30900981615 /* ProcessLauncher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessLauncher.cpp; sourceTree = "<group>"; };
......@@ -1436,6 +1441,7 @@
children = (
1AB7D4C91288AAA700CFD08C /* DownloadProxy.cpp */,
1AB7D4C81288AAA700CFD08C /* DownloadProxy.h */,
1AB7D5E91288B8C000CFD08C /* DownloadProxy.messages.in */,
);
path = Downloads;
sourceTree = "<group>";
......@@ -2026,6 +2032,8 @@
C0CE729D1247E71D00BC0EC4 /* Derived Sources */ = {
isa = PBXGroup;
children = (
1AB7D6171288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp */,
1AB7D6181288B9D900CFD08C /* DownloadProxyMessages.h */,
1A2D8437127F65D5001EB962 /* NPObjectMessageReceiverMessageReceiver.cpp */,
1A2D8438127F65D5001EB962 /* NPObjectMessageReceiverMessages.h */,
1A8EF96C1252AF6B00F7067F /* PluginControllerProxyMessageReceiver.cpp */,
......@@ -2327,6 +2335,7 @@
BCEE7AD112817988009827DA /* WebProcessProxyMessages.h in Headers */,
1A2D956F12848564001EB962 /* ChildProcess.h in Headers */,
1AB7D4CA1288AAA700CFD08C /* DownloadProxy.h in Headers */,
1AB7D61A1288B9D900CFD08C /* DownloadProxyMessages.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -2672,6 +2681,7 @@
BCEE7AD012817988009827DA /* WebProcessProxyMessageReceiver.cpp in Sources */,
1A2D957012848564001EB962 /* ChildProcess.cpp in Sources */,
1AB7D4CB1288AAA700CFD08C /* DownloadProxy.cpp in Sources */,
1AB7D6191288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -25,6 +25,10 @@
#include "Download.h"
#include "Connection.h"
#include "DownloadProxyMessages.h"
#include "WebProcess.h"
using namespace WebCore;
namespace WebKit {
......@@ -46,19 +50,28 @@ Download::~Download()
platformInvalidate();
}
CoreIPC::Connection* Download::connection() const
{
return WebProcess::shared().connection();
}
void Download::didBegin()
{
// FIXME: Implement.
send(Messages::DownloadProxy::DidBegin());
}
void Download::didReceiveData(uint64_t length)
{
// FIXME: Implement.
}
void Download::didCreateDestination(const String& path)
{
send(Messages::DownloadProxy::DidCreateDestination(path));
}
void Download::didFinish()
{
// FIXME: Implement.
send(Messages::DownloadProxy::DidFinish());
}
} // namespace WebKit
......@@ -37,23 +37,29 @@ class WKDownloadAsDelegate;
#endif
#endif
#include "MessageSender.h"
#include <WebCore/ResourceRequest.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassOwnPtr.h>
namespace WebKit {
class Download {
class Download : public CoreIPC::MessageSender<Download> {
WTF_MAKE_NONCOPYABLE(Download);
public:
static PassOwnPtr<Download> create(uint64_t downloadID, const WebCore::ResourceRequest&);
~Download();
// Used by MessageSender.
CoreIPC::Connection* connection() const;
uint64_t destinationID() const { return m_downloadID; }
void start();
void didBegin();
void didReceiveData(uint64_t length);
void didCreateDestination(const String& path);
void didFinish();
private:
......
......@@ -147,8 +147,8 @@ void Download::platformInvalidate()
- (void)download:(NSURLDownload *)download didCreateDestination:(NSString *)path
{
// FIXME: Implement.
notImplemented();
if (_download)
_download->didCreateDestination(path);
}
- (void)downloadDidFinish:(NSURLDownload *)download
......
......@@ -92,7 +92,7 @@ public:
static PassRefPtr<WebPage> create(uint64_t pageID, const WebPageCreationParameters&);
virtual ~WebPage();
// Used by MessageSenderWithDestinationID.
// Used by MessageSender.
CoreIPC::Connection* connection() const;
uint64_t destinationID() const { return pageID(); }
......
......@@ -2067,6 +2067,10 @@
RelativePath="..\UIProcess\Downloads\DownloadProxy.h"
>
</File>
<File
RelativePath="..\UIProcess\Downloads\DownloadProxy.messages.in"
>
</File>
</Filter>
<Filter
Name="Launcher"
......@@ -2428,6 +2432,14 @@
<Filter
Name="Derived Sources"
>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\DownloadProxyMessageReceiver.cpp"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\DownloadProxyMessages.h"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\WebInspectorMessageReceiver.cpp"
>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment