Back out 1907bf7e6d7c (bug 749485) for build bustage

This commit is contained in:
Phil Ringnalda 2012-05-05 20:33:59 -07:00
Родитель d6697e4410
Коммит 15ea61df18
20 изменённых файлов: 321 добавлений и 400 удалений

Просмотреть файл

@ -788,11 +788,9 @@ static void LogMessage(const char* aWarning, nsPIDOMWindow* aWindow)
NS_IMETHODIMP
nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
{
ErrorResult rv;
nsresult rv = NS_OK;
nsIDocument* responseXML = GetResponseXML(rv);
if (rv.Failed()) {
return rv.ErrorCode();
}
NS_ENSURE_SUCCESS(rv, rv);
if (!responseXML) {
*aResponseXML = nsnull;
@ -803,11 +801,11 @@ nsXMLHttpRequest::GetResponseXML(nsIDOMDocument **aResponseXML)
}
nsIDocument*
nsXMLHttpRequest::GetResponseXML(ErrorResult& aRv)
nsXMLHttpRequest::GetResponseXML(nsresult& aRv)
{
if (mResponseType != XML_HTTP_RESPONSE_TYPE_DEFAULT &&
mResponseType != XML_HTTP_RESPONSE_TYPE_DOCUMENT) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return nsnull;
}
if (mWarnAboutMultipartHtml) {
@ -931,22 +929,22 @@ nsXMLHttpRequest::AppendToResponseText(const char * aSrcBuffer,
NS_IMETHODIMP
nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
{
ErrorResult rv;
nsresult rv = NS_OK;
nsString responseText;
GetResponseText(responseText, rv);
aResponseText = responseText;
return rv.ErrorCode();
return rv;
}
void
nsXMLHttpRequest::GetResponseText(nsString& aResponseText, ErrorResult& aRv)
nsXMLHttpRequest::GetResponseText(nsString& aResponseText, nsresult& aRv)
{
aResponseText.Truncate();
if (mResponseType != XML_HTTP_RESPONSE_TYPE_DEFAULT &&
mResponseType != XML_HTTP_RESPONSE_TYPE_TEXT &&
mResponseType != XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -974,17 +972,15 @@ nsXMLHttpRequest::GetResponseText(nsString& aResponseText, ErrorResult& aRv)
mResponseText.Truncate();
mResponseBodyDecodedPos = 0;
nsresult rv;
nsCOMPtr<nsICharsetConverterManager> ccm =
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &aRv);
if (NS_FAILED(aRv)) {
return;
}
aRv = ccm->GetUnicodeDecoderRaw(mResponseCharset.get(),
getter_AddRefs(mDecoder));
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
}
@ -993,7 +989,7 @@ nsXMLHttpRequest::GetResponseText(nsString& aResponseText, ErrorResult& aRv)
"Unexpected mResponseBodyDecodedPos");
aRv = AppendToResponseText(mResponseBody.get() + mResponseBodyDecodedPos,
mResponseBody.Length() - mResponseBodyDecodedPos);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
@ -1138,27 +1134,27 @@ NS_IMETHODIMP nsXMLHttpRequest::SetResponseType(const nsAString& aResponseType)
return NS_OK;
}
ErrorResult rv;
nsresult rv = NS_OK;
SetResponseType(responseType, rv);
return rv.ErrorCode();
return rv;
}
void
nsXMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aType,
ErrorResult& aRv)
nsresult& aRv)
{
SetResponseType(ResponseType(aType), aRv);
}
void
nsXMLHttpRequest::SetResponseType(nsXMLHttpRequest::ResponseType aResponseType,
ErrorResult& aRv)
nsresult& aRv)
{
// If the state is not OPENED or HEADERS_RECEIVED raise an
// INVALID_STATE_ERR exception and terminate these steps.
if (!(mState & (XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_SENT |
XML_HTTP_REQUEST_HEADERS_RECEIVED))) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -1166,14 +1162,14 @@ nsXMLHttpRequest::SetResponseType(nsXMLHttpRequest::ResponseType aResponseType,
if (HasOrHasHadOwner() &&
!(mState & (XML_HTTP_REQUEST_UNSENT | XML_HTTP_REQUEST_ASYNC))) {
LogMessage("ResponseTypeSyncXHRWarning", GetOwner());
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
aRv = NS_ERROR_DOM_INVALID_ACCESS_ERR;
return;
}
if (!(mState & XML_HTTP_REQUEST_ASYNC) &&
(aResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_TEXT ||
aResponseType == XML_HTTP_RESPONSE_TYPE_CHUNKED_ARRAYBUFFER)) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -1192,19 +1188,20 @@ nsXMLHttpRequest::SetResponseType(nsXMLHttpRequest::ResponseType aResponseType,
mResponseType == XML_HTTP_RESPONSE_TYPE_MOZ_BLOB);
}
}
aRv = NS_OK;
}
/* readonly attribute jsval response; */
NS_IMETHODIMP
nsXMLHttpRequest::GetResponse(JSContext *aCx, jsval *aResult)
{
ErrorResult rv;
nsresult rv = NS_OK;
*aResult = GetResponse(aCx, rv);
return rv.ErrorCode();
return rv;
}
JS::Value
nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
nsXMLHttpRequest::GetResponse(JSContext* aCx, nsresult& aRv)
{
switch (mResponseType) {
case XML_HTTP_RESPONSE_TYPE_DEFAULT:
@ -1213,12 +1210,12 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
{
nsString str;
aRv = GetResponseText(str);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return JSVAL_NULL;
}
JS::Value result;
if (!xpc::StringToJsval(aCx, str, &result)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return JSVAL_NULL;
}
return result;
@ -1238,7 +1235,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
RootResultArrayBuffer();
aRv = nsContentUtils::CreateArrayBuffer(aCx, mResponseBody,
&mResultArrayBuffer);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return JSVAL_NULL;
}
}
@ -1254,7 +1251,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
if (!mResponseBlob) {
aRv = CreatePartialBlob();
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return JSVAL_NULL;
}
}
@ -1291,7 +1288,7 @@ nsXMLHttpRequest::GetResponse(JSContext* aCx, ErrorResult& aRv)
if (mResultJSON == JSVAL_VOID) {
aRv = CreateResponseParsedJSON(aCx);
mResponseText.Truncate();
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
// Per spec, errors aren't propagated. null is returned instead.
aRv = NS_OK;
// It would be nice to log the error to the console. That's hard to
@ -1502,14 +1499,14 @@ NS_IMETHODIMP
nsXMLHttpRequest::GetResponseHeader(const nsACString& aHeader,
nsACString& aResult)
{
ErrorResult rv;
nsresult rv = NS_OK;
GetResponseHeader(aHeader, aResult, rv);
return rv.ErrorCode();
return rv;
}
void
nsXMLHttpRequest::GetResponseHeader(const nsACString& header,
nsACString& _retval, ErrorResult& aRv)
nsACString& _retval, nsresult& aRv)
{
_retval.SetIsVoid(true);
@ -1613,7 +1610,7 @@ nsXMLHttpRequest::GetResponseHeader(const nsACString& header,
}
aRv = httpChannel->GetResponseHeader(header, _retval);
if (aRv.ErrorCode() == NS_ERROR_NOT_AVAILABLE) {
if (aRv == NS_ERROR_NOT_AVAILABLE) {
// Means no header
_retval.SetIsVoid(true);
aRv = NS_OK;
@ -2521,18 +2518,17 @@ nsXMLHttpRequest::ChangeStateToDone()
NS_IMETHODIMP
nsXMLHttpRequest::SendAsBinary(const nsAString &aBody, JSContext *aCx)
{
ErrorResult rv;
nsresult rv = NS_OK;
SendAsBinary(aCx, aBody, rv);
return rv.ErrorCode();
return rv;
}
void
nsXMLHttpRequest::SendAsBinary(JSContext *aCx, const nsAString &aBody,
ErrorResult& aRv)
nsXMLHttpRequest::SendAsBinary(JSContext *aCx, const nsAString &aBody, nsresult& aRv)
{
char *data = static_cast<char*>(NS_Alloc(aBody.Length() + 1));
if (!data) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return;
}
@ -2543,7 +2539,7 @@ nsXMLHttpRequest::SendAsBinary(JSContext *aCx, const nsAString &aBody,
while (iter != end) {
if (*iter & 0xFF00) {
NS_Free(data);
aRv.Throw(NS_ERROR_DOM_INVALID_CHARACTER_ERR);
aRv = NS_ERROR_DOM_INVALID_CHARACTER_ERR;
return;
}
*p++ = static_cast<char>(*iter++);
@ -2553,7 +2549,7 @@ nsXMLHttpRequest::SendAsBinary(JSContext *aCx, const nsAString &aBody,
nsCOMPtr<nsIInputStream> stream;
aRv = NS_NewByteInputStream(getter_AddRefs(stream), data, aBody.Length(),
NS_ASSIGNMENT_ADOPT);
if (aRv.Failed()) {
if (NS_FAILED(aRv)){
NS_Free(data);
return;
}
@ -2561,7 +2557,7 @@ nsXMLHttpRequest::SendAsBinary(JSContext *aCx, const nsAString &aBody,
nsCOMPtr<nsIWritableVariant> variant = new nsVariant();
aRv = variant->SetAsISupports(stream);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
@ -3302,20 +3298,20 @@ nsXMLHttpRequest::GetTimeout(PRUint32 *aTimeout)
NS_IMETHODIMP
nsXMLHttpRequest::SetTimeout(PRUint32 aTimeout)
{
ErrorResult rv;
nsresult rv = NS_OK;
SetTimeout(aTimeout, rv);
return rv.ErrorCode();
return rv;
}
void
nsXMLHttpRequest::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
nsXMLHttpRequest::SetTimeout(uint32_t aTimeout, nsresult& aRv)
{
if (!(mState & (XML_HTTP_REQUEST_ASYNC | XML_HTTP_REQUEST_UNSENT)) &&
HasOrHasHadOwner()) {
/* Timeout is not supported for synchronous requests with an owning window,
per XHR2 spec. */
LogMessage("TimeoutSyncXHRWarning", GetOwner());
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
aRv = NS_ERROR_DOM_INVALID_ACCESS_ERR;
return;
}
@ -3875,17 +3871,17 @@ nsXMLHttpRequest::GetInterface(const nsIID & aIID, void **aResult)
}
JS::Value
nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSIID* aIID, ErrorResult& aRv)
nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSIID* aIID, nsresult& aRv)
{
const nsID* iid = aIID->GetID();
nsCOMPtr<nsISupports> result;
JS::Value v = JSVAL_NULL;
aRv = GetInterface(*iid, getter_AddRefs(result));
NS_ENSURE_FALSE(aRv.Failed(), JSVAL_NULL);
NS_ENSURE_SUCCESS(aRv, JSVAL_NULL);
JSObject* global = JS_GetGlobalForObject(aCx, GetWrapper());
aRv = nsContentUtils::WrapNative(aCx, global, result, iid, &v);
return aRv.Failed() ? JSVAL_NULL : v;
return NS_SUCCEEDED(aRv) ? v : JSVAL_NULL;
}
nsXMLHttpRequestUpload*

Просмотреть файл

@ -84,7 +84,7 @@ class nsIDOMFormData;
{ \
return GetListenerAsJSObject(mOn##_capitalized##Listener); \
} \
void SetOn##_lowercase(JSContext* aCx, JSObject* aCallback, ErrorResult& aRv) \
void SetOn##_lowercase(JSContext* aCx, JSObject* aCallback, nsresult& aRv) \
{ \
aRv = SetJSObjectListener(aCx, NS_LITERAL_STRING(#_lowercase), \
mOn##_capitalized##Listener, \
@ -211,12 +211,12 @@ public:
// The WebIDL parser converts constructors into methods called _Constructor.
static already_AddRefed<nsXMLHttpRequest>
_Constructor(nsISupports* aGlobal, ErrorResult& aRv)
_Constructor(nsISupports* aGlobal, nsresult& aRv)
{
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal);
nsCOMPtr<nsIScriptObjectPrincipal> principal = do_QueryInterface(aGlobal);
if (!window || ! principal) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return NULL;
}
@ -283,13 +283,13 @@ public:
// request
void Open(const nsAString& aMethod, const nsAString& aUrl, bool aAsync,
const nsAString& aUser, const nsAString& aPassword, ErrorResult& aRv)
const nsAString& aUser, const nsAString& aPassword, nsresult& aRv)
{
aRv = Open(NS_ConvertUTF16toUTF8(aMethod), NS_ConvertUTF16toUTF8(aUrl),
aAsync, aUser, aPassword);
}
void SetRequestHeader(const nsAString& aHeader, const nsAString& aValue,
ErrorResult& aRv)
nsresult& aRv)
{
aRv = SetRequestHeader(NS_ConvertUTF16toUTF8(aHeader),
NS_ConvertUTF16toUTF8(aValue));
@ -298,7 +298,7 @@ public:
{
return mTimeoutMilliseconds;
}
void SetTimeout(uint32_t aTimeout, ErrorResult& aRv);
void SetTimeout(uint32_t aTimeout, nsresult& aRv);
bool GetWithCredentials();
void SetWithCredentials(bool aWithCredentials, nsresult& aRv);
nsXMLHttpRequestUpload* GetUpload();
@ -387,26 +387,26 @@ private:
}
public:
void Send(JSContext *aCx, ErrorResult& aRv)
void Send(JSContext *aCx, nsresult& aRv)
{
aRv = Send(aCx, Nullable<RequestBody>());
}
void Send(JSContext *aCx, JSObject* aArrayBuffer, ErrorResult& aRv)
void Send(JSContext *aCx, JSObject* aArrayBuffer, nsresult& aRv)
{
NS_ASSERTION(aArrayBuffer, "Null should go to string version");
aRv = Send(aCx, RequestBody(aArrayBuffer));
}
void Send(JSContext *aCx, nsIDOMBlob* aBlob, ErrorResult& aRv)
void Send(JSContext *aCx, nsIDOMBlob* aBlob, nsresult& aRv)
{
NS_ASSERTION(aBlob, "Null should go to string version");
aRv = Send(aCx, RequestBody(aBlob));
}
void Send(JSContext *aCx, nsIDocument* aDoc, ErrorResult& aRv)
void Send(JSContext *aCx, nsIDocument* aDoc, nsresult& aRv)
{
NS_ASSERTION(aDoc, "Null should go to string version");
aRv = Send(aCx, RequestBody(aDoc));
}
void Send(JSContext *aCx, const nsAString& aString, ErrorResult& aRv)
void Send(JSContext *aCx, const nsAString& aString, nsresult& aRv)
{
if (DOMStringIsNull(aString)) {
Send(aCx, aRv);
@ -415,17 +415,17 @@ public:
aRv = Send(aCx, RequestBody(aString));
}
}
void Send(JSContext *aCx, nsIDOMFormData* aFormData, ErrorResult& aRv)
void Send(JSContext *aCx, nsIDOMFormData* aFormData, nsresult& aRv)
{
NS_ASSERTION(aFormData, "Null should go to string version");
aRv = Send(aCx, RequestBody(aFormData));
}
void Send(JSContext *aCx, nsIInputStream* aStream, ErrorResult& aRv)
void Send(JSContext *aCx, nsIInputStream* aStream, nsresult& aRv)
{
NS_ASSERTION(aStream, "Null should go to string version");
aRv = Send(aCx, RequestBody(aStream));
}
void SendAsBinary(JSContext *aCx, const nsAString& aBody, ErrorResult& aRv);
void SendAsBinary(JSContext *aCx, const nsAString& aBody, nsresult& aRv);
void Abort();
@ -433,9 +433,9 @@ public:
uint32_t GetStatus();
void GetStatusText(nsString& aStatusText);
void GetResponseHeader(const nsACString& aHeader, nsACString& aResult,
ErrorResult& aRv);
nsresult& aRv);
void GetResponseHeader(const nsAString& aHeader, nsString& aResult,
ErrorResult& aRv)
nsresult& aRv)
{
nsCString result;
GetResponseHeader(NS_ConvertUTF16toUTF8(aHeader), result, aRv);
@ -460,10 +460,10 @@ public:
{
return XMLHttpRequestResponseType(mResponseType);
}
void SetResponseType(XMLHttpRequestResponseType aType, ErrorResult& aRv);
JS::Value GetResponse(JSContext* aCx, ErrorResult& aRv);
void GetResponseText(nsString& aResponseText, ErrorResult& aRv);
nsIDocument* GetResponseXML(ErrorResult& aRv);
void SetResponseType(XMLHttpRequestResponseType aType, nsresult& aRv);
JS::Value GetResponse(JSContext* aCx, nsresult& aRv);
void GetResponseText(nsString& aResponseText, nsresult& aRv);
nsIDocument* GetResponseXML(nsresult& aRv);
bool GetMozBackgroundRequest();
void SetMozBackgroundRequest(bool aMozBackgroundRequest, nsresult& aRv);
@ -476,7 +476,7 @@ public:
}
// We need a GetInterface callable from JS for chrome JS
JS::Value GetInterface(JSContext* aCx, nsIJSIID* aIID, ErrorResult& aRv);
JS::Value GetInterface(JSContext* aCx, nsIJSIID* aIID, nsresult& aRv);
// This creates a trusted readystatechange event, which is not cancelable and
// doesn't bubble.
@ -633,7 +633,7 @@ protected:
XML_HTTP_RESPONSE_TYPE_MOZ_BLOB
};
void SetResponseType(nsXMLHttpRequest::ResponseType aType, ErrorResult& aRv);
void SetResponseType(nsXMLHttpRequest::ResponseType aType, nsresult& aRv);
ResponseType mResponseType;

Просмотреть файл

@ -785,17 +785,16 @@ WebGLContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
NS_IMETHODIMP
WebGLContext::GetContextAttributes(jsval *aResult)
{
ErrorResult rv;
nsresult rv = NS_OK;
JSObject* obj = GetContextAttributes(rv);
if (rv.Failed())
return rv.ErrorCode();
NS_ENSURE_SUCCESS(rv, rv);
*aResult = JS::ObjectOrNullValue(obj);
return NS_OK;
}
JSObject*
WebGLContext::GetContextAttributes(ErrorResult &rv)
WebGLContext::GetContextAttributes(nsresult &rv)
{
if (!IsContextStable())
{
@ -804,13 +803,13 @@ WebGLContext::GetContextAttributes(ErrorResult &rv)
JSContext *cx = nsContentUtils::GetCurrentJSContext();
if (!cx) {
rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return NULL;
}
JSObject *obj = JS_NewObject(cx, NULL, NULL, NULL);
if (!obj) {
rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return NULL;
}
@ -831,7 +830,7 @@ WebGLContext::GetContextAttributes(ErrorResult &rv)
mOptions.preserveDrawingBuffer ? JSVAL_TRUE : JSVAL_FALSE,
NULL, NULL, JSPROP_ENUMERATE))
{
rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return NULL;
}

Просмотреть файл

@ -694,7 +694,7 @@ public:
return mHeight;
}
JSObject *GetContextAttributes(ErrorResult &rv);
JSObject *GetContextAttributes(nsresult &rv);
bool IsContextLost() const { return !IsContextStable(); }
void GetSupportedExtensions(dom::Nullable< nsTArray<nsString> > &retval);
nsIWebGLExtension* GetExtension(const nsAString& aName);
@ -797,28 +797,28 @@ public:
dom::Nullable< nsTArray<WebGLShader*> > &retval);
WebGLint GetAttribLocation(WebGLProgram* prog, const nsAString& name);
JS::Value GetBufferParameter(WebGLenum target, WebGLenum pname);
JS::Value GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv);
JS::Value GetParameter(JSContext* cx, WebGLenum pname, nsresult& rv);
WebGLenum GetError();
JS::Value GetFramebufferAttachmentParameter(JSContext* cx,
WebGLenum target,
WebGLenum attachment,
WebGLenum pname,
ErrorResult& rv);
nsresult& rv);
JS::Value GetProgramParameter(WebGLProgram *prog, WebGLenum pname);
void GetProgramInfoLog(WebGLProgram *prog, nsAString& retval, ErrorResult& rv);
void GetProgramInfoLog(WebGLProgram *prog, nsAString& retval, nsresult& rv);
JS::Value GetRenderbufferParameter(WebGLenum target, WebGLenum pname);
JS::Value GetShaderParameter(WebGLShader *shader, WebGLenum pname);
already_AddRefed<WebGLShaderPrecisionFormat>
GetShaderPrecisionFormat(WebGLenum shadertype, WebGLenum precisiontype);
void GetShaderInfoLog(WebGLShader *shader, nsAString& retval, ErrorResult& rv);
void GetShaderInfoLog(WebGLShader *shader, nsAString& retval, nsresult& rv);
void GetShaderSource(WebGLShader *shader, nsAString& retval);
JS::Value GetTexParameter(WebGLenum target, WebGLenum pname);
JS::Value GetUniform(JSContext* cx, WebGLProgram *prog,
WebGLUniformLocation *location, ErrorResult& rv);
WebGLUniformLocation *location, nsresult& rv);
already_AddRefed<WebGLUniformLocation>
GetUniformLocation(WebGLProgram *prog, const nsAString& name);
JS::Value GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
ErrorResult& rv);
nsresult& rv);
WebGLsizeiptr GetVertexAttribOffset(WebGLuint index, WebGLenum pname);
void Hint(WebGLenum target, WebGLenum mode);
bool IsBuffer(WebGLBuffer *buffer);
@ -834,7 +834,7 @@ public:
MakeContextCurrent();
gl->fLineWidth(width);
}
void LinkProgram(WebGLProgram *program, ErrorResult& rv);
void LinkProgram(WebGLProgram *program, nsresult& rv);
void PixelStorei(WebGLenum pname, WebGLint param);
void PolygonOffset(WebGLfloat factor, WebGLfloat units) {
if (!IsContextStable())
@ -844,7 +844,7 @@ public:
}
void ReadPixels(WebGLint x, WebGLint y, WebGLsizei width, WebGLsizei height,
WebGLenum format, WebGLenum type,
dom::ArrayBufferView* pixels, ErrorResult& rv);
dom::ArrayBufferView* pixels, nsresult& rv);
void RenderbufferStorage(WebGLenum target, WebGLenum internalformat,
WebGLsizei width, WebGLsizei height);
void SampleCoverage(WebGLclampf value, WebGLboolean invert) {
@ -866,14 +866,13 @@ public:
void TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
WebGLenum internalformat, WebGLsizei width,
WebGLsizei height, WebGLint border, WebGLenum format,
WebGLenum type, dom::ArrayBufferView *pixels,
ErrorResult& rv);
WebGLenum type, dom::ArrayBufferView *pixels, nsresult& rv);
void TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
WebGLenum internalformat, WebGLenum format, WebGLenum type,
dom::ImageData* pixels, ErrorResult& rv);
dom::ImageData* pixels, nsresult& rv);
void TexImage2D(JSContext* /* unused */, WebGLenum target, WebGLint level,
WebGLenum internalformat, WebGLenum format, WebGLenum type,
dom::Element* elt, ErrorResult& rv);
dom::Element* elt, nsresult& rv);
void TexParameterf(WebGLenum target, WebGLenum pname, WebGLfloat param) {
TexParameter_base(target, pname, nsnull, &param);
}
@ -885,13 +884,13 @@ public:
WebGLint xoffset, WebGLint yoffset,
WebGLsizei width, WebGLsizei height, WebGLenum format,
WebGLenum type, dom::ArrayBufferView* pixels,
ErrorResult& rv);
nsresult& rv);
void TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
WebGLint xoffset, WebGLint yoffset, WebGLenum format,
WebGLenum type, dom::ImageData* pixels, ErrorResult& rv);
WebGLenum type, dom::ImageData* pixels, nsresult& rv);
void TexSubImage2D(JSContext* /* unused */, WebGLenum target, WebGLint level,
WebGLint xoffset, WebGLint yoffset, WebGLenum format,
WebGLenum type, dom::Element* elt, ErrorResult& rv);
WebGLenum type, dom::Element* elt, nsresult& rv);
void Uniform1i(WebGLUniformLocation* location, WebGLint x);
void Uniform2i(WebGLUniformLocation* location, WebGLint x, WebGLint y);

Просмотреть файл

@ -2321,20 +2321,19 @@ WebGLContext::GetAttribLocation(WebGLProgram *prog, const nsAString& name)
NS_IMETHODIMP
WebGLContext::GetParameter(PRUint32 pname, JSContext* cx, JS::Value *retval)
{
ErrorResult rv;
nsresult rv = NS_OK;
JS::Value v = GetParameter(cx, pname, rv);
if (rv.Failed())
return rv.ErrorCode();
NS_ENSURE_SUCCESS(rv, rv);
*retval = v;
return NS_OK;
}
static JS::Value
StringValue(JSContext* cx, const char* chars, ErrorResult& rv)
StringValue(JSContext* cx, const char* chars, nsresult& rv)
{
JSString* str = JS_NewStringCopyZ(cx, chars);
if (!str) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
rv = NS_ERROR_OUT_OF_MEMORY;
return JS::NullValue();
}
@ -2342,7 +2341,7 @@ StringValue(JSContext* cx, const char* chars, ErrorResult& rv)
}
JS::Value
WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, ErrorResult& rv)
WebGLContext::GetParameter(JSContext* cx, WebGLenum pname, nsresult& rv)
{
if (!IsContextStable())
return JS::NullValue();
@ -2748,11 +2747,10 @@ WebGLContext::GetBufferParameter(WebGLenum target, WebGLenum pname)
NS_IMETHODIMP
WebGLContext::GetFramebufferAttachmentParameter(WebGLenum target, WebGLenum attachment, WebGLenum pname, JSContext* cx, JS::Value *retval)
{
ErrorResult rv;
nsresult rv = NS_OK;
JS::Value v =
GetFramebufferAttachmentParameter(cx, target, attachment, pname, rv);
if (rv.Failed())
return rv.ErrorCode();
NS_ENSURE_SUCCESS(rv, rv);
*retval = v;
return NS_OK;
}
@ -2762,7 +2760,7 @@ WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
WebGLenum target,
WebGLenum attachment,
WebGLenum pname,
ErrorResult& rv)
nsresult& rv)
{
if (!IsContextStable())
return JS::NullValue();
@ -2803,7 +2801,7 @@ WebGLContext::GetFramebufferAttachmentParameter(JSContext* cx,
if (!dom::WrapObject(cx, GetWrapper(),
const_cast<WebGLRenderbuffer*>(fba.Renderbuffer()),
&v)) {
rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return JS::NullValue();
}
return v;
@ -3024,14 +3022,14 @@ WebGLContext::GetProgramParameter(WebGLProgram *prog, WebGLenum pname)
NS_IMETHODIMP
WebGLContext::GetProgramInfoLog(nsIWebGLProgram *pobj, nsAString& retval)
{
ErrorResult rv;
nsresult rv = NS_OK;
GetProgramInfoLog(static_cast<WebGLProgram*>(pobj), retval, rv);
return rv.ErrorCode();
return rv;
}
void
WebGLContext::GetProgramInfoLog(WebGLProgram *prog, nsAString& retval,
ErrorResult& rv)
nsresult& rv)
{
if (!IsContextStable())
{
@ -3251,18 +3249,17 @@ NS_IMETHODIMP
WebGLContext::GetUniform(nsIWebGLProgram *pobj, nsIWebGLUniformLocation *ploc,
JSContext *cx, JS::Value *retval)
{
ErrorResult rv;
nsresult rv = NS_OK;
JS::Value v = GetUniform(cx, static_cast<WebGLProgram*>(pobj),
static_cast<WebGLUniformLocation*>(ploc), rv);
if (rv.Failed())
return rv.ErrorCode();
NS_ENSURE_SUCCESS(rv, rv);
*retval = v;
return NS_OK;
}
JS::Value
WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
WebGLUniformLocation *location, ErrorResult& rv)
WebGLUniformLocation *location, nsresult& rv)
{
if (!IsContextStable())
return JS::NullValue();
@ -3331,20 +3328,20 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
}
if (index == uniforms) {
rv.Throw(NS_ERROR_FAILURE); // XXX GL error? shouldn't happen.
rv = NS_ERROR_FAILURE; // XXX GL error? shouldn't happen.
return JS::NullValue();
}
GLenum baseType;
GLint unitSize;
if (!BaseTypeAndSizeFromUniformType(uniformType, &baseType, &unitSize)) {
rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return JS::NullValue();
}
// this should never happen
if (unitSize > 16) {
rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return JS::NullValue();
}
@ -3356,7 +3353,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
} else {
JSObject* obj = Float32Array::Create(cx, unitSize, fv);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
rv = NS_ERROR_OUT_OF_MEMORY;
}
return JS::ObjectOrNullValue(obj);
}
@ -3368,7 +3365,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
} else {
JSObject* obj = Int32Array::Create(cx, unitSize, iv);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
rv = NS_ERROR_OUT_OF_MEMORY;
}
return JS::ObjectOrNullValue(obj);
}
@ -3383,7 +3380,7 @@ WebGLContext::GetUniform(JSContext* cx, WebGLProgram *prog,
uv[k] = JS::BooleanValue(iv[k] ? true : false);
JSObject* obj = JS_NewArrayObject(cx, unitSize, uv);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
rv = NS_ERROR_OUT_OF_MEMORY;
}
return JS::ObjectOrNullValue(obj);
}
@ -3436,17 +3433,16 @@ NS_IMETHODIMP
WebGLContext::GetVertexAttrib(WebGLuint index, WebGLenum pname, JSContext* cx,
JS::Value *retval)
{
ErrorResult rv;
nsresult rv = NS_OK;
JS::Value v = GetVertexAttrib(cx, index, pname, rv);
if (rv.Failed())
return rv.ErrorCode();
NS_ENSURE_SUCCESS(rv, rv);
*retval = v;
return NS_OK;
}
JS::Value
WebGLContext::GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
ErrorResult& rv)
nsresult& rv)
{
if (!IsContextStable())
return JS::NullValue();
@ -3462,7 +3458,7 @@ WebGLContext::GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
JS::Value v;
if (!dom::WrapObject(cx, GetWrapper(),
mAttribBuffers[index].buf.get(), &v)) {
rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return JS::NullValue();
}
return v;
@ -3496,7 +3492,7 @@ WebGLContext::GetVertexAttrib(JSContext* cx, WebGLuint index, WebGLenum pname,
}
JSObject* obj = Float32Array::Create(cx, 4, vec);
if (!obj) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
rv = NS_ERROR_OUT_OF_MEMORY;
}
return JS::ObjectOrNullValue(obj);
}
@ -3705,13 +3701,13 @@ GL_SAME_METHOD_1(LineWidth, LineWidth, WebGLfloat)
NS_IMETHODIMP
WebGLContext::LinkProgram(nsIWebGLProgram *pobj)
{
ErrorResult rv;
nsresult rv = NS_OK;
LinkProgram(static_cast<WebGLProgram*>(pobj), rv);
return rv.ErrorCode();
return rv;
}
void
WebGLContext::LinkProgram(WebGLProgram *program, ErrorResult& rv)
WebGLContext::LinkProgram(WebGLProgram *program, nsresult& rv)
{
if (!IsContextStable())
return;
@ -3722,7 +3718,8 @@ WebGLContext::LinkProgram(WebGLProgram *program, ErrorResult& rv)
GLuint progname = program->GLName();
if (!program->NextGeneration()) {
return rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return;
}
if (!program->HasBothShaderTypesAttached()) {
@ -3803,16 +3800,16 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width, WebGLsizei he
}
ArrayBufferView pixels(cx, &pixelsVal.toObject());
ErrorResult rv;
nsresult rv = NS_OK;
ReadPixels(x, y, width, height, format, type, &pixels, rv);
return rv.ErrorCode();
return rv;
}
void
WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
WebGLsizei height, WebGLenum format,
WebGLenum type, ArrayBufferView* pixels,
ErrorResult& rv)
nsresult& rv)
{
if (!IsContextStable()) {
return;
@ -3820,7 +3817,8 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
if (HTMLCanvasElement()->IsWriteOnly() && !nsContentUtils::IsCallerTrustedForRead()) {
LogMessageIfVerbose("ReadPixels: Not allowed");
return rv.Throw(NS_ERROR_DOM_SECURITY_ERR);
rv = NS_ERROR_DOM_SECURITY_ERR;
return;
}
if (width < 0 || height < 0)
@ -4023,7 +4021,8 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
}
} else {
NS_WARNING("Unhandled case, how'd we get here?");
return rv.Throw(NS_ERROR_FAILURE);
rv = NS_ERROR_FAILURE;
return;
}
}
}
@ -5361,14 +5360,13 @@ WebGLContext::GetShaderParameter(WebGLShader *shader, WebGLenum pname)
NS_IMETHODIMP
WebGLContext::GetShaderInfoLog(nsIWebGLShader *sobj, nsAString& retval)
{
ErrorResult rv;
nsresult rv = NS_OK;
GetShaderInfoLog(static_cast<WebGLShader*>(sobj), retval, rv);
return rv.ErrorCode();
return rv;
}
void
WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsAString& retval,
ErrorResult& rv)
WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsAString& retval, nsresult& rv)
{
if (!IsContextStable())
{
@ -5391,7 +5389,8 @@ WebGLContext::GetShaderInfoLog(WebGLShader *shader, nsAString& retval,
GLint k = -1;
gl->fGetShaderiv(shadername, LOCAL_GL_INFO_LOG_LENGTH, &k);
if (k == -1) {
return rv.Throw(NS_ERROR_FAILURE); // XXX GL Error? should never happen.
rv = NS_ERROR_FAILURE; // XXX GL Error? should never happen.
return;
}
if (k == 0) {
@ -5791,7 +5790,7 @@ WebGLContext::TexImage2D_array(WebGLenum target, WebGLint level, WebGLenum inter
WebGLenum format, WebGLenum type,
JSObject *pixels, JSContext *cx)
{
ErrorResult rv;
nsresult rv = NS_OK;
if (!pixels) {
TexImage2D(cx, target, level, internalformat, width, height, border,
format, type, nsnull, rv);
@ -5800,14 +5799,14 @@ WebGLContext::TexImage2D_array(WebGLenum target, WebGLint level, WebGLenum inter
TexImage2D(cx, target, level, internalformat, width, height, border,
format, type, &view, rv);
}
return rv.ErrorCode();
return rv;
}
void
WebGLContext::TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
WebGLenum internalformat, WebGLsizei width,
WebGLsizei height, WebGLint border, WebGLenum format,
WebGLenum type, ArrayBufferView *pixels, ErrorResult& rv)
WebGLenum type, ArrayBufferView *pixels, nsresult& rv)
{
if (!IsContextStable())
return;
@ -5841,7 +5840,7 @@ WebGLContext::TexImage2D_imageData(WebGLenum target, WebGLint level, WebGLenum i
void
WebGLContext::TexImage2D(JSContext* cx, WebGLenum target, WebGLint level,
WebGLenum internalformat, WebGLenum format,
WebGLenum type, ImageData* pixels, ErrorResult& rv)
WebGLenum type, ImageData* pixels, nsresult& rv)
{
if (!IsContextStable())
return;
@ -5863,16 +5862,16 @@ NS_IMETHODIMP
WebGLContext::TexImage2D_dom(WebGLenum target, WebGLint level, WebGLenum internalformat,
WebGLenum format, GLenum type, Element* elt)
{
ErrorResult rv;
nsresult rv = NS_OK;
TexImage2D(NULL, target, level, internalformat, format, type, elt, rv);
return rv.ErrorCode();
return rv;
}
void
WebGLContext::TexImage2D(JSContext* /* unused */, WebGLenum target,
WebGLint level, WebGLenum internalformat,
WebGLenum format, WebGLenum type, Element* elt,
ErrorResult& rv)
nsresult& rv)
{
if (!IsContextStable())
return;
@ -5881,7 +5880,7 @@ WebGLContext::TexImage2D(JSContext* /* unused */, WebGLenum target,
int srcFormat;
rv = DOMElementToImageSurface(elt, getter_AddRefs(isurf), &srcFormat);
if (rv.Failed())
if (NS_FAILED(rv))
return;
PRUint32 byteLength = isurf->Stride() * isurf->Height();
@ -6023,7 +6022,7 @@ WebGLContext::TexSubImage2D_array(WebGLenum target, WebGLint level,
WebGLenum format, WebGLenum type,
JSObject *pixels, JSContext *cx)
{
ErrorResult rv;
nsresult rv = NS_OK;
if (!pixels) {
TexSubImage2D(cx, target, level, xoffset, yoffset, width, height,
format, type, nsnull, rv);
@ -6032,7 +6031,7 @@ WebGLContext::TexSubImage2D_array(WebGLenum target, WebGLint level,
TexSubImage2D(cx, target, level, xoffset, yoffset, width, height,
format, type, &view, rv);
}
return rv.ErrorCode();
return rv;
}
void
@ -6041,7 +6040,7 @@ WebGLContext::TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
WebGLsizei width, WebGLsizei height,
WebGLenum format, WebGLenum type,
ArrayBufferView* pixels,
ErrorResult& rv)
nsresult& rv)
{
if (!IsContextStable())
return;
@ -6085,7 +6084,7 @@ void
WebGLContext::TexSubImage2D(JSContext* cx, WebGLenum target, WebGLint level,
WebGLint xoffset, WebGLint yoffset,
WebGLenum format, WebGLenum type, ImageData* pixels,
ErrorResult& rv)
nsresult& rv)
{
if (!IsContextStable())
return;
@ -6108,16 +6107,16 @@ WebGLContext::TexSubImage2D_dom(WebGLenum target, WebGLint level,
WebGLenum format, WebGLenum type,
Element *elt)
{
ErrorResult rv;
nsresult rv = NS_OK;
TexSubImage2D(NULL, target, level, xoffset, yoffset, format, type, elt, rv);
return rv.ErrorCode();
return rv;
}
void
WebGLContext::TexSubImage2D(JSContext* /* unused */, WebGLenum target,
WebGLint level, WebGLint xoffset, WebGLint yoffset,
WebGLenum format, WebGLenum type,
dom::Element* elt, ErrorResult& rv)
dom::Element* elt, nsresult& rv)
{
if (!IsContextStable())
return;
@ -6126,7 +6125,7 @@ WebGLContext::TexSubImage2D(JSContext* /* unused */, WebGLenum target,
int srcFormat;
rv = DOMElementToImageSurface(elt, getter_AddRefs(isurf), &srcFormat);
if (rv.Failed())
if (NS_FAILED(rv))
return;
PRUint32 byteLength = isurf->Stride() * isurf->Height();

Просмотреть файл

@ -49,7 +49,6 @@
#include "nsEventListenerManager.h"
#include "nsIScriptContext.h"
#include "nsWrapperCache.h"
#include "mozilla/ErrorResult.h"
class nsDOMEventListenerWrapper : public nsIDOMEventListener
{
@ -81,7 +80,7 @@ public:
void AddEventListener(const nsAString& aType,
nsIDOMEventListener* aCallback, // XXX nullable
bool aCapture, Nullable<bool>& aWantsUntrusted,
mozilla::ErrorResult& aRv)
nsresult& aRv)
{
aRv = AddEventListener(aType, aCallback, aCapture,
!aWantsUntrusted.IsNull() && aWantsUntrusted.Value(),
@ -89,11 +88,11 @@ public:
}
void RemoveEventListener(const nsAString& aType,
nsIDOMEventListener* aCallback,
bool aCapture, mozilla::ErrorResult& aRv)
bool aCapture, nsresult& aRv)
{
aRv = RemoveEventListener(aType, aCallback, aCapture);
}
bool DispatchEvent(nsIDOMEvent* aEvent, mozilla::ErrorResult& aRv)
bool DispatchEvent(nsIDOMEvent* aEvent, nsresult& aRv)
{
bool result = false;
aRv = DispatchEvent(aEvent, &result);

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/workers/Workers.h"
#include "mozilla/ErrorResult.h"
#include "jsapi.h"
#include "jsfriendapi.h"
@ -45,11 +44,11 @@ Throw(JSContext* cx, nsresult rv)
template<bool mainThread>
inline bool
ThrowMethodFailedWithDetails(JSContext* cx, const ErrorResult& rv,
ThrowMethodFailedWithDetails(JSContext* cx, nsresult rv,
const char* /* ifaceName */,
const char* /* memberName */)
{
return Throw<mainThread>(cx, rv.ErrorCode());
return Throw<mainThread>(cx, rv);
}
inline bool

Просмотреть файл

@ -67,12 +67,9 @@ DOMInterfaces = {
'workers': True,
'nativeType': 'mozilla::dom::workers::XMLHttpRequest',
'headerFile': 'mozilla/dom/workers/bindings/XMLHttpRequest.h',
'infallible': {
'all': ['readyState', 'statusText' ],
'getterOnly': [ 'timeout', 'withCredentials', 'mozBackgroundRequest',
'responseType', 'responseXML', 'channel', 'multipart' ]
}
'infallible': [
'readyState', 'statusText'
]
}],
'XMLHttpRequestUpload': [

Просмотреть файл

@ -1610,8 +1610,8 @@ class CGCallGenerator(CGThing):
self.cgRoot.append(call)
if isFallible:
self.cgRoot.prepend(CGGeneric("ErrorResult rv;"))
self.cgRoot.append(CGGeneric("if (rv.Failed()) {"))
self.cgRoot.prepend(CGGeneric("nsresult rv = NS_OK;"))
self.cgRoot.append(CGGeneric("if (NS_FAILED(rv)) {"))
self.cgRoot.append(CGIndenter(CGGeneric(errorReport)))
self.cgRoot.append(CGGeneric("}"))

Просмотреть файл

@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* vim: set ts=2 sw=2 et tw=79: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* A struct for tracking exceptions that need to be thrown to JS.
*/
#ifndef mozilla_ErrorResult_h
#define mozilla_ErrorResult_h
#include "nscore.h"
namespace mozilla {
class ErrorResult {
public:
ErrorResult() {
mResult = NS_OK;
}
void Throw(nsresult rv) {
MOZ_ASSERT(NS_FAILED(rv), "Please don't try throwing success");
mResult = rv;
}
// In the future, we can add overloads of Throw that take more
// interesting things, like strings or DOM exception types or
// something if desired.
// Backwards-compat to make conversion simpler. We don't call
// Throw() here because people can easily pass success codes to
// this.
void operator=(nsresult rv) {
mResult = rv;
}
bool Failed() const {
return NS_FAILED(mResult);
}
nsresult ErrorCode() const {
return mResult;
}
private:
nsresult mResult;
};
} // namespace mozilla
#endif /* mozilla_ErrorResult_h */

Просмотреть файл

@ -45,11 +45,7 @@ CPPSRCS = \
BindingUtils.cpp \
$(NULL)
EXPORTS_NAMESPACES = $(binding_include_path) mozilla
EXPORTS_mozilla = \
ErrorResult.h \
$(NULL)
EXPORTS_NAMESPACES = $(binding_include_path)
EXPORTS_$(binding_include_path) = \
DOMJSClass.h \

Просмотреть файл

@ -14,7 +14,6 @@
#include "EventTarget.h"
USING_WORKERS_NAMESPACE
using mozilla::ErrorResult;
namespace {
@ -195,7 +194,7 @@ EventListenerManager::FinalizeInternal(JSFreeOp* aFop)
void
EventListenerManager::Add(JSContext* aCx, const jsid& aType,
JSObject* aListener, Phase aPhase,
bool aWantsUntrusted, ErrorResult& aRv)
bool aWantsUntrusted, nsresult& aRv)
{
MOZ_ASSERT(aListener);
@ -206,7 +205,7 @@ EventListenerManager::Add(JSContext* aCx, const jsid& aType,
static_cast<ListenerCollection*>(&mCollectionHead);
collection = ListenerCollection::Add(aCx, head, aType);
if (!collection) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return;
}
}
@ -226,7 +225,7 @@ EventListenerManager::Add(JSContext* aCx, const jsid& aType,
static_cast<ListenerData*>(&collection->mListenerHead),
aListener, aPhase, aWantsUntrusted);
if (!listenerData) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return;
}
}
@ -280,24 +279,24 @@ EventListenerManager::GetEventListener(const jsid& aType) const
bool
EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
JSObject* aEvent, ErrorResult& aRv) const
JSObject* aEvent, nsresult& aRv) const
{
using namespace mozilla::dom::workers::events;
if (!IsSupportedEventClass(aEvent)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
jsval val;
if (!JS_GetProperty(aCx, aEvent, "target", &val)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
if (!JSVAL_IS_NULL(val)) {
// Already has a target, must be recursively dispatched. Throw.
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
@ -311,7 +310,7 @@ EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
if (!JS_GetProperty(aCx, aEvent, "type", &val) ||
!(eventType = JS_ValueToString(aCx, val)) ||
!(eventType = JS_InternJSString(aCx, eventType))) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
@ -319,7 +318,7 @@ EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
// there is no need to worry about this property being faked.
if (!JS_GetProperty(aCx, aEvent, "isTrusted", &val) ||
!JS_ValueToBoolean(aCx, val, &eventIsTrusted)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
@ -342,7 +341,7 @@ EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
// untrusted event.
if ((eventIsTrusted || listenerData->mWantsUntrusted) &&
!listeners.append(listenerData->mListener)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return false;
}
}
@ -369,7 +368,7 @@ EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
JSObject* listenerObj;
if (!JS_ValueToObject(aCx, listenerVal, &listenerObj)) {
if (!JS_ReportPendingException(aCx)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
continue;
@ -382,7 +381,7 @@ EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
JSBool hasHandleEvent;
if (!JS_HasProperty(aCx, listenerObj, sHandleEventChars, &hasHandleEvent)) {
if (!JS_ReportPendingException(aCx)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
continue;
@ -391,7 +390,7 @@ EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
if (hasHandleEvent) {
if (!JS_GetProperty(aCx, listenerObj, sHandleEventChars, &listenerVal)) {
if (!JS_ReportPendingException(aCx)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
continue;
@ -405,7 +404,7 @@ EventListenerManager::DispatchEvent(JSContext* aCx, const EventTarget& aTarget,
if (!JS_CallFunctionValue(aCx, thisObj, listenerVal, ArrayLength(argv),
argv, &rval)) {
if (!JS_ReportPendingException(aCx)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return false;
}
continue;

Просмотреть файл

@ -10,8 +10,6 @@
#include "prclist.h"
#include "mozilla/ErrorResult.h"
BEGIN_WORKERS_NAMESPACE
class EventTarget;
@ -58,7 +56,7 @@ public:
void
AddEventListener(JSContext* aCx, const jsid& aType, JSObject* aListener,
bool aCapturing, bool aWantsUntrusted, ErrorResult& aRv)
bool aCapturing, bool aWantsUntrusted, nsresult& aRv)
{
Add(aCx, aType, aListener, aCapturing ? Capturing : Bubbling,
aWantsUntrusted, aRv);
@ -76,14 +74,14 @@ public:
bool
DispatchEvent(JSContext* aCx, const EventTarget& aTarget, JSObject* aEvent,
ErrorResult& aRv) const;
nsresult& aRv) const;
JSObject*
GetEventListener(const jsid& aType) const;
void
SetEventListener(JSContext* aCx, const jsid& aType, JSObject* aListener,
ErrorResult& aRv)
nsresult& aRv)
{
JSObject* existing = GetEventListener(aType);
if (existing) {
@ -116,7 +114,7 @@ private:
void
Add(JSContext* aCx, const jsid& aType, JSObject* aListener, Phase aPhase,
bool aWantsUntrusted, ErrorResult& aRv);
bool aWantsUntrusted, nsresult& aRv);
void
Remove(JSContext* aCx, const jsid& aType, JSObject* aListener, Phase aPhase,

Просмотреть файл

@ -6,7 +6,6 @@
#include "EventTarget.h"
USING_WORKERS_NAMESPACE
using mozilla::ErrorResult;
void
EventTarget::_Trace(JSTracer* aTrc)
@ -23,14 +22,14 @@ EventTarget::_Finalize(JSFreeOp* aFop)
}
JSObject*
EventTarget::GetEventListener(const nsAString& aType, ErrorResult& aRv) const
EventTarget::GetEventListener(const nsAString& aType, nsresult& aRv) const
{
JSContext* cx = GetJSContext();
JSString* type =
JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
if (!type || !(type = JS_InternJSString(cx, type))) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return NULL;
}
@ -39,14 +38,14 @@ EventTarget::GetEventListener(const nsAString& aType, ErrorResult& aRv) const
void
EventTarget::SetEventListener(const nsAString& aType, JSObject* aListener,
ErrorResult& aRv)
nsresult& aRv)
{
JSContext* cx = GetJSContext();
JSString* type =
JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
if (!type || !(type = JS_InternJSString(cx, type))) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return;
}
@ -57,7 +56,7 @@ EventTarget::SetEventListener(const nsAString& aType, JSObject* aListener,
void
EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener,
bool aCapturing, Nullable<bool> aWantsUntrusted,
ErrorResult& aRv)
nsresult& aRv)
{
if (!aListener) {
return;
@ -68,7 +67,7 @@ EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener,
JSString* type =
JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
if (!type || !(type = JS_InternJSString(cx, type))) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return;
}
@ -80,7 +79,7 @@ EventTarget::AddEventListener(const nsAString& aType, JSObject* aListener,
void
EventTarget::RemoveEventListener(const nsAString& aType, JSObject* aListener,
bool aCapturing, ErrorResult& aRv)
bool aCapturing, nsresult& aRv)
{
if (!aListener) {
return;
@ -91,7 +90,7 @@ EventTarget::RemoveEventListener(const nsAString& aType, JSObject* aListener,
JSString* type =
JS_NewUCStringCopyN(cx, aType.BeginReading(), aType.Length());
if (!type || !(type = JS_InternJSString(cx, type))) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return;
}

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/dom/workers/bindings/EventListenerManager.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/ErrorResult.h"
using namespace mozilla::dom;
@ -39,25 +38,24 @@ public:
void
AddEventListener(const nsAString& aType, JSObject* aListener,
bool aCapture, Nullable<bool> aWantsUntrusted,
ErrorResult& aRv);
bool aCapture, Nullable<bool> aWantsUntrusted, nsresult& aRv);
void
RemoveEventListener(const nsAString& aType, JSObject* aListener,
bool aCapture, ErrorResult& aRv);
bool aCapture, nsresult& aRv);
bool
DispatchEvent(JSObject* aEvent, ErrorResult& aRv) const
DispatchEvent(JSObject* aEvent, nsresult& aRv) const
{
return mListenerManager.DispatchEvent(GetJSContext(), *this, aEvent, aRv);
}
JSObject*
GetEventListener(const nsAString& aType, ErrorResult& aRv) const;
GetEventListener(const nsAString& aType, nsresult& aRv) const;
void
SetEventListener(const nsAString& aType, JSObject* aListener,
ErrorResult& aRv);
nsresult& aRv);
bool
HasListeners() const

Просмотреть файл

@ -56,7 +56,6 @@
USING_WORKERS_NAMESPACE
using namespace mozilla::dom;
using mozilla::ErrorResult;
namespace {
@ -199,10 +198,10 @@ private:
}
NS_ConvertASCIItoUTF16 nameStr(name + 2);
ErrorResult rv;
nsresult rv = NS_OK;
JSObject* listener = worker->GetEventListener(nameStr, rv);
if (rv.Failed()) {
if (NS_FAILED(rv)) {
JS_ReportError(aCx, "Failed to get listener!");
}
@ -229,10 +228,10 @@ private:
}
NS_ConvertASCIItoUTF16 nameStr(name + 2);
ErrorResult rv;
nsresult rv = NS_OK;
worker->SetEventListener(nameStr, listener, rv);
if (rv.Failed()) {
if (NS_FAILED(rv)) {
JS_ReportError(aCx, "Failed to set listener!");
return false;
}

Просмотреть файл

@ -177,12 +177,12 @@ private:
return false;
}
ErrorResult rv;
nsresult rv = NS_OK;
JSObject* listener =
scope->GetEventListener(NS_ConvertASCIItoUTF16(name + 2), rv);
if (rv.Failed()) {
if (NS_FAILED(rv)) {
JS_ReportError(aCx, "Failed to get event listener!");
return false;
}
@ -209,10 +209,10 @@ private:
return false;
}
ErrorResult rv;
nsresult rv = NS_OK;
scope->SetEventListener(NS_ConvertASCIItoUTF16(name + 2),
JSVAL_TO_OBJECT(*aVp), rv);
if (rv.Failed()) {
if (NS_FAILED(rv)) {
JS_ReportError(aCx, "Failed to set event listener!");
return false;
}
@ -341,12 +341,12 @@ private:
return false;
}
ErrorResult rv;
nsresult rv = NS_OK;
JSObject* adaptor =
scope->GetEventListener(NS_ConvertASCIItoUTF16(name + 2), rv);
if (rv.Failed()) {
if (NS_FAILED(rv)) {
JS_ReportError(aCx, "Failed to get event listener!");
return false;
}
@ -394,11 +394,11 @@ private:
OBJECT_TO_JSVAL(aObj));
js::SetFunctionNativeReserved(listener, SLOT_wrappedFunction, *aVp);
ErrorResult rv;
nsresult rv = NS_OK;
scope->SetEventListener(NS_ConvertASCIItoUTF16(name + 2), listener, rv);
if (rv.Failed()) {
if (NS_FAILED(rv)) {
JS_ReportError(aCx, "Failed to set event listener!");
return false;
}
@ -745,12 +745,12 @@ private:
return false;
}
ErrorResult rv;
nsresult rv = NS_OK;
JSObject* listener =
scope->GetEventListener(NS_ConvertASCIItoUTF16(name + 2), rv);
if (rv.Failed()) {
if (NS_FAILED(rv)) {
JS_ReportError(aCx, "Failed to get event listener!");
return false;
}
@ -777,12 +777,12 @@ private:
return false;
}
ErrorResult rv;
nsresult rv = NS_OK;
scope->SetEventListener(NS_ConvertASCIItoUTF16(name + 2),
JSVAL_TO_OBJECT(*aVp), rv);
if (rv.Failed()) {
if (NS_FAILED(rv)) {
JS_ReportError(aCx, "Failed to set event listener!");
return false;
}

Просмотреть файл

@ -32,7 +32,6 @@
USING_WORKERS_NAMESPACE
using mozilla::dom::workers::exceptions::ThrowDOMExceptionForNSResult;
using mozilla::ErrorResult;
// XXX Need to figure this out...
#define UNCATCHABLE_EXCEPTION NS_ERROR_OUT_OF_MEMORY
@ -1448,7 +1447,7 @@ XMLHttpRequest::_Finalize(JSFreeOp* aFop)
// static
XMLHttpRequest*
XMLHttpRequest::_Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv)
XMLHttpRequest::_Constructor(JSContext* aCx, JSObject* aGlobal, nsresult& aRv)
{
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
MOZ_ASSERT(workerPrivate);
@ -1456,7 +1455,7 @@ XMLHttpRequest::_Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv
nsRefPtr<XMLHttpRequest> xhr = new XMLHttpRequest(aCx, workerPrivate);
if (!Wrap(aCx, aGlobal, xhr)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return NULL;
}
@ -1502,7 +1501,7 @@ XMLHttpRequest::ReleaseProxy(ReleaseType aType)
}
void
XMLHttpRequest::MaybePin(ErrorResult& aRv)
XMLHttpRequest::MaybePin(nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
@ -1513,13 +1512,13 @@ XMLHttpRequest::MaybePin(ErrorResult& aRv)
JSContext* cx = GetJSContext();
if (!JS_AddNamedObjectRoot(cx, &mJSObject, "XMLHttpRequest mJSObject")) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
if (!mWorkerPrivate->AddFeature(cx, this)) {
JS_RemoveObjectRoot(cx, &mJSObject);
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
@ -1527,7 +1526,7 @@ XMLHttpRequest::MaybePin(ErrorResult& aRv)
}
void
XMLHttpRequest::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv)
XMLHttpRequest::MaybeDispatchPrematureAbortEvents(nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(mProxy);
@ -1541,12 +1540,12 @@ XMLHttpRequest::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv)
MOZ_ASSERT(target);
DispatchPrematureAbortEvent(target, STRING_abort, true, aRv);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
DispatchPrematureAbortEvent(target, STRING_loadend, true, aRv);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
@ -1558,17 +1557,17 @@ XMLHttpRequest::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv)
MOZ_ASSERT(target);
DispatchPrematureAbortEvent(target, STRING_readystatechange, false, aRv);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
DispatchPrematureAbortEvent(target, STRING_abort, false, aRv);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
DispatchPrematureAbortEvent(target, STRING_loadend, false, aRv);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
@ -1579,8 +1578,7 @@ XMLHttpRequest::MaybeDispatchPrematureAbortEvents(ErrorResult& aRv)
void
XMLHttpRequest::DispatchPrematureAbortEvent(JSObject* aTarget,
uint8_t aEventType,
bool aUploadTarget,
ErrorResult& aRv)
bool aUploadTarget, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(mProxy);
@ -1591,7 +1589,7 @@ XMLHttpRequest::DispatchPrematureAbortEvent(JSObject* aTarget,
JSString* type = JS_NewStringCopyZ(cx, sEventStrings[aEventType]);
if (!type) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return;
}
@ -1613,13 +1611,13 @@ XMLHttpRequest::DispatchPrematureAbortEvent(JSObject* aTarget,
}
if (!event) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
bool dummy;
if (!events::DispatchEventToTarget(cx, aTarget, event, &dummy)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
@ -1644,14 +1642,14 @@ void
XMLHttpRequest::SendInternal(const nsAString& aStringBody,
JSAutoStructuredCloneBuffer& aBody,
nsTArray<nsCOMPtr<nsISupports> >& aClonedObjects,
ErrorResult& aRv)
nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
bool hasUploadListeners = mUpload ? mUpload->HasListeners() : false;
MaybePin(aRv);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
@ -1681,7 +1679,7 @@ XMLHttpRequest::SendInternal(const nsAString& aStringBody,
}
if (mProxy->mIsSyncXHR && !mWorkerPrivate->RunSyncLoop(cx, syncQueueKey)) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
@ -1703,18 +1701,18 @@ XMLHttpRequest::Notify(JSContext* aCx, Status aStatus)
void
XMLHttpRequest::Open(const nsAString& aMethod, const nsAString& aUrl,
bool aAsync, const nsAString& aUser,
const nsAString& aPassword, ErrorResult& aRv)
const nsAString& aPassword, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (mProxy) {
MaybeDispatchPrematureAbortEvents(aRv);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
}
@ -1731,7 +1729,7 @@ XMLHttpRequest::Open(const nsAString& aMethod, const nsAString& aUrl,
if (!runnable->Dispatch(GetJSContext())) {
ReleaseProxy();
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
@ -1740,17 +1738,17 @@ XMLHttpRequest::Open(const nsAString& aMethod, const nsAString& aUrl,
void
XMLHttpRequest::SetRequestHeader(const nsAString& aHeader,
const nsAString& aValue, ErrorResult& aRv)
const nsAString& aValue, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (!mProxy) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -1759,18 +1757,18 @@ XMLHttpRequest::SetRequestHeader(const nsAString& aHeader,
NS_ConvertUTF16toUTF8(aHeader),
NS_ConvertUTF16toUTF8(aValue));
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
void
XMLHttpRequest::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
XMLHttpRequest::SetTimeout(uint32_t aTimeout, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
@ -1785,18 +1783,18 @@ XMLHttpRequest::SetTimeout(uint32_t aTimeout, ErrorResult& aRv)
nsRefPtr<SetTimeoutRunnable> runnable =
new SetTimeoutRunnable(mWorkerPrivate, mProxy, aTimeout);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
void
XMLHttpRequest::SetWithCredentials(bool aWithCredentials, ErrorResult& aRv)
XMLHttpRequest::SetWithCredentials(bool aWithCredentials, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
@ -1811,18 +1809,18 @@ XMLHttpRequest::SetWithCredentials(bool aWithCredentials, ErrorResult& aRv)
nsRefPtr<SetWithCredentialsRunnable> runnable =
new SetWithCredentialsRunnable(mWorkerPrivate, mProxy, aWithCredentials);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
void
XMLHttpRequest::SetMultipart(bool aMultipart, ErrorResult& aRv)
XMLHttpRequest::SetMultipart(bool aMultipart, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
@ -1837,19 +1835,19 @@ XMLHttpRequest::SetMultipart(bool aMultipart, ErrorResult& aRv)
nsRefPtr<SetMultipartRunnable> runnable =
new SetMultipartRunnable(mWorkerPrivate, mProxy, aMultipart);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
void
XMLHttpRequest::SetMozBackgroundRequest(bool aBackgroundRequest,
ErrorResult& aRv)
nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
@ -1865,18 +1863,18 @@ XMLHttpRequest::SetMozBackgroundRequest(bool aBackgroundRequest,
new SetBackgroundRequestRunnable(mWorkerPrivate, mProxy,
aBackgroundRequest);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
XMLHttpRequestUpload*
XMLHttpRequest::GetUpload(ErrorResult& aRv)
XMLHttpRequest::GetUpload(nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return NULL;
}
@ -1885,7 +1883,7 @@ XMLHttpRequest::GetUpload(ErrorResult& aRv)
XMLHttpRequestUpload::Create(GetJSContext(), this);
if (!upload) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return NULL;
}
@ -1896,17 +1894,17 @@ XMLHttpRequest::GetUpload(ErrorResult& aRv)
}
void
XMLHttpRequest::Send(ErrorResult& aRv)
XMLHttpRequest::Send(nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (!mProxy) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -1918,17 +1916,17 @@ XMLHttpRequest::Send(ErrorResult& aRv)
}
void
XMLHttpRequest::Send(const nsAString& aBody, ErrorResult& aRv)
XMLHttpRequest::Send(const nsAString& aBody, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (!mProxy) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -1940,18 +1938,18 @@ XMLHttpRequest::Send(const nsAString& aBody, ErrorResult& aRv)
}
void
XMLHttpRequest::Send(JSObject* aBody, ErrorResult& aRv)
XMLHttpRequest::Send(JSObject* aBody, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(aBody);
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (!mProxy) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -1964,7 +1962,7 @@ XMLHttpRequest::Send(JSObject* aBody, ErrorResult& aRv)
else {
JSString* bodyStr = JS_ValueToString(cx, OBJECT_TO_JSVAL(aBody));
if (!bodyStr) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return;
}
valToClone = STRING_TO_JSVAL(bodyStr);
@ -1979,7 +1977,7 @@ XMLHttpRequest::Send(JSObject* aBody, ErrorResult& aRv)
JSAutoStructuredCloneBuffer buffer;
if (!buffer.write(cx, valToClone, callbacks, &clonedObjects)) {
aRv.Throw(NS_ERROR_DOM_DATA_CLONE_ERR);
aRv = NS_ERROR_DOM_DATA_CLONE_ERR;
return;
}
@ -1987,20 +1985,20 @@ XMLHttpRequest::Send(JSObject* aBody, ErrorResult& aRv)
}
void
XMLHttpRequest::SendAsBinary(const nsAString& aBody, ErrorResult& aRv)
XMLHttpRequest::SendAsBinary(const nsAString& aBody, nsresult& aRv)
{
NS_NOTYETIMPLEMENTED("Implement me!");
aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
return;
aRv = NS_ERROR_NOT_IMPLEMENTED;
}
void
XMLHttpRequest::Abort(ErrorResult& aRv)
XMLHttpRequest::Abort(nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (!mProxy) {
@ -2008,7 +2006,7 @@ XMLHttpRequest::Abort(ErrorResult& aRv)
}
MaybeDispatchPrematureAbortEvents(aRv);
if (aRv.Failed()) {
if (NS_FAILED(aRv)) {
return;
}
@ -2016,24 +2014,24 @@ XMLHttpRequest::Abort(ErrorResult& aRv)
nsRefPtr<AbortRunnable> runnable = new AbortRunnable(mWorkerPrivate, mProxy);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
void
XMLHttpRequest::GetResponseHeader(const nsAString& aHeader,
nsAString& aResponseHeader, ErrorResult& aRv)
nsAString& aResponseHeader, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (!mProxy) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -2042,7 +2040,7 @@ XMLHttpRequest::GetResponseHeader(const nsAString& aHeader,
new GetResponseHeaderRunnable(mWorkerPrivate, mProxy,
NS_ConvertUTF16toUTF8(aHeader), value);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
@ -2051,17 +2049,17 @@ XMLHttpRequest::GetResponseHeader(const nsAString& aHeader,
void
XMLHttpRequest::GetAllResponseHeaders(nsAString& aResponseHeaders,
ErrorResult& aRv)
nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (!mProxy) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -2069,7 +2067,7 @@ XMLHttpRequest::GetAllResponseHeaders(nsAString& aResponseHeaders,
nsRefPtr<GetAllResponseHeadersRunnable> runnable =
new GetAllResponseHeadersRunnable(mWorkerPrivate, mProxy, responseHeaders);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
@ -2077,12 +2075,12 @@ XMLHttpRequest::GetAllResponseHeaders(nsAString& aResponseHeaders,
}
void
XMLHttpRequest::OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv)
XMLHttpRequest::OverrideMimeType(const nsAString& aMimeType, nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
@ -2092,31 +2090,31 @@ XMLHttpRequest::OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv)
// (bug 671047). For now we're going to let this work only if the Send()
// method has not been called.
if (!mProxy || SendInProgress()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
nsRefPtr<OverrideMimeTypeRunnable> runnable =
new OverrideMimeTypeRunnable(mWorkerPrivate, mProxy, aMimeType);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
}
void
XMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aResponseType,
ErrorResult& aRv)
nsresult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (mCanceled) {
aRv.Throw(UNCATCHABLE_EXCEPTION);
aRv = UNCATCHABLE_EXCEPTION;
return;
}
if (!mProxy || SendInProgress()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
aRv = NS_ERROR_DOM_INVALID_STATE_ERR;
return;
}
@ -2132,7 +2130,7 @@ XMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aResponseType,
nsRefPtr<SetResponseTypeRunnable> runnable =
new SetResponseTypeRunnable(mWorkerPrivate, mProxy, responseType);
if (!runnable->Dispatch(GetJSContext())) {
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return;
}
@ -2143,7 +2141,7 @@ XMLHttpRequest::SetResponseType(XMLHttpRequestResponseType aResponseType,
}
jsval
XMLHttpRequest::GetResponse(ErrorResult& aRv)
XMLHttpRequest::GetResponse(nsresult& aRv)
{
if (NS_SUCCEEDED(mStateData.mResponseTextResult) &&
JSVAL_IS_VOID(mStateData.mResponse)) {
@ -2154,7 +2152,7 @@ XMLHttpRequest::GetResponse(ErrorResult& aRv)
JS_NewUCStringCopyN(GetJSContext(), mStateData.mResponseText.get(),
mStateData.mResponseText.Length());
if (!str) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
aRv = NS_ERROR_OUT_OF_MEMORY;
return JSVAL_VOID;
}
@ -2166,7 +2164,7 @@ XMLHttpRequest::GetResponse(ErrorResult& aRv)
}
void
XMLHttpRequest::GetResponseText(nsAString& aResponseText, ErrorResult& aRv)
XMLHttpRequest::GetResponseText(nsAString& aResponseText, nsresult& aRv)
{
aRv = mStateData.mResponseTextResult;
aResponseText = mStateData.mResponseText;

Просмотреть файл

@ -68,7 +68,7 @@ public:
_Finalize(JSFreeOp* aFop) MOZ_OVERRIDE;
static XMLHttpRequest*
_Constructor(JSContext* aCx, JSObject* aGlobal, ErrorResult& aRv);
_Constructor(JSContext* aCx, JSObject* aGlobal, nsresult& aRv);
void
Unpin();
@ -78,13 +78,13 @@ public:
#define IMPL_GETTER_AND_SETTER(_type) \
JSObject* \
GetOn##_type(ErrorResult& aRv) \
GetOn##_type(nsresult& aRv) \
{ \
return GetEventListener(NS_LITERAL_STRING(#_type), aRv); \
} \
\
void \
SetOn##_type(JSObject* aListener, ErrorResult& aRv) \
SetOn##_type(JSObject* aListener, nsresult& aRv) \
{ \
SetEventListener(NS_LITERAL_STRING(#_type), aListener, aRv); \
}
@ -101,68 +101,68 @@ public:
void
Open(const nsAString& aMethod, const nsAString& aUrl, bool aAsync,
const nsAString& aUser, const nsAString& aPassword, ErrorResult& aRv);
const nsAString& aUser, const nsAString& aPassword, nsresult& aRv);
void
SetRequestHeader(const nsAString& aHeader, const nsAString& aValue,
ErrorResult& aRv);
nsresult& aRv);
uint32_t
GetTimeout() const
GetTimeout(nsresult& aRv) const
{
return mTimeout;
}
void
SetTimeout(uint32_t aTimeout, ErrorResult& aRv);
SetTimeout(uint32_t aTimeout, nsresult& aRv);
bool
GetWithCredentials() const
GetWithCredentials(nsresult& aRv) const
{
return mWithCredentials;
}
void
SetWithCredentials(bool aWithCredentials, ErrorResult& aRv);
SetWithCredentials(bool aWithCredentials, nsresult& aRv);
bool
GetMultipart() const
GetMultipart(nsresult& aRv) const
{
return mMultipart;
}
void
SetMultipart(bool aMultipart, ErrorResult& aRv);
SetMultipart(bool aMultipart, nsresult& aRv);
bool
GetMozBackgroundRequest() const
GetMozBackgroundRequest(nsresult& aRv) const
{
return mBackgroundRequest;
}
void
SetMozBackgroundRequest(bool aBackgroundRequest, ErrorResult& aRv);
SetMozBackgroundRequest(bool aBackgroundRequest, nsresult& aRv);
XMLHttpRequestUpload*
GetUpload(ErrorResult& aRv);
GetUpload(nsresult& aRv);
void
Send(ErrorResult& aRv);
Send(nsresult& aRv);
void
Send(const nsAString& aBody, ErrorResult& aRv);
Send(const nsAString& aBody, nsresult& aRv);
void
Send(JSObject* aBody, ErrorResult& aRv);
Send(JSObject* aBody, nsresult& aRv);
void
SendAsBinary(const nsAString& aBody, ErrorResult& aRv);
SendAsBinary(const nsAString& aBody, nsresult& aRv);
void
Abort(ErrorResult& aRv);
Abort(nsresult& aRv);
uint16_t
GetStatus(ErrorResult& aRv) const
GetStatus(nsresult& aRv) const
{
aRv = mStateData.mStatusResult;
return mStateData.mStatus;
@ -176,45 +176,45 @@ public:
void
GetResponseHeader(const nsAString& aHeader, nsAString& aResponseHeader,
ErrorResult& aRv);
nsresult& aRv);
void
GetAllResponseHeaders(nsAString& aResponseHeaders, ErrorResult& aRv);
GetAllResponseHeaders(nsAString& aResponseHeaders, nsresult& aRv);
void
OverrideMimeType(const nsAString& aMimeType, ErrorResult& aRv);
OverrideMimeType(const nsAString& aMimeType, nsresult& aRv);
XMLHttpRequestResponseType
GetResponseType() const
GetResponseType(nsresult& aRv) const
{
return mResponseType;
}
void
SetResponseType(XMLHttpRequestResponseType aResponseType, ErrorResult& aRv);
SetResponseType(XMLHttpRequestResponseType aResponseType, nsresult& aRv);
jsval
GetResponse(ErrorResult& aRv);
GetResponse(nsresult& aRv);
void
GetResponseText(nsAString& aResponseText, ErrorResult& aRv);
GetResponseText(nsAString& aResponseText, nsresult& aRv);
JSObject*
GetResponseXML() const
GetResponseXML(nsresult& aRv) const
{
return NULL;
}
JSObject*
GetChannel() const
GetChannel(nsresult& aRv) const
{
return NULL;
}
JS::Value
GetInterface(JSObject* aIID, ErrorResult& aRv)
GetInterface(JSObject* aIID, nsresult& aRv)
{
aRv.Throw(NS_ERROR_FAILURE);
aRv = NS_ERROR_FAILURE;
return JSVAL_NULL;
}
@ -244,14 +244,14 @@ private:
ReleaseProxy(ReleaseType aType = Default);
void
MaybePin(ErrorResult& aRv);
MaybePin(nsresult& aRv);
void
MaybeDispatchPrematureAbortEvents(ErrorResult& aRv);
MaybeDispatchPrematureAbortEvents(nsresult& aRv);
void
DispatchPrematureAbortEvent(JSObject* aTarget, uint8_t aEventType,
bool aUploadTarget, ErrorResult& aRv);
bool aUploadTarget, nsresult& aRv);
bool
SendInProgress() const
@ -263,7 +263,7 @@ private:
SendInternal(const nsAString& aStringBody,
JSAutoStructuredCloneBuffer& aBody,
nsTArray<nsCOMPtr<nsISupports> >& aClonedObjects,
ErrorResult& aRv);
nsresult& aRv);
};
END_WORKERS_NAMESPACE

Просмотреть файл

@ -29,13 +29,13 @@ public:
#define IMPL_GETTER_AND_SETTER(_type) \
JSObject* \
GetOn##_type(ErrorResult& aRv) \
GetOn##_type(nsresult& aRv) \
{ \
return GetEventListener(NS_LITERAL_STRING(#_type), aRv); \
} \
\
void \
SetOn##_type(JSObject* aListener, ErrorResult& aRv) \
SetOn##_type(JSObject* aListener, nsresult& aRv) \
{ \
SetEventListener(NS_LITERAL_STRING(#_type), aListener, aRv); \
}