Commit 9e948caa authored by levin@chromium.org's avatar levin@chromium.org

Unreviewed, rolling out r81144.

http://trac.webkit.org/changeset/81144
https://bugs.webkit.org/show_bug.cgi?id=56432

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2011-03-15
It broke the ui test
NPAPITesterBase.GetURLRedirectNotification. (Requested by
dave_levin on #webkit).

* public/WebURLLoader.h:
* src/AssociatedURLLoader.cpp:
(WebKit::AssociatedURLLoader::AssociatedURLLoader):
(WebKit::AssociatedURLLoader::~AssociatedURLLoader):
(WebKit::AssociatedURLLoader::loadSynchronously):
(WebKit::AssociatedURLLoader::loadAsynchronously):
(WebKit::AssociatedURLLoader::cancel):
(WebKit::AssociatedURLLoader::setDefersLoading):
(WebKit::AssociatedURLLoader::prepareRequest):
(WebKit::AssociatedURLLoader::willSendRequest):
(WebKit::AssociatedURLLoader::didSendData):
(WebKit::AssociatedURLLoader::didReceiveResponse):
(WebKit::AssociatedURLLoader::didDownloadData):
(WebKit::AssociatedURLLoader::didReceiveData):
(WebKit::AssociatedURLLoader::didReceiveCachedMetadata):
(WebKit::AssociatedURLLoader::didFinishLoading):
(WebKit::AssociatedURLLoader::didFail):
* src/AssociatedURLLoader.h:

git-svn-id: svn://svn.chromium.org/blink/trunk@81204 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent cb5815e4
2011-03-15 Sheriff Bot <webkit.review.bot@gmail.com>
Unreviewed, rolling out r81144.
http://trac.webkit.org/changeset/81144
https://bugs.webkit.org/show_bug.cgi?id=56432
It broke the ui test
NPAPITesterBase.GetURLRedirectNotification. (Requested by
dave_levin on #webkit).
* public/WebURLLoader.h:
* src/AssociatedURLLoader.cpp:
(WebKit::AssociatedURLLoader::AssociatedURLLoader):
(WebKit::AssociatedURLLoader::~AssociatedURLLoader):
(WebKit::AssociatedURLLoader::loadSynchronously):
(WebKit::AssociatedURLLoader::loadAsynchronously):
(WebKit::AssociatedURLLoader::cancel):
(WebKit::AssociatedURLLoader::setDefersLoading):
(WebKit::AssociatedURLLoader::prepareRequest):
(WebKit::AssociatedURLLoader::willSendRequest):
(WebKit::AssociatedURLLoader::didSendData):
(WebKit::AssociatedURLLoader::didReceiveResponse):
(WebKit::AssociatedURLLoader::didDownloadData):
(WebKit::AssociatedURLLoader::didReceiveData):
(WebKit::AssociatedURLLoader::didReceiveCachedMetadata):
(WebKit::AssociatedURLLoader::didFinishLoading):
(WebKit::AssociatedURLLoader::didFail):
* src/AssociatedURLLoader.h:
2011-03-15 Tony Chang <tony@chromium.org> 2011-03-15 Tony Chang <tony@chromium.org>
Reviewed by Adam Barth. Reviewed by Adam Barth.
......
/* /*
* Copyright (C) 2009, 2011 Google Inc. All rights reserved. * Copyright (C) 2009 Google Inc. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
...@@ -41,21 +41,6 @@ class WebURLRequest; ...@@ -41,21 +41,6 @@ class WebURLRequest;
class WebURLResponse; class WebURLResponse;
struct WebURLError; struct WebURLError;
enum WebCrossOriginRequestPolicy {
DenyCrossOriginRequests,
UseAccessControl,
AllowCrossOriginRequests
};
struct WebURLLoaderOptions {
WebURLLoaderOptions() : sniffContent(false), allowCredentials(false), forcePreflight(false), crossOriginRequestPolicy(DenyCrossOriginRequests) {}
bool sniffContent; // Whether to sniff content.
bool allowCredentials; // Whether to send HTTP credentials and cookies with the request.
bool forcePreflight; // If AccessControl is used, whether to force a preflight.
WebCrossOriginRequestPolicy crossOriginRequestPolicy;
};
class WebURLLoader { class WebURLLoader {
public: public:
// The WebURLLoader may be deleted in a call to its client. // The WebURLLoader may be deleted in a call to its client.
......
/* /*
* Copyright (C) 2010, 2011 Google Inc. All rights reserved. * Copyright (C) 2010 Google Inc. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
...@@ -31,203 +31,103 @@ ...@@ -31,203 +31,103 @@
#include "config.h" #include "config.h"
#include "AssociatedURLLoader.h" #include "AssociatedURLLoader.h"
#include "DocumentThreadableLoader.h"
#include "SubresourceLoader.h"
#include "ThreadableLoaderClient.h"
#include "WebApplicationCacheHost.h" #include "WebApplicationCacheHost.h"
#include "WebDataSource.h" #include "WebDataSource.h"
#include "WebFrameImpl.h" #include "WebFrameImpl.h"
#include "WebKit.h" #include "WebKit.h"
#include "WebKitClient.h" #include "WebKitClient.h"
#include "WebURLError.h"
#include "WebURLLoaderClient.h"
#include "WebURLRequest.h" #include "WebURLRequest.h"
#include "WrappedResourceRequest.h"
#include "WrappedResourceResponse.h"
using namespace WebCore;
using namespace WebKit;
using namespace WTF;
namespace WebKit { namespace WebKit {
// This class bridges the interface differences between WebCore and WebKit loader clients. AssociatedURLLoader::AssociatedURLLoader(PassRefPtr<WebFrameImpl> frameImpl)
// It forwards its ThreadableLoaderClient notifications to a WebURLLoaderClient. : m_frameImpl(frameImpl),
class AssociatedURLLoader::ClientAdapter : public ThreadableLoaderClient { m_realLoader(webKitClient()->createURLLoader()),
public: m_realClient(0)
static PassOwnPtr<ClientAdapter> create(AssociatedURLLoader*, WebURLLoaderClient*, bool /*downloadToFile*/);
virtual void didSendData(unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/);
virtual void willSendRequest(ResourceRequest& /*newRequest*/, const ResourceResponse& /*redirectResponse*/);
virtual void didReceiveResponse(const ResourceResponse&);
virtual void didReceiveData(const char*, int /*dataLength*/);
virtual void didReceiveCachedMetadata(const char*, int /*dataLength*/);
virtual void didFinishLoading(unsigned long /*identifier*/, double /*finishTime*/);
virtual void didFail(const ResourceError&);
// This method stops loading and releases the DocumentThreadableLoader as early as possible.
void clearClient() { m_client = 0; }
private:
ClientAdapter(AssociatedURLLoader*, WebURLLoaderClient*, bool /*downloadToFile*/);
AssociatedURLLoader* m_loader;
WebURLLoaderClient* m_client;
unsigned long m_downloadLength;
bool m_downloadToFile;
};
PassOwnPtr<AssociatedURLLoader::ClientAdapter> AssociatedURLLoader::ClientAdapter::create(AssociatedURLLoader* loader, WebURLLoaderClient* client, bool downloadToFile)
{ {
return adoptPtr(new ClientAdapter(loader, client, downloadToFile));
} }
AssociatedURLLoader::ClientAdapter::ClientAdapter(AssociatedURLLoader* loader, WebURLLoaderClient* client, bool downloadToFile) AssociatedURLLoader::~AssociatedURLLoader()
: m_loader(loader)
, m_client(client)
, m_downloadLength(0)
, m_downloadToFile(downloadToFile)
{ {
ASSERT(m_loader);
ASSERT(m_client);
} }
void AssociatedURLLoader::ClientAdapter::willSendRequest(ResourceRequest& newRequest, const ResourceResponse& redirectResponse) void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURLResponse& response, WebURLError& error, WebData& data)
{ {
if (!m_client) ASSERT(!m_realClient);
return;
WebURLRequest requestCopy(request);
prepareRequest(requestCopy);
WrappedResourceRequest wrappedNewRequest(newRequest); m_realLoader->loadSynchronously(requestCopy, response, error, data);
WrappedResourceResponse wrappedRedirectResponse(redirectResponse);
m_client->willSendRequest(m_loader, wrappedNewRequest, wrappedRedirectResponse);
} }
void AssociatedURLLoader::ClientAdapter::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebURLLoaderClient* client)
{ {
if (!m_client) ASSERT(!m_realClient);
return;
m_client->didSendData(m_loader, bytesSent, totalBytesToBeSent); WebURLRequest requestCopy(request);
} prepareRequest(requestCopy);
void AssociatedURLLoader::ClientAdapter::didReceiveResponse(const ResourceResponse& response) m_realClient = client;
{ m_realLoader->loadAsynchronously(requestCopy, this);
WrappedResourceResponse wrappedResponse(response);
m_client->didReceiveResponse(m_loader, wrappedResponse);
} }
void AssociatedURLLoader::ClientAdapter::didReceiveData(const char* data, int lengthReceived) void AssociatedURLLoader::cancel()
{ {
if (!m_client) m_realLoader->cancel();
return;
m_client->didReceiveData(m_loader, data, lengthReceived);
m_downloadLength += lengthReceived;
} }
void AssociatedURLLoader::ClientAdapter::didReceiveCachedMetadata(const char* data, int lengthReceived) void AssociatedURLLoader::setDefersLoading(bool defersLoading)
{ {
if (!m_client) m_realLoader->setDefersLoading(defersLoading);
return;
m_client->didReceiveCachedMetadata(m_loader, data, lengthReceived);
} }
void AssociatedURLLoader::ClientAdapter::didFinishLoading(unsigned long identifier, double finishTime) void AssociatedURLLoader::prepareRequest(WebURLRequest& request)
{ {
if (!m_client) WebApplicationCacheHost* applicationCacheHost = m_frameImpl->dataSource()->applicationCacheHost();
return; if (applicationCacheHost)
applicationCacheHost->willStartSubResourceRequest(request);
if (m_downloadToFile) { m_frameImpl->dispatchWillSendRequest(request);
int downloadLength = m_downloadLength <= INT_MAX ? m_downloadLength : INT_MAX;
m_client->didDownloadData(m_loader, downloadLength);
// While the client could have cancelled, continue, since the load finished.
}
m_client->didFinishLoading(m_loader, finishTime);
} }
void AssociatedURLLoader::ClientAdapter::didFail(const ResourceError& error) void AssociatedURLLoader::willSendRequest(WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirectResponse)
{ {
if (!m_client) m_realClient->willSendRequest(this, newRequest, redirectResponse);
return;
WebURLError webError(error);
m_client->didFail(m_loader, webError);
} }
AssociatedURLLoader::AssociatedURLLoader(PassRefPtr<WebFrameImpl> frameImpl) void AssociatedURLLoader::didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
: m_frameImpl(frameImpl)
, m_client(0)
{ {
ASSERT(m_frameImpl); m_realClient->didSendData(this, bytesSent, totalBytesToBeSent);
m_options.sniffContent = false;
m_options.allowCredentials = true;
m_options.forcePreflight = false;
m_options.crossOriginRequestPolicy = AllowCrossOriginRequests; // TODO(bbudge) Default should be DenyCrossOriginRequests, but this would break some tests.
} }
AssociatedURLLoader::AssociatedURLLoader(PassRefPtr<WebFrameImpl> frameImpl, const WebURLLoaderOptions& options) void AssociatedURLLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& response)
: m_frameImpl(frameImpl)
, m_options(options)
, m_client(0)
{ {
ASSERT(m_frameImpl); m_realClient->didReceiveResponse(this, response);
} }
AssociatedURLLoader::~AssociatedURLLoader() void AssociatedURLLoader::didDownloadData(WebURLLoader*, int dataLength)
{ {
if (m_clientAdapter) m_realClient->didDownloadData(this, dataLength);
m_clientAdapter->clearClient();
} }
#define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, webcore_name) \ void AssociatedURLLoader::didReceiveData(WebURLLoader*, const char* data, int dataLength)
COMPILE_ASSERT(static_cast<int>(WebKit::webkit_name) == static_cast<int>(WebCore::webcore_name), mismatching_enums)
COMPILE_ASSERT_MATCHING_ENUM(DenyCrossOriginRequests, DenyCrossOriginRequests);
COMPILE_ASSERT_MATCHING_ENUM(UseAccessControl, UseAccessControl);
COMPILE_ASSERT_MATCHING_ENUM(AllowCrossOriginRequests, AllowCrossOriginRequests);
void AssociatedURLLoader::loadSynchronously(const WebURLRequest& request, WebURLResponse& response, WebURLError& error, WebData& data)
{ {
ASSERT(0); // Synchronous loading is not supported. m_realClient->didReceiveData(this, data, dataLength);
} }
void AssociatedURLLoader::loadAsynchronously(const WebURLRequest& request, WebURLLoaderClient* client) void AssociatedURLLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength)
{ {
ASSERT(!m_client); m_realClient->didReceiveCachedMetadata(this, data, dataLength);
m_client = client;
ASSERT(m_client);
ThreadableLoaderOptions options;
options.sendLoadCallbacks = true; // Always send callbacks.
options.sniffContent = m_options.sniffContent;
options.allowCredentials = m_options.allowCredentials;
options.forcePreflight = m_options.forcePreflight;
options.crossOriginRequestPolicy = static_cast<WebCore::CrossOriginRequestPolicy>(m_options.crossOriginRequestPolicy);
const ResourceRequest& webcoreRequest = request.toResourceRequest();
Document* webcoreDocument = m_frameImpl->frame()->document();
m_clientAdapter = ClientAdapter::create(this, m_client, request.downloadToFile());
m_loader = DocumentThreadableLoader::create(webcoreDocument, m_clientAdapter.get(), webcoreRequest, options);
} }
void AssociatedURLLoader::cancel() void AssociatedURLLoader::didFinishLoading(WebURLLoader*, double finishTime)
{ {
if (m_loader) { m_realClient->didFinishLoading(this, finishTime);
m_clientAdapter->clearClient();
m_loader->cancel();
}
} }
void AssociatedURLLoader::setDefersLoading(bool defersLoading) void AssociatedURLLoader::didFail(WebURLLoader*, const WebURLError& error)
{ {
if (m_loader) m_realClient->didFail(this, error);
m_loader->setDefersLoading(defersLoading);
} }
} // namespace WebKit } // namespace WebKit
/* /*
* Copyright (C) 2010, 2011 Google Inc. All rights reserved. * Copyright (C) 2010 Google Inc. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
...@@ -32,22 +32,20 @@ ...@@ -32,22 +32,20 @@
#define AssociatedURLLoader_h #define AssociatedURLLoader_h
#include "WebURLLoader.h" #include "WebURLLoader.h"
#include <wtf/Noncopyable.h> #include "WebURLLoaderClient.h"
#include <wtf/OwnPtr.h> #include <wtf/OwnPtr.h>
#include <wtf/RefPtr.h> #include <wtf/RefPtr.h>
namespace WebCore { class DocumentThreadableLoader; }
namespace WebKit { namespace WebKit {
class WebFrameImpl; class WebFrameImpl;
// This class is used to implement WebFrame::createAssociatedURLLoader. // This class is used to implement WebFrame::createAssociatedURLLoader.
class AssociatedURLLoader : public WebURLLoader { // FIXME: Implement in terms of WebCore::SubresourceLoader.
WTF_MAKE_NONCOPYABLE(AssociatedURLLoader); class AssociatedURLLoader : public WebURLLoader,
public WebURLLoaderClient {
public: public:
AssociatedURLLoader(PassRefPtr<WebFrameImpl>); AssociatedURLLoader(PassRefPtr<WebFrameImpl>);
AssociatedURLLoader(PassRefPtr<WebFrameImpl>, const WebURLLoaderOptions&);
~AssociatedURLLoader(); ~AssociatedURLLoader();
// WebURLLoader methods: // WebURLLoader methods:
...@@ -56,15 +54,22 @@ public: ...@@ -56,15 +54,22 @@ public:
virtual void cancel(); virtual void cancel();
virtual void setDefersLoading(bool); virtual void setDefersLoading(bool);
private: // WebURLLoaderClient methods:
virtual void willSendRequest(WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirectResponse);
virtual void didSendData(WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&);
virtual void didDownloadData(WebURLLoader*, int dataLength);
virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength);
virtual void didReceiveCachedMetadata(WebURLLoader*, const char* data, int dataLength);
virtual void didFinishLoading(WebURLLoader*, double finishTime);
virtual void didFail(WebURLLoader*, const WebURLError&);
class ClientAdapter; private:
void prepareRequest(WebURLRequest&);
RefPtr<WebFrameImpl> m_frameImpl; RefPtr<WebFrameImpl> m_frameImpl;
WebURLLoaderOptions m_options; OwnPtr<WebURLLoader> m_realLoader;
WebURLLoaderClient* m_client; WebURLLoaderClient* m_realClient;
OwnPtr<ClientAdapter> m_clientAdapter;
RefPtr<WebCore::DocumentThreadableLoader> m_loader;
}; };
} // namespace WebKit } // namespace WebKit
......
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