summaryrefslogtreecommitdiffstats
path: root/webkit/api
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/api')
-rw-r--r--webkit/api/public/WebHTTPBody.h57
-rw-r--r--webkit/api/public/WebHTTPHeaderVisitor.h44
-rw-r--r--webkit/api/public/WebKitClient.h12
-rw-r--r--webkit/api/public/WebNonCopyable.h49
-rw-r--r--webkit/api/public/WebURL.h8
-rw-r--r--webkit/api/public/WebURLError.h15
-rw-r--r--webkit/api/public/WebURLLoader.h14
-rw-r--r--webkit/api/public/WebURLLoaderClient.h24
-rw-r--r--webkit/api/public/WebURLRequest.h84
-rw-r--r--webkit/api/public/WebURLResponse.h83
-rw-r--r--webkit/api/src/ResourceHandle.cpp304
-rw-r--r--webkit/api/src/WebDragData.cpp11
-rw-r--r--webkit/api/src/WebHTTPBody.cpp124
-rw-r--r--webkit/api/src/WebURLError.cpp69
-rw-r--r--webkit/api/src/WebURLRequest.cpp246
-rw-r--r--webkit/api/src/WebURLRequestPrivate.h53
-rw-r--r--webkit/api/src/WebURLResponse.cpp259
-rw-r--r--webkit/api/src/WebURLResponsePrivate.h50
-rw-r--r--webkit/api/src/WrappedResourceRequest.h67
-rw-r--r--webkit/api/src/WrappedResourceResponse.h68
20 files changed, 1527 insertions, 114 deletions
diff --git a/webkit/api/public/WebHTTPBody.h b/webkit/api/public/WebHTTPBody.h
index 1a4f49c..59a008d 100644
--- a/webkit/api/public/WebHTTPBody.h
+++ b/webkit/api/public/WebHTTPBody.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -31,23 +31,62 @@
#ifndef WebHTTPBody_h
#define WebHTTPBody_h
-#error "This header file is still a work in progress; do not include!"
-
#include "WebData.h"
+#include "WebNonCopyable.h"
#include "WebString.h"
-#include "WebVector.h"
+
+#if WEBKIT_IMPLEMENTATION
+namespace WebCore { class FormData; }
+namespace WTF { template <typename T> class PassRefPtr; }
+#endif
namespace WebKit {
+ class WebHTTPBodyPrivate;
- struct WebHTTPBody {
+ class WebHTTPBody : public WebNonCopyable {
+ public:
struct Element {
enum { TypeData, TypeFile } type;
WebData data;
- WebString fileName;
+ WebString filePath;
};
- WebVector<Element> elements;
+
+ ~WebHTTPBody() { reset(); }
+
+ WebHTTPBody() : m_private(0) { }
+
+ bool isNull() const { return m_private == 0; }
+
+ WEBKIT_API void initialize();
+ WEBKIT_API void reset();
+
+ // Returns the number of elements comprising the http body.
+ WEBKIT_API size_t elementCount() const;
+
+ // Sets the values of the element at the given index. Returns false if
+ // index is out of bounds.
+ WEBKIT_API bool elementAt(size_t index, Element&) const;
+
+ // Append to the list of elements.
+ WEBKIT_API void appendData(const WebData&);
+ WEBKIT_API void appendFile(const WebString&);
+
+ // Identifies a particular form submission instance. A value of 0 is
+ // used to indicate an unspecified identifier.
+ WEBKIT_API long long identifier() const;
+ WEBKIT_API void setIdentifier(long long);
+
+#if WEBKIT_IMPLEMENTATION
+ void rebind(WTF::PassRefPtr<WebCore::FormData>);
+ operator WTF::PassRefPtr<WebCore::FormData>() const;
+#endif
+
+ private:
+ void assign(WebHTTPBodyPrivate*);
+ WebHTTPBodyPrivate* m_private;
};
+
} // namespace WebKit
#endif
diff --git a/webkit/api/public/WebHTTPHeaderVisitor.h b/webkit/api/public/WebHTTPHeaderVisitor.h
new file mode 100644
index 0000000..b61d3da
--- /dev/null
+++ b/webkit/api/public/WebHTTPHeaderVisitor.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef WebHTTPHeaderVisitor_h
+#define WebHTTPHeaderVisitor_h
+
+namespace WebKit {
+ class WebString;
+
+ class WebHTTPHeaderVisitor {
+ public:
+ virtual void visitHeader(const WebString& name, const WebString& value) = 0;
+ };
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/public/WebKitClient.h b/webkit/api/public/WebKitClient.h
index 5b136d5..7dc158a 100644
--- a/webkit/api/public/WebKitClient.h
+++ b/webkit/api/public/WebKitClient.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -42,6 +42,7 @@ namespace WebKit {
class WebString;
class WebThemeEngine;
class WebURL;
+ class WebURLLoader;
struct WebPluginInfo;
template <typename T> class WebVector;
@@ -71,7 +72,7 @@ namespace WebKit {
// hash must have been generated by calling VisitedLinkHash().
virtual bool isLinkVisited(unsigned long long linkHash) = 0;
-
+
// Network -------------------------------------------------------------
virtual void setCookies(
@@ -81,6 +82,9 @@ namespace WebKit {
// A suggestion to prefetch IP information for the given hostname.
virtual void prefetchHostName(const WebString&) = 0;
+ // Returns a new WebURLLoader instance.
+ virtual WebURLLoader* createURLLoader() = 0;
+
// Plugins -------------------------------------------------------------
diff --git a/webkit/api/public/WebNonCopyable.h b/webkit/api/public/WebNonCopyable.h
new file mode 100644
index 0000000..df4b482
--- /dev/null
+++ b/webkit/api/public/WebNonCopyable.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef WebNonCopyable_h
+#define WebNonCopyable_h
+
+namespace WebKit {
+
+ // A base class to extend from if you do not support copying.
+ class WebNonCopyable {
+ protected:
+ WebNonCopyable() { }
+ ~WebNonCopyable() { }
+
+ private:
+ WebNonCopyable(const WebNonCopyable&);
+ WebNonCopyable& operator=(const WebNonCopyable&);
+ };
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/public/WebURL.h b/webkit/api/public/WebURL.h
index aad9281..ae833f5 100644
--- a/webkit/api/public/WebURL.h
+++ b/webkit/api/public/WebURL.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -128,7 +128,7 @@ namespace WebKit {
operator GURL() const
{
- return GURL(m_spec.data(), m_spec.length(), m_parsed, m_isValid);
+ return isNull() ? GURL() : GURL(m_spec.data(), m_spec.length(), m_parsed, m_isValid);
}
#endif
diff --git a/webkit/api/public/WebURLError.h b/webkit/api/public/WebURLError.h
index 6332b5e..d1a92e9 100644
--- a/webkit/api/public/WebURLError.h
+++ b/webkit/api/public/WebURLError.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -31,8 +31,6 @@
#ifndef WebURLError_h
#define WebURLError_h
-#error "This header file is still a work in progress; do not include!"
-
#include "WebString.h"
#include "WebURL.h"
@@ -48,9 +46,10 @@ namespace WebKit {
// string as it will just be passed via callbacks to the consumer.
WebString domain;
- // A numeric reason for the error. WebKit does not care about the
- // value of this field as it will just be passed via callbacks to the
- // consumer.
+ // A numeric error code detailing the reason for this error. A value
+ // of 0 means no error. WebKit does not interpret the meaning of other
+ // values and normally just forwards this error information back to the
+ // embedder (see for example WebFrameClient).
int reason;
// The url that failed to load.
diff --git a/webkit/api/public/WebURLLoader.h b/webkit/api/public/WebURLLoader.h
index 721fe60..e9027c4 100644
--- a/webkit/api/public/WebURLLoader.h
+++ b/webkit/api/public/WebURLLoader.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -31,16 +31,14 @@
#ifndef WebURLLoader_h
#define WebURLLoader_h
-#error "This header file is still a work in progress; do not include!"
-
#include "WebCommon.h"
namespace WebKit {
- class WebCString;
- class WebURLError;
+ class WebData;
class WebURLLoaderClient;
class WebURLRequest;
class WebURLResponse;
+ struct WebURLError;
class WebURLLoader {
public:
@@ -50,7 +48,7 @@ namespace WebKit {
// caller upon completion. There is no mechanism to interrupt a
// synchronous load!!
virtual void loadSynchronously(const WebURLRequest&,
- WebURLResponse&, WebURLError&, WebCString& data) = 0;
+ WebURLResponse&, WebURLError&, WebData& data) = 0;
// Load the request asynchronously, sending notifications to the given
// client. The client will receive no further notifications if the
diff --git a/webkit/api/public/WebURLLoaderClient.h b/webkit/api/public/WebURLLoaderClient.h
index 3a0a761..5e7d4e2 100644
--- a/webkit/api/public/WebURLLoaderClient.h
+++ b/webkit/api/public/WebURLLoaderClient.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -31,33 +31,35 @@
#ifndef WebURLLoaderClient_h
#define WebURLLoaderClient_h
-#error "This header file is still a work in progress; do not include!"
-
namespace WebKit {
+ class WebURLLoader;
+ class WebURLRequest;
+ class WebURLResponse;
+ struct WebURLError;
class WebURLLoaderClient {
public:
// Called when following a redirect. |newRequest| contains the request
// generated by the redirect. The client may modify |newRequest|.
virtual void willSendRequest(
- WebURLRequest& newRequest, const WebURLResponse& redirectResponse) = 0;
+ WebURLLoader*, WebURLRequest& newRequest, const WebURLResponse& redirectResponse) = 0;
// Called to report upload progress. The bytes reported correspond to
// the HTTP message body.
virtual void didSendData(
- unsigned long long bytesSent, unsigned long long totalBytesToBeSent) = 0;
+ WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) = 0;
// Called when response headers are received.
- virtual void didReceiveResponse(const WebURLResponse&) = 0;
+ virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&) = 0;
// Called when a chunk of response data is received.
- virtual void didReceiveData(const char* data, int dataLength, int totalDataLength) = 0;
+ virtual void didReceiveData(WebURLLoader*, const char* data, int dataLength, long long totalDataLength) = 0;
// Called when the load completes successfully.
- virtual void didFinishLoading() = 0;
+ virtual void didFinishLoading(WebURLLoader*) = 0;
// Called when the load completes with an error.
- virtual void didFail(const WebURLError&) = 0;
+ virtual void didFail(WebURLLoader*, const WebURLError&) = 0;
};
} // namespace WebKit
diff --git a/webkit/api/public/WebURLRequest.h b/webkit/api/public/WebURLRequest.h
index c7b9bec..5e4ee07 100644
--- a/webkit/api/public/WebURLRequest.h
+++ b/webkit/api/public/WebURLRequest.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -31,14 +31,17 @@
#ifndef WebURLRequest_h
#define WebURLRequest_h
-#error "This header file is still a work in progress; do not include!"
-
#include "WebCommon.h"
#include "WebHTTPBody.h"
+#if defined(WEBKIT_IMPLEMENTATION)
+namespace WebCore { struct ResourceRequest; }
+#endif
+
namespace WebKit {
class WebCString;
class WebHTTPBody;
+ class WebHTTPHeaderVisitor;
class WebString;
class WebURL;
class WebURLRequestPrivate;
@@ -66,58 +69,75 @@ namespace WebKit {
WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); }
WebURLRequest& operator=(const WebURLRequest& r) { assign(r); return *this; }
+ explicit WebURLRequest(const WebURL& url) : m_private(0)
+ {
+ initialize();
+ setURL(url);
+ }
+
WEBKIT_API void initialize();
WEBKIT_API void reset();
WEBKIT_API void assign(const WebURLRequest&);
bool isNull() const { return m_private == 0; }
- WEBKIT_API WebURL url() const = 0;
- WEBKIT_API void setURL(const WebURL&) = 0;
+ WEBKIT_API WebURL url() const;
+ WEBKIT_API void setURL(const WebURL&);
// Used to implement third-party cookie blocking.
- WEBKIT_API WebURL firstPartyForCookies() const = 0;
- WEBKIT_API void setFirstPartyForCookies(const WebURL&) = 0;
+ WEBKIT_API WebURL firstPartyForCookies() const;
+ WEBKIT_API void setFirstPartyForCookies(const WebURL&);
+
+ WEBKIT_API CachePolicy cachePolicy() const;
+ WEBKIT_API void setCachePolicy(CachePolicy);
- WEBKIT_API CachePolicy cachePolicy() const = 0;
- WEBKIT_API void setCachePolicy(CachePolicy) = 0;
+ WEBKIT_API WebString httpMethod() const;
+ WEBKIT_API void setHTTPMethod(const WebString&);
- WEBKIT_API WebString httpMethod() const = 0;
- WEBKIT_API void setHTTPMethod(const WebString&) = 0;
+ WEBKIT_API WebString httpHeaderField(const WebString& name) const;
+ WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value);
+ WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value);
+ WEBKIT_API void clearHTTPHeaderField(const WebString& name);
+ WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
- WEBKIT_API WebString httpHeaderField(const WebString& name) const = 0;
- WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value) = 0;
- WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value) = 0;
- WEBKIT_API void clearHTTPHeaderField(const WebString& name) = 0;
+ WEBKIT_API const WebHTTPBody& httpBody() const;
+ WEBKIT_API void setHTTPBody(const WebHTTPBody&);
- WEBKIT_API bool hasHTTPBody() const = 0;
- WEBKIT_API void httpBody(WebHTTPBody&) const = 0;
- WEBKIT_API void setHTTPBody(const WebHTTPBody&) = 0;
- WEBKIT_API void appendToHTTPBody(const WebHTTPBody::Element&) = 0;
-
// Controls whether upload progress events are generated when a request
// has a body.
- WEBKIT_API bool reportUploadProgress() const = 0;
- WEBKIT_API void setReportUploadProgress(bool) = 0;
+ WEBKIT_API bool reportUploadProgress() const;
+ WEBKIT_API void setReportUploadProgress(bool);
- WEBKIT_API TargetType targetType() const = 0;
- WEBKIT_API void setTargetType(const TargetType&) = 0;
+ WEBKIT_API TargetType targetType() const;
+ WEBKIT_API void setTargetType(TargetType);
// A consumer controlled value intended to be used to identify the
// requestor.
- WEBKIT_API int requestorID() const = 0;
- WEBKIT_API void setRequestorID(int) = 0;
+ WEBKIT_API int requestorID() const;
+ WEBKIT_API void setRequestorID(int);
// A consumer controlled value intended to be used to identify the
// process of the requestor.
- WEBKIT_API int requestorProcessID() const = 0;
- WEBKIT_API void setRequestorProcessID(int) = 0;
+ WEBKIT_API int requestorProcessID() const;
+ WEBKIT_API void setRequestorProcessID(int);
+
+ // Allows the request to be matched up with its app cache context.
+ WEBKIT_API int appCacheContextID() const;
+ WEBKIT_API void setAppCacheContextID(int id);
// A consumer controlled value intended to be used to record opaque
// security info related to this request.
// FIXME: This really doesn't belong here!
- WEBKIT_API WebCString securityInfo() const = 0;
- WEBKIT_API void setSecurityInfo(const WebCString&) = 0;
+ WEBKIT_API WebCString securityInfo() const;
+ WEBKIT_API void setSecurityInfo(const WebCString&);
+
+#if defined(WEBKIT_IMPLEMENTATION)
+ WebCore::ResourceRequest& toMutableResourceRequest();
+ const WebCore::ResourceRequest& toResourceRequest() const;
+#endif
+
+ protected:
+ void assign(WebURLRequestPrivate*);
private:
WebURLRequestPrivate* m_private;
diff --git a/webkit/api/public/WebURLResponse.h b/webkit/api/public/WebURLResponse.h
index 30d2641..2e1429f 100644
--- a/webkit/api/public/WebURLResponse.h
+++ b/webkit/api/public/WebURLResponse.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -31,12 +31,15 @@
#ifndef WebURLResponse_h
#define WebURLResponse_h
-#error "This header file is still a work in progress; do not include!"
-
#include "WebCommon.h"
+#if defined(WEBKIT_IMPLEMENTATION)
+namespace WebCore { class ResourceResponse; }
+#endif
+
namespace WebKit {
class WebCString;
+ class WebHTTPHeaderVisitor;
class WebString;
class WebURL;
class WebURLResponsePrivate;
@@ -49,51 +52,69 @@ namespace WebKit {
WebURLResponse(const WebURLResponse& r) : m_private(0) { assign(r); }
WebURLResponse& operator=(const WebURLResponse& r) { assign(r); return *this; }
+ explicit WebURLResponse(const WebURL& url) : m_private(0)
+ {
+ initialize();
+ setURL(url);
+ }
+
WEBKIT_API void initialize();
WEBKIT_API void reset();
WEBKIT_API void assign(const WebURLResponse&);
bool isNull() const { return m_private == 0; }
- WEBKIT_API WebURL url() const = 0;
- WEBKIT_API void setURL(const WebURL&) = 0;
+ WEBKIT_API WebURL url() const;
+ WEBKIT_API void setURL(const WebURL&);
- WEBKIT_API WebString mimeType() const = 0;
- WEBKIT_API void setMIMEType(const WebString&) = 0;
+ WEBKIT_API WebString mimeType() const;
+ WEBKIT_API void setMIMEType(const WebString&);
- WEBKIT_API long long expectedContentLength() const = 0;
- WEBKIT_API void setExpectedContentLength(long long) = 0;
+ WEBKIT_API long long expectedContentLength() const;
+ WEBKIT_API void setExpectedContentLength(long long);
- WEBKIT_API WebString textEncodingName() const = 0;
- WEBKIT_API void setTextEncodingName(const WebString&) = 0;
+ WEBKIT_API WebString textEncodingName() const;
+ WEBKIT_API void setTextEncodingName(const WebString&);
- WEBKIT_API WebString suggestedFileName() const = 0;
- WEBKIT_API void setSuggestedFileName(const WebString&) = 0;
+ WEBKIT_API WebString suggestedFileName() const;
+ WEBKIT_API void setSuggestedFileName(const WebString&);
- WEBKIT_API int httpStatusCode() const = 0;
- WEBKIT_API void setHTTPStatusCode(int) = 0;
+ WEBKIT_API int httpStatusCode() const;
+ WEBKIT_API void setHTTPStatusCode(int);
- WEBKIT_API WebString httpStatusText() const = 0;
- WEBKIT_API void setHTTPStatusText(const WebString&) = 0;
+ WEBKIT_API WebString httpStatusText() const;
+ WEBKIT_API void setHTTPStatusText(const WebString&);
- WEBKIT_API WebString httpHeaderField(const WebString& name) const = 0;
- WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value) = 0;
- WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value) = 0;
- WEBKIT_API void clearHTTPHeaderField(const WebString& name) = 0;
+ WEBKIT_API WebString httpHeaderField(const WebString& name) const;
+ WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value);
+ WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value);
+ WEBKIT_API void clearHTTPHeaderField(const WebString& name);
+ WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
- WEBKIT_API double expirationDate() const = 0;
- WEBKIT_API void setExpirationDate(double) = 0;
+ WEBKIT_API double expirationDate() const;
+ WEBKIT_API void setExpirationDate(double);
- WEBKIT_API double lastModifiedDate() const = 0;
- WEBKIT_API void setLastModifiedDate(double) = 0;
+ WEBKIT_API double lastModifiedDate() const;
+ WEBKIT_API void setLastModifiedDate(double);
- WEBKIT_API bool isContentFiltered() const = 0;
- WEBKIT_API void setIsContentFiltered(bool) = 0;
+ WEBKIT_API bool isContentFiltered() const;
+ WEBKIT_API void setIsContentFiltered(bool);
+
+ WEBKIT_API long long appCacheID() const;
+ WEBKIT_API void setAppCacheID(long long);
// A consumer controlled value intended to be used to record opaque
// security info related to this request.
- WEBKIT_API WebCString securityInfo() const = 0;
- WEBKIT_API void setSecurityInfo(const WebCString&) = 0;
+ WEBKIT_API WebCString securityInfo() const;
+ WEBKIT_API void setSecurityInfo(const WebCString&);
+
+#if defined(WEBKIT_IMPLEMENTATION)
+ WebCore::ResourceResponse& toMutableResourceResponse();
+ const WebCore::ResourceResponse& toResourceResponse() const;
+#endif
+
+ protected:
+ void assign(WebURLResponsePrivate*);
private:
WebURLResponsePrivate* m_private;
diff --git a/webkit/api/src/ResourceHandle.cpp b/webkit/api/src/ResourceHandle.cpp
new file mode 100644
index 0000000..7b4043c
--- /dev/null
+++ b/webkit/api/src/ResourceHandle.cpp
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "ResourceHandle.h"
+
+#include "WebKit.h"
+#include "WebKitClient.h"
+#include "WebURLError.h"
+#include "WebURLLoader.h"
+#include "WebURLLoaderClient.h"
+#include "WebURLRequest.h"
+#include "WebURLResponse.h"
+#include "WrappedResourceRequest.h"
+#include "WrappedResourceResponse.h"
+
+#include "MainThread.h"
+#include "ResourceHandleClient.h"
+#include "ResourceRequest.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+static void deleteLoader(void* param)
+{
+ delete static_cast<WebURLLoader*>(param);
+}
+
+static void deleteLoaderSoon(WebURLLoader* loader)
+{
+ callOnMainThread(deleteLoader, loader);
+}
+
+// ResourceHandleInternal -----------------------------------------------------
+
+class ResourceHandleInternal : public WebURLLoaderClient {
+public:
+ ResourceHandleInternal(const ResourceRequest& request, ResourceHandleClient* client)
+ : m_request(request)
+ , m_owner(0)
+ , m_client(client)
+ {
+ }
+
+ ~ResourceHandleInternal();
+
+ void start();
+ void cancel();
+ void setDefersLoading(bool);
+
+ // WebURLLoaderClient methods:
+ virtual void willSendRequest(WebURLLoader*, WebURLRequest&, const WebURLResponse&);
+ virtual void didSendData(
+ WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
+ virtual void didReceiveResponse(WebURLLoader*, const WebURLResponse&);
+ virtual void didReceiveData(
+ WebURLLoader*, const char* data, int dataLength, long long totalDataLength);
+ virtual void didFinishLoading(WebURLLoader*);
+ virtual void didFail(WebURLLoader*, const WebURLError&);
+
+ ResourceRequest m_request;
+ ResourceHandle* m_owner;
+ ResourceHandleClient* m_client;
+ OwnPtr<WebURLLoader> m_loader;
+};
+
+ResourceHandleInternal::~ResourceHandleInternal()
+{
+ if (m_loader.get()) {
+ m_loader->cancel();
+ // The loader is typically already on the stack at this point, so we
+ // need to defer its destruction.
+ // FIXME: We should probably add a "dispose" method on WebURLLoader and
+ // push this deferred destruction logic into the loader implementation.
+ deleteLoaderSoon(m_loader.release());
+ }
+}
+
+void ResourceHandleInternal::start()
+{
+ m_loader.set(webKitClient()->createURLLoader());
+ ASSERT(m_loader.get());
+
+ WrappedResourceRequest wrappedRequest(m_request);
+ m_loader->loadAsynchronously(wrappedRequest, this);
+}
+
+void ResourceHandleInternal::cancel()
+{
+ m_loader->cancel();
+
+ // Do not make any further calls to the client.
+ m_client = 0;
+}
+
+void ResourceHandleInternal::setDefersLoading(bool value)
+{
+ m_loader->setDefersLoading(value);
+}
+
+void ResourceHandleInternal::willSendRequest(
+ WebURLLoader*, WebURLRequest& request, const WebURLResponse& response)
+{
+ ASSERT(m_client);
+ ASSERT(!request.isNull());
+ ASSERT(!response.isNull());
+ m_client->willSendRequest(m_owner, request.toMutableResourceRequest(), response.toResourceResponse());
+}
+
+void ResourceHandleInternal::didSendData(
+ WebURLLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
+{
+ ASSERT(m_client);
+ m_client->didSendData(m_owner, bytesSent, totalBytesToBeSent);
+}
+
+void ResourceHandleInternal::didReceiveResponse(WebURLLoader*, const WebURLResponse& response)
+{
+ ASSERT(m_client);
+ ASSERT(!response.isNull());
+ m_client->didReceiveResponse(m_owner, response.toResourceResponse());
+}
+
+void ResourceHandleInternal::didReceiveData(
+ WebURLLoader*, const char* data, int dataLength, long long totalDataLength)
+{
+ ASSERT(m_client);
+
+ // FIXME: ResourceHandleClient::didReceiveData should take a 'long long'
+ int lengthReceived = static_cast<int>(totalDataLength);
+ if (lengthReceived != totalDataLength) // overflow occurred
+ lengthReceived = -1;
+
+ m_client->didReceiveData(m_owner, data, dataLength, lengthReceived);
+}
+
+void ResourceHandleInternal::didFinishLoading(WebURLLoader*)
+{
+ ASSERT(m_client);
+ m_client->didFinishLoading(m_owner);
+}
+
+void ResourceHandleInternal::didFail(WebURLLoader*, const WebURLError& error)
+{
+ ASSERT(m_client);
+ m_client->didFail(m_owner, error);
+}
+
+// ResourceHandle -------------------------------------------------------------
+
+ResourceHandle::ResourceHandle(const ResourceRequest& request,
+ ResourceHandleClient* client,
+ bool defersLoading,
+ bool shouldContentSniff,
+ bool mightDownloadFromHandle)
+ : d(new ResourceHandleInternal(request, client))
+{
+ d->m_owner = this;
+
+ // FIXME: Figure out what to do with the bool params.
+}
+
+PassRefPtr<ResourceHandle> ResourceHandle::create(const ResourceRequest& request,
+ ResourceHandleClient* client,
+ Frame* deprecated,
+ bool defersLoading,
+ bool shouldContentSniff,
+ bool mightDownloadFromHandle)
+{
+ RefPtr<ResourceHandle> newHandle = adoptRef(new ResourceHandle(
+ request, client, defersLoading, shouldContentSniff, mightDownloadFromHandle));
+
+ if (newHandle->start(deprecated))
+ return newHandle.release();
+
+ return 0;
+}
+
+const ResourceRequest& ResourceHandle::request() const
+{
+ return d->m_request;
+}
+
+ResourceHandleClient* ResourceHandle::client() const
+{
+ return d->m_client;
+}
+
+void ResourceHandle::setClient(ResourceHandleClient* client)
+{
+ d->m_client = client;
+}
+
+void ResourceHandle::setDefersLoading(bool value)
+{
+ d->setDefersLoading(value);
+}
+
+bool ResourceHandle::start(Frame* deprecated)
+{
+ d->start();
+ return true;
+}
+
+void ResourceHandle::clearAuthentication()
+{
+}
+
+void ResourceHandle::cancel()
+{
+ d->cancel();
+}
+
+ResourceHandle::~ResourceHandle()
+{
+ d->m_owner = 0;
+}
+
+PassRefPtr<SharedBuffer> ResourceHandle::bufferedData()
+{
+ return 0;
+}
+
+bool ResourceHandle::loadsBlocked()
+{
+ return false; // This seems to be related to sync XMLHttpRequest...
+}
+
+// static
+bool ResourceHandle::supportsBufferedData()
+{
+ return false; // The loader will buffer manually if it needs to.
+}
+
+// static
+void ResourceHandle::loadResourceSynchronously(const ResourceRequest& request,
+ StoredCredentials unused,
+ ResourceError& error,
+ ResourceResponse& response,
+ Vector<char>& data,
+ Frame* deprecated)
+{
+ OwnPtr<WebURLLoader> loader(webKitClient()->createURLLoader());
+ ASSERT(loader.get());
+
+ WrappedResourceRequest requestIn(request);
+ WrappedResourceResponse responseOut(response);
+ WebURLError errorOut;
+ WebData dataOut;
+
+ loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut);
+
+ error = errorOut;
+ data.clear();
+ data.append(dataOut.data(), dataOut.size());
+}
+
+// static
+bool ResourceHandle::willLoadFromCache(ResourceRequest& request)
+{
+ // This method is used to determine if a POST request can be repeated from
+ // cache, but you cannot really know until you actually try to read from the
+ // cache. Even if we checked now, something else could come along and wipe
+ // out the cache entry by the time we fetch it.
+ //
+ // So, we always say yes here, which allows us to generate an ERR_CACHE_MISS
+ // if the request cannot be serviced from cache. We force the 'DontLoad'
+ // cache policy at this point to ensure that we never hit the network for
+ // this request.
+ //
+ ASSERT(request.httpMethod() == "POST");
+ request.setCachePolicy(ReturnCacheDataDontLoad);
+ return true;
+}
+
+} // namespace WebCore
diff --git a/webkit/api/src/WebDragData.cpp b/webkit/api/src/WebDragData.cpp
index 426ceea..044c6ea 100644
--- a/webkit/api/src/WebDragData.cpp
+++ b/webkit/api/src/WebDragData.cpp
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google 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:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -53,10 +53,7 @@ void WebDragData::initialize()
void WebDragData::reset()
{
- if (m_private) {
- m_private->deref();
- m_private = 0;
- }
+ assign(0);
}
void WebDragData::assign(const WebDragData& other)
diff --git a/webkit/api/src/WebHTTPBody.cpp b/webkit/api/src/WebHTTPBody.cpp
new file mode 100644
index 0000000..69875e7
--- /dev/null
+++ b/webkit/api/src/WebHTTPBody.cpp
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "WebHTTPBody.h"
+
+#include "FormData.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class WebHTTPBodyPrivate : public FormData {
+};
+
+void WebHTTPBody::initialize()
+{
+ assign(static_cast<WebHTTPBodyPrivate*>(FormData::create().releaseRef()));
+}
+
+void WebHTTPBody::reset()
+{
+ assign(0);
+}
+
+size_t WebHTTPBody::elementCount() const
+{
+ return m_private->elements().size();
+}
+
+bool WebHTTPBody::elementAt(size_t index, Element& result) const
+{
+ if (index >= m_private->elements().size())
+ return false;
+
+ const FormDataElement& element = m_private->elements()[index];
+
+ switch (element.m_type) {
+ case FormDataElement::data:
+ result.type = Element::TypeData;
+ result.data.assign(element.m_data.data(), element.m_data.size());
+ result.filePath.reset();
+ break;
+ case FormDataElement::encodedFile:
+ result.type = Element::TypeFile;
+ result.data.reset();
+ result.filePath = element.m_filename;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+
+ return true;
+}
+
+void WebHTTPBody::appendData(const WebData& data)
+{
+ // FIXME: FormDataElement::m_data should be a SharedBuffer<char>. Then we
+ // could avoid this buffer copy.
+ m_private->appendData(data.data(), data.size());
+}
+
+void WebHTTPBody::appendFile(const WebString& filePath)
+{
+ m_private->appendFile(filePath);
+}
+
+long long WebHTTPBody::identifier() const
+{
+ return m_private->identifier();
+}
+
+void WebHTTPBody::setIdentifier(long long identifier)
+{
+ return m_private->setIdentifier(identifier);
+}
+
+void WebHTTPBody::rebind(PassRefPtr<FormData> formData)
+{
+ assign(static_cast<WebHTTPBodyPrivate*>(formData.releaseRef()));
+}
+
+WebHTTPBody::operator PassRefPtr<FormData>() const
+{
+ return m_private;
+}
+
+void WebHTTPBody::assign(WebHTTPBodyPrivate* p)
+{
+ // p is already ref'd for us by the caller
+ if (m_private)
+ m_private->deref();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/WebURLError.cpp b/webkit/api/src/WebURLError.cpp
new file mode 100644
index 0000000..cd7d72d
--- /dev/null
+++ b/webkit/api/src/WebURLError.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "WebURLError.h"
+
+#include "CString.h"
+#include "KURL.h"
+#include "ResourceError.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebURLError::WebURLError(const ResourceError& error)
+{
+ *this = error;
+}
+
+WebURLError& WebURLError::operator=(const ResourceError& error)
+{
+ if (error.isNull())
+ *this = WebURLError();
+ else {
+ domain = error.domain();
+ reason = error.errorCode();
+ unreachableURL = KURL(error.failingURL());
+ }
+ return *this;
+}
+
+WebURLError::operator ResourceError() const
+{
+ if (reason == 0)
+ return ResourceError();
+ CString spec = unreachableURL.spec();
+ return ResourceError(domain, reason,
+ String::fromUTF8(spec.data(), spec.length()),
+ String());
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/WebURLRequest.cpp b/webkit/api/src/WebURLRequest.cpp
new file mode 100644
index 0000000..66483f9
--- /dev/null
+++ b/webkit/api/src/WebURLRequest.cpp
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "WebURLRequest.h"
+
+#include "WebHTTPHeaderVisitor.h"
+#include "WebURL.h"
+#include "WebURLRequestPrivate.h"
+
+#include "ResourceRequest.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// The standard implementation of WebURLRequestPrivate, which maintains
+// ownership of a ResourceRequest instance.
+class WebURLRequestPrivateImpl : public WebURLRequestPrivate {
+public:
+ WebURLRequestPrivateImpl()
+ {
+ m_resourceRequest = &m_resourceRequestAllocation;
+ }
+
+ WebURLRequestPrivateImpl(const WebURLRequestPrivate* p)
+ : m_resourceRequestAllocation(*p->m_resourceRequest)
+ {
+ m_resourceRequest = &m_resourceRequestAllocation;
+ }
+
+ virtual void dispose() { delete this; }
+
+ ResourceRequest m_resourceRequestAllocation;
+};
+
+void WebURLRequest::initialize()
+{
+ assign(new WebURLRequestPrivateImpl());
+}
+
+void WebURLRequest::reset()
+{
+ assign(0);
+}
+
+void WebURLRequest::assign(const WebURLRequest& r)
+{
+ assign(r.m_private ? new WebURLRequestPrivateImpl(r.m_private) : 0);
+}
+
+WebURL WebURLRequest::url() const
+{
+ return m_private->m_resourceRequest->url();
+}
+
+void WebURLRequest::setURL(const WebURL& url)
+{
+ m_private->m_resourceRequest->setURL(url);
+}
+
+WebURL WebURLRequest::firstPartyForCookies() const
+{
+ return m_private->m_resourceRequest->firstPartyForCookies();
+}
+
+void WebURLRequest::setFirstPartyForCookies(const WebURL& firstPartyForCookies)
+{
+ m_private->m_resourceRequest->setFirstPartyForCookies(firstPartyForCookies);
+}
+
+WebURLRequest::CachePolicy WebURLRequest::cachePolicy() const
+{
+ return static_cast<WebURLRequest::CachePolicy>(
+ m_private->m_resourceRequest->cachePolicy());
+}
+
+void WebURLRequest::setCachePolicy(CachePolicy cachePolicy)
+{
+ m_private->m_resourceRequest->setCachePolicy(
+ static_cast<ResourceRequestCachePolicy>(cachePolicy));
+}
+
+WebString WebURLRequest::httpMethod() const
+{
+ return m_private->m_resourceRequest->httpMethod();
+}
+
+void WebURLRequest::setHTTPMethod(const WebString& httpMethod)
+{
+ m_private->m_resourceRequest->setHTTPMethod(httpMethod);
+}
+
+WebString WebURLRequest::httpHeaderField(const WebString& name) const
+{
+ return m_private->m_resourceRequest->httpHeaderField(String(name));
+}
+
+void WebURLRequest::setHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceRequest->setHTTPHeaderField(String(name), value);
+}
+
+void WebURLRequest::addHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceRequest->addHTTPHeaderField(String(name), value);
+}
+
+void WebURLRequest::clearHTTPHeaderField(const WebString& name)
+{
+ // FIXME: Add a clearHTTPHeaderField method to ResourceRequest.
+ const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields();
+ const_cast<HTTPHeaderMap*>(&map)->remove(String(name));
+}
+
+void WebURLRequest::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const
+{
+ const HTTPHeaderMap& map = m_private->m_resourceRequest->httpHeaderFields();
+ for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ visitor->visitHeader(String(it->first), it->second);
+}
+
+const WebHTTPBody& WebURLRequest::httpBody() const
+{
+ m_private->m_httpBody.rebind(m_private->m_resourceRequest->httpBody());
+ return m_private->m_httpBody;
+}
+
+void WebURLRequest::setHTTPBody(const WebHTTPBody& httpBody)
+{
+ m_private->m_resourceRequest->setHTTPBody(httpBody);
+ m_private->m_httpBody.rebind(0); // Free memory of the old body
+}
+
+bool WebURLRequest::reportUploadProgress() const
+{
+ return m_private->m_resourceRequest->reportUploadProgress();
+}
+
+void WebURLRequest::setReportUploadProgress(bool reportUploadProgress)
+{
+ m_private->m_resourceRequest->setReportUploadProgress(reportUploadProgress);
+}
+
+WebURLRequest::TargetType WebURLRequest::targetType() const
+{
+ return static_cast<TargetType>(m_private->m_resourceRequest->targetType());
+}
+
+void WebURLRequest::setTargetType(TargetType targetType)
+{
+ m_private->m_resourceRequest->setTargetType(
+ static_cast<ResourceRequest::TargetType>(targetType));
+}
+
+int WebURLRequest::requestorID() const
+{
+ return m_private->m_resourceRequest->requestorID();
+}
+
+void WebURLRequest::setRequestorID(int requestorID)
+{
+ m_private->m_resourceRequest->setRequestorID(requestorID);
+}
+
+int WebURLRequest::requestorProcessID() const
+{
+ return m_private->m_resourceRequest->requestorProcessID();
+}
+
+void WebURLRequest::setRequestorProcessID(int requestorProcessID)
+{
+ m_private->m_resourceRequest->setRequestorProcessID(requestorProcessID);
+}
+
+int WebURLRequest::appCacheContextID() const
+{
+ return m_private->m_resourceRequest->appCacheContextID();
+}
+
+void WebURLRequest::setAppCacheContextID(int appCacheContextID)
+{
+ m_private->m_resourceRequest->setAppCacheContextID(appCacheContextID);
+}
+
+WebCString WebURLRequest::securityInfo() const
+{
+ return m_private->m_resourceRequest->securityInfo();
+}
+
+void WebURLRequest::setSecurityInfo(const WebCString& securityInfo)
+{
+ m_private->m_resourceRequest->setSecurityInfo(securityInfo);
+}
+
+ResourceRequest& WebURLRequest::toMutableResourceRequest()
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceRequest);
+
+ return *m_private->m_resourceRequest;
+}
+
+const ResourceRequest& WebURLRequest::toResourceRequest() const
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceRequest);
+
+ return *m_private->m_resourceRequest;
+}
+
+void WebURLRequest::assign(WebURLRequestPrivate* p)
+{
+ if (m_private)
+ m_private->dispose();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/WebURLRequestPrivate.h b/webkit/api/src/WebURLRequestPrivate.h
new file mode 100644
index 0000000..57ef3d1
--- /dev/null
+++ b/webkit/api/src/WebURLRequestPrivate.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef WebURLRequestPrivate_h
+#define WebURLRequestPrivate_h
+
+#include "WebHTTPBody.h"
+
+namespace WebCore { struct ResourceRequest; }
+
+namespace WebKit {
+
+ class WebURLRequestPrivate {
+ public:
+ WebURLRequestPrivate() : m_resourceRequest(0) { }
+
+ // Called by WebURLRequest when it no longer needs this object.
+ virtual void dispose() = 0;
+
+ WebCore::ResourceRequest* m_resourceRequest;
+ WebHTTPBody m_httpBody;
+ };
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/src/WebURLResponse.cpp b/webkit/api/src/WebURLResponse.cpp
new file mode 100644
index 0000000..64c9463
--- /dev/null
+++ b/webkit/api/src/WebURLResponse.cpp
@@ -0,0 +1,259 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "config.h"
+#include "WebURLResponse.h"
+
+#include "WebHTTPHeaderVisitor.h"
+#include "WebString.h"
+#include "WebURL.h"
+#include "WebURLResponsePrivate.h"
+
+#include "ResourceResponse.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+// The standard implementation of WebURLResponsePrivate, which maintains
+// ownership of a ResourceResponse instance.
+class WebURLResponsePrivateImpl : public WebURLResponsePrivate {
+public:
+ WebURLResponsePrivateImpl()
+ {
+ m_resourceResponse = &m_resourceResponseAllocation;
+ }
+
+ WebURLResponsePrivateImpl(const WebURLResponsePrivate* p)
+ : m_resourceResponseAllocation(*p->m_resourceResponse)
+ {
+ m_resourceResponse = &m_resourceResponseAllocation;
+ }
+
+ virtual void dispose() { delete this; }
+
+ ResourceResponse m_resourceResponseAllocation;
+};
+
+void WebURLResponse::initialize()
+{
+ assign(new WebURLResponsePrivateImpl());
+}
+
+void WebURLResponse::reset()
+{
+ assign(0);
+}
+
+void WebURLResponse::assign(const WebURLResponse& r)
+{
+ assign(r.m_private ? new WebURLResponsePrivateImpl(r.m_private) : 0);
+}
+
+WebURL WebURLResponse::url() const
+{
+ return m_private->m_resourceResponse->url();
+}
+
+void WebURLResponse::setURL(const WebURL& url)
+{
+ m_private->m_resourceResponse->setURL(url);
+}
+
+WebString WebURLResponse::mimeType() const
+{
+ return m_private->m_resourceResponse->mimeType();
+}
+
+void WebURLResponse::setMIMEType(const WebString& mimeType)
+{
+ m_private->m_resourceResponse->setMimeType(mimeType);
+}
+
+long long WebURLResponse::expectedContentLength() const
+{
+ return m_private->m_resourceResponse->expectedContentLength();
+}
+
+void WebURLResponse::setExpectedContentLength(long long expectedContentLength)
+{
+ m_private->m_resourceResponse->setExpectedContentLength(expectedContentLength);
+}
+
+WebString WebURLResponse::textEncodingName() const
+{
+ return m_private->m_resourceResponse->textEncodingName();
+}
+
+void WebURLResponse::setTextEncodingName(const WebString& textEncodingName)
+{
+ m_private->m_resourceResponse->setTextEncodingName(textEncodingName);
+}
+
+WebString WebURLResponse::suggestedFileName() const
+{
+ return m_private->m_resourceResponse->suggestedFilename();
+}
+
+void WebURLResponse::setSuggestedFileName(const WebString& suggestedFileName)
+{
+ m_private->m_resourceResponse->setSuggestedFilename(suggestedFileName);
+}
+
+int WebURLResponse::httpStatusCode() const
+{
+ return m_private->m_resourceResponse->httpStatusCode();
+}
+
+void WebURLResponse::setHTTPStatusCode(int httpStatusCode)
+{
+ m_private->m_resourceResponse->setHTTPStatusCode(httpStatusCode);
+}
+
+WebString WebURLResponse::httpStatusText() const
+{
+ return m_private->m_resourceResponse->httpStatusText();
+}
+
+void WebURLResponse::setHTTPStatusText(const WebString& httpStatusText)
+{
+ m_private->m_resourceResponse->setHTTPStatusText(httpStatusText);
+}
+
+WebString WebURLResponse::httpHeaderField(const WebString& name) const
+{
+ return m_private->m_resourceResponse->httpHeaderField(String(name));
+}
+
+void WebURLResponse::setHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ m_private->m_resourceResponse->setHTTPHeaderField(String(name), value);
+}
+
+void WebURLResponse::addHTTPHeaderField(const WebString& name, const WebString& value)
+{
+ // FIXME: Add an addHTTPHeaderField method to ResourceResponse.
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ String valueStr(value);
+ pair<HTTPHeaderMap::iterator, bool> result =
+ const_cast<HTTPHeaderMap*>(&map)->add(String(name), valueStr);
+ if (!result.second)
+ result.first->second += ", " + valueStr;
+}
+
+void WebURLResponse::clearHTTPHeaderField(const WebString& name)
+{
+ // FIXME: Add a clearHTTPHeaderField method to ResourceResponse.
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ const_cast<HTTPHeaderMap*>(&map)->remove(String(name));
+}
+
+void WebURLResponse::visitHTTPHeaderFields(WebHTTPHeaderVisitor* visitor) const
+{
+ const HTTPHeaderMap& map = m_private->m_resourceResponse->httpHeaderFields();
+ for (HTTPHeaderMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ visitor->visitHeader(String(it->first), it->second);
+}
+
+double WebURLResponse::expirationDate() const
+{
+ return static_cast<double>(m_private->m_resourceResponse->expirationDate());
+}
+
+void WebURLResponse::setExpirationDate(double expirationDate)
+{
+ m_private->m_resourceResponse->setExpirationDate(static_cast<time_t>(expirationDate));
+}
+
+double WebURLResponse::lastModifiedDate() const
+{
+ return static_cast<double>(m_private->m_resourceResponse->lastModifiedDate());
+}
+
+void WebURLResponse::setLastModifiedDate(double lastModifiedDate)
+{
+ m_private->m_resourceResponse->setLastModifiedDate(static_cast<time_t>(lastModifiedDate));
+}
+
+bool WebURLResponse::isContentFiltered() const
+{
+ return m_private->m_resourceResponse->isContentFiltered();
+}
+
+void WebURLResponse::setIsContentFiltered(bool isContentFiltered)
+{
+ m_private->m_resourceResponse->setIsContentFiltered(isContentFiltered);
+}
+
+long long WebURLResponse::appCacheID() const
+{
+ return m_private->m_resourceResponse->getAppCacheID();
+}
+
+void WebURLResponse::setAppCacheID(long long appCacheID)
+{
+ m_private->m_resourceResponse->setAppCacheID(appCacheID);
+}
+
+WebCString WebURLResponse::securityInfo() const
+{
+ // FIXME: getSecurityInfo is misnamed.
+ return m_private->m_resourceResponse->getSecurityInfo();
+}
+
+void WebURLResponse::setSecurityInfo(const WebCString& securityInfo)
+{
+ m_private->m_resourceResponse->setSecurityInfo(securityInfo);
+}
+
+ResourceResponse& WebURLResponse::toMutableResourceResponse()
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceResponse);
+
+ return *m_private->m_resourceResponse;
+}
+
+const ResourceResponse& WebURLResponse::toResourceResponse() const
+{
+ ASSERT(m_private);
+ ASSERT(m_private->m_resourceResponse);
+
+ return *m_private->m_resourceResponse;
+}
+
+void WebURLResponse::assign(WebURLResponsePrivate* p)
+{
+ if (m_private)
+ m_private->dispose();
+ m_private = p;
+}
+
+} // namespace WebKit
diff --git a/webkit/api/src/WebURLResponsePrivate.h b/webkit/api/src/WebURLResponsePrivate.h
new file mode 100644
index 0000000..d421c1a
--- /dev/null
+++ b/webkit/api/src/WebURLResponsePrivate.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#ifndef WebURLResponsePrivate_h
+#define WebURLResponsePrivate_h
+
+namespace WebCore { class ResourceResponse; }
+
+namespace WebKit {
+
+ class WebURLResponsePrivate {
+ public:
+ WebURLResponsePrivate() : m_resourceResponse(0) { }
+
+ // Called by WebURLResponse when it no longer needs this object.
+ virtual void dispose() = 0;
+
+ WebCore::ResourceResponse* m_resourceResponse;
+ };
+
+} // namespace WebKit
+
+#endif
diff --git a/webkit/api/src/WrappedResourceRequest.h b/webkit/api/src/WrappedResourceRequest.h
new file mode 100644
index 0000000..58188c1
--- /dev/null
+++ b/webkit/api/src/WrappedResourceRequest.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "WebURLRequestPrivate.h"
+
+namespace WebKit {
+
+ class WrappedResourceRequest : public WebURLRequest {
+ public:
+ ~WrappedResourceRequest()
+ {
+ reset(); // Need to drop reference to m_handle
+ }
+
+ WrappedResourceRequest(WebCore::ResourceRequest& resourceRequest)
+ {
+ bind(&resourceRequest);
+ }
+
+ WrappedResourceRequest(const WebCore::ResourceRequest& resourceRequest)
+ {
+ bind(const_cast<WebCore::ResourceRequest*>(&resourceRequest));
+ }
+
+ private:
+ void bind(WebCore::ResourceRequest* resourceRequest)
+ {
+ m_handle.m_resourceRequest = resourceRequest;
+ assign(&m_handle);
+ }
+
+ class Handle : public WebURLRequestPrivate {
+ public:
+ virtual void dispose() { m_resourceRequest = 0; }
+ };
+
+ Handle m_handle;
+ };
+
+} // namespace WebKit
diff --git a/webkit/api/src/WrappedResourceResponse.h b/webkit/api/src/WrappedResourceResponse.h
new file mode 100644
index 0000000..fe7bb99
--- /dev/null
+++ b/webkit/api/src/WrappedResourceResponse.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2009 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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.
+ */
+
+#include "WebURLResponse.h"
+#include "WebURLResponsePrivate.h"
+
+namespace WebKit {
+
+ class WrappedResourceResponse : public WebURLResponse {
+ public:
+ ~WrappedResourceResponse()
+ {
+ reset(); // Need to drop reference to m_handle
+ }
+
+ WrappedResourceResponse(WebCore::ResourceResponse& resourceResponse)
+ {
+ bind(&resourceResponse);
+ }
+
+ WrappedResourceResponse(const WebCore::ResourceResponse& resourceResponse)
+ {
+ bind(const_cast<WebCore::ResourceResponse*>(&resourceResponse));
+ }
+
+ private:
+ void bind(WebCore::ResourceResponse* resourceResponse)
+ {
+ m_handle.m_resourceResponse = resourceResponse;
+ assign(&m_handle);
+ }
+
+ class Handle : public WebURLResponsePrivate {
+ public:
+ virtual void dispose() { m_resourceResponse = 0; }
+ };
+
+ Handle m_handle;
+ };
+
+} // namespace WebKit