Reviewed by Geoffrey Garen.
https://bugs.webkit.org/show_bug.cgi?id=22390
Abstract away JSC:: usage in WebCore/xml
* bindings/js/ScriptString.h: Added.
(WebCore::ScriptString::ScriptString):
(WebCore::ScriptString::operator JSC::UString):
(WebCore::ScriptString::isNull):
(WebCore::ScriptString::size):
(WebCore::ScriptString::operator=):
(WebCore::ScriptString::operator+=):
* inspector/InspectorController.cpp:
(WebCore::XMLHttpRequestResource::XMLHttpRequestResource):
(WebCore::InspectorResource::setXMLHttpRequestProperties):
(WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
* inspector/InspectorController.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::responseText):
(WebCore::XMLHttpRequest::clearResponse):
(WebCore::XMLHttpRequest::dropProtection):
(WebCore::XMLHttpRequest::didFinishLoading):
(WebCore::XMLHttpRequest::didReceiveData):
* xml/XMLHttpRequest.h:
(WebCore::XMLHttpRequest::setLastSendURL):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@38680
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-11-21 Darin Fisher <darin@chromium.org>
+
+ Reviewed by Geoffrey Garen.
+
+ https://bugs.webkit.org/show_bug.cgi?id=22390
+ Abstract away JSC:: usage in WebCore/xml
+
+ * bindings/js/ScriptString.h: Added.
+ (WebCore::ScriptString::ScriptString):
+ (WebCore::ScriptString::operator JSC::UString):
+ (WebCore::ScriptString::isNull):
+ (WebCore::ScriptString::size):
+ (WebCore::ScriptString::operator=):
+ (WebCore::ScriptString::operator+=):
+ * inspector/InspectorController.cpp:
+ (WebCore::XMLHttpRequestResource::XMLHttpRequestResource):
+ (WebCore::InspectorResource::setXMLHttpRequestProperties):
+ (WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
+ * inspector/InspectorController.h:
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::responseText):
+ (WebCore::XMLHttpRequest::clearResponse):
+ (WebCore::XMLHttpRequest::dropProtection):
+ (WebCore::XMLHttpRequest::didFinishLoading):
+ (WebCore::XMLHttpRequest::didReceiveData):
+ * xml/XMLHttpRequest.h:
+ (WebCore::XMLHttpRequest::setLastSendURL):
+
2008-11-21 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen.
--- /dev/null
+/*
+ * Copyright (c) 2008, 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 ScriptString_h
+#define ScriptString_h
+
+#include <runtime/JSLock.h>
+#include <runtime/UString.h>
+
+namespace WebCore {
+
+class String;
+
+class ScriptString {
+public:
+ ScriptString(const char* s) : m_str(s) {}
+ ScriptString(const JSC::UString& s) : m_str(s) {}
+
+ operator JSC::UString() const { return m_str; }
+
+ bool isNull() const { return m_str.isNull(); }
+ size_t size() const { return m_str.size(); }
+
+ ScriptString& operator=(const char* s)
+ {
+ JSC::JSLock lock(false);
+ m_str = s;
+ return *this;
+ }
+
+ ScriptString& operator+=(const String& s)
+ {
+ JSC::JSLock lock(false);
+ m_str += s;
+ return *this;
+ }
+
+private:
+ JSC::UString m_str;
+};
+
+} // namespace WebCore
+
+#endif // ScriptString_h
// XMLHttpRequestResource Class
struct XMLHttpRequestResource {
- XMLHttpRequestResource(JSC::UString& sourceString)
+ XMLHttpRequestResource(const JSC::UString& sourceString)
{
JSC::JSLock lock(false);
this->sourceString = sourceString.rep();
JSValueProtect(context, newScriptObject);
}
- void setXMLHttpRequestProperties(JSC::UString& data)
+ void setXMLHttpRequestProperties(const JSC::UString& data)
{
xmlHttpRequestResource.set(new XMLHttpRequestResource(data));
}
}
}
-void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, JSC::UString& sourceString)
+void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identifier, const JSC::UString& sourceString)
{
if (!enabled())
return;
void didReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived);
void didFinishLoading(DocumentLoader*, unsigned long identifier);
void didFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&);
- void resourceRetrievedByXMLHttpRequest(unsigned long identifier, JSC::UString& sourceString);
+ void resourceRetrievedByXMLHttpRequest(unsigned long identifier, const JSC::UString& sourceString);
#if ENABLE(DATABASE)
void didOpenDatabase(Database*, const String& domain, const String& name, const String& version);
#include "FrameLoader.h"
#include "HTTPParsers.h"
#include "InspectorController.h"
-#include "JSDOMBinding.h"
-#include "JSDOMWindow.h"
#include "KURL.h"
#include "KURLHash.h"
#include "Page.h"
#include "XMLHttpRequestProgressEvent.h"
#include "XMLHttpRequestUpload.h"
#include "markup.h"
-#include <runtime/JSLock.h>
#include <wtf/StdLibExtras.h>
+#if USE(JSC)
+#include "JSDOMWindow.h"
+#endif
+
namespace WebCore {
typedef HashSet<String, CaseFoldingHash> HeadersSet;
return m_state;
}
-const JSC::UString& XMLHttpRequest::responseText() const
+const ScriptString& XMLHttpRequest::responseText() const
{
return m_responseText;
}
void XMLHttpRequest::clearResponse()
{
m_response = ResourceResponse();
- {
- JSC::JSLock lock(false);
- m_responseText = "";
- }
+ m_responseText = "";
m_createdDocument = false;
m_responseXML = 0;
}
void XMLHttpRequest::dropProtection()
{
+#if USE(JSC)
// The XHR object itself holds on to the responseText, and
// thus has extra cost even independent of any
// responseText or responseXML objects it has handed
if (JSC::JSValue* wrapper = getCachedDOMObjectWrapper(*window->globalData(), this))
JSC::Heap::heap(wrapper)->reportExtraMemoryCost(m_responseText.size() * 2);
}
+#endif
unsetPendingActivity(this);
}
if (m_state < HEADERS_RECEIVED)
changeState(HEADERS_RECEIVED);
- {
- JSC::JSLock lock(false);
- if (m_decoder)
- m_responseText += m_decoder->flush();
- }
+ if (m_decoder)
+ m_responseText += m_decoder->flush();
if (Frame* frame = document()->frame()) {
if (Page* page = frame->page()) {
if (len == -1)
len = strlen(data);
- String decoded = m_decoder->decode(data, len);
-
- {
- JSC::JSLock lock(false);
- m_responseText += decoded;
- }
+ m_responseText += m_decoder->decode(data, len);
if (!m_error) {
updateAndDispatchOnProgress(len);
#include "FormData.h"
#include "ResourceResponse.h"
#include "SubresourceLoaderClient.h"
+#include "ScriptString.h"
#include <wtf/OwnPtr.h>
namespace WebCore {
void overrideMimeType(const String& override);
String getAllResponseHeaders(ExceptionCode&) const;
String getResponseHeader(const String& name, ExceptionCode&) const;
- const JSC::UString& responseText() const;
+ const ScriptString& responseText() const;
Document* responseXML() const;
void setLastSendLineNumber(unsigned lineNumber) { m_lastSendLineNumber = lineNumber; }
- void setLastSendURL(JSC::UString url) { m_lastSendURL = url; }
+ void setLastSendURL(const String& url) { m_lastSendURL = url; }
XMLHttpRequestUpload* upload();
XMLHttpRequestUpload* optionalUpload() const { return m_upload.get(); }
// to be able to share the buffer with JavaScript versions of the whole or partial string.
// In contrast, this string doesn't interact much with the rest of the engine so it's not that
// big a cost that it isn't a String.
- JSC::UString m_responseText;
+ ScriptString m_responseText;
mutable bool m_createdDocument;
mutable RefPtr<Document> m_responseXML;
long long m_receivedLength;
unsigned m_lastSendLineNumber;
- JSC::UString m_lastSendURL;
+ String m_lastSendURL;
};
} // namespace WebCore