#ifndef XMLHttpRequest_h
#define XMLHttpRequest_h
-#include "bindings/v8/ScriptString.h"
-#include "bindings/v8/ScriptWrappable.h"
+#include "bindings/core/v8/ScriptString.h"
#include "core/dom/ActiveDOMObject.h"
#include "core/events/EventListener.h"
#include "core/loader/ThreadableLoaderClient.h"
#include "core/xml/XMLHttpRequestEventTarget.h"
#include "core/xml/XMLHttpRequestProgressEventThrottle.h"
-#include "platform/AsyncMethodRunner.h"
#include "platform/heap/Handle.h"
#include "platform/network/FormData.h"
#include "platform/network/ResourceResponse.h"
#include "wtf/text/AtomicStringHash.h"
#include "wtf/text/StringBuilder.h"
-namespace WebCore {
+namespace blink {
class Blob;
class DOMFormData;
class XMLHttpRequest FINAL
: public RefCountedWillBeRefCountedGarbageCollected<XMLHttpRequest>
- , public ScriptWrappable
, public XMLHttpRequestEventTarget
, private ThreadableLoaderClient
, public ActiveDOMObject {
ResponseTypeDocument,
ResponseTypeBlob,
ResponseTypeArrayBuffer,
- ResponseTypeStream
- };
-
- enum DropProtection {
- DropProtectionSync,
- DropProtectionAsync,
+ ResponseTypeLegacyStream
};
virtual void contextDestroyed() OVERRIDE;
virtual void suspend() OVERRIDE;
virtual void resume() OVERRIDE;
virtual void stop() OVERRIDE;
+ virtual bool hasPendingActivity() const OVERRIDE;
virtual const AtomicString& interfaceName() const OVERRIDE;
virtual ExecutionContext* executionContext() const OVERRIDE;
void sendForInspectorXHRReplay(PassRefPtr<FormData>, ExceptionState&);
// Expose HTTP validation methods for other untrusted requests.
- static bool isAllowedHTTPMethod(const String&);
static AtomicString uppercaseKnownHTTPMethod(const AtomicString&);
- static bool isAllowedHTTPHeader(const String&);
void setResponseType(const String&, ExceptionState&);
String responseType();
virtual void didFail(const ResourceError&) OVERRIDE;
virtual void didFailRedirectCheck() OVERRIDE;
- AtomicString responseMIMEType() const;
+ // Returns the MIME type part of m_mimeTypeOverride if present and
+ // successfully parsed, or returns one of the "Content-Type" header value
+ // of the received response.
+ //
+ // This method is named after the term "final MIME type" defined in the
+ // spec but doesn't convert the result to ASCII lowercase as specified in
+ // the spec. Must be lowered later or compared using case insensitive
+ // comparison functions if required.
+ AtomicString finalResponseMIMEType() const;
+ // The same as finalResponseMIMEType() but fallbacks to "text/xml" if
+ // finalResponseMIMEType() returns an empty string.
+ AtomicString finalResponseMIMETypeWithFallback() const;
bool responseIsXML() const;
+ PassOwnPtr<TextResourceDecoder> createDecoder() const;
+
+ void initResponseDocument();
bool areMethodAndURLValidForSend();
bool initSend(ExceptionState&);
void changeState(State newState);
void dispatchReadyStateChangeEvent();
- void dropProtectionSoon();
- void dropProtection();
// Clears variables used only while the resource is being loaded.
void clearVariablesForLoading();
// Returns false iff reentry happened and a new load is started.
- bool internalAbort(DropProtection = DropProtectionSync);
+ bool internalAbort();
// Clears variables holding response header and body data.
void clearResponse();
void clearRequest();
void handleDidFailGeneric();
// Handles didFail() call not caused by cancellation or timeout.
void handleNetworkError();
- // Handles didFail() call triggered by m_loader->cancel().
+ // Handles didFail() call for cancellations. For example, the
+ // ResourceLoader handling the load notifies m_loader of an error
+ // cancellation when the frame containing the XHR navigates away.
void handleDidCancel();
// Handles didFail() call for timeout.
void handleDidTimeout();
KURL m_url;
AtomicString m_method;
HTTPHeaderMap m_requestHeaders;
+ // Not converted to ASCII lowercase. Must be lowered later or compared
+ // using case insensitive comparison functions if needed.
AtomicString m_mimeTypeOverride;
- bool m_async;
- bool m_includeCredentials;
unsigned long m_timeoutMilliseconds;
RefPtrWillBeMember<Blob> m_responseBlob;
RefPtrWillBeMember<Stream> m_responseStream;
State m_state;
ResourceResponse m_response;
- String m_responseEncoding;
+ String m_finalResponseCharset;
OwnPtr<TextResourceDecoder> m_decoder;
ScriptString m_responseText;
- // Used to skip m_responseDocument creation if it's done previously. We need
- // this separate flag since m_responseDocument can be 0 for some cases.
- bool m_createdDocument;
RefPtrWillBeMember<Document> m_responseDocument;
RefPtr<SharedBuffer> m_binaryResponseBuilder;
RefPtr<ArrayBuffer> m_responseArrayBuffer;
- bool m_error;
-
- bool m_uploadEventsAllowed;
- bool m_uploadComplete;
-
- bool m_sameOriginRequest;
-
// Used for onprogress tracking
long long m_receivedLength;
// An enum corresponding to the allowed string values for the responseType attribute.
ResponseTypeCode m_responseTypeCode;
- AsyncMethodRunner<XMLHttpRequest> m_dropProtectionRunner;
RefPtr<SecurityOrigin> m_securityOrigin;
+
+ bool m_async;
+ bool m_includeCredentials;
+ // Used to skip m_responseDocument creation if it's done previously. We need
+ // this separate flag since m_responseDocument can be 0 for some cases.
+ bool m_parsedResponse;
+ bool m_error;
+ bool m_uploadEventsAllowed;
+ bool m_uploadComplete;
+ bool m_sameOriginRequest;
};
-} // namespace WebCore
+} // namespace blink
#endif // XMLHttpRequest_h