зеркало из https://github.com/mozilla/gecko-dev.git
Bug 744700 - B2G 3G: Notify connection errors in the WebMobileConnection API (part 1), r=bent
This commit is contained in:
Родитель
a479bfdafb
Коммит
1bd3305413
|
@ -505,6 +505,7 @@ using mozilla::dom::indexedDB::IDBWrapperCache;
|
|||
#include "nsIDOMMobileConnection.h"
|
||||
#endif
|
||||
#include "USSDReceivedEvent.h"
|
||||
#include "DataErrorEvent.h"
|
||||
#include "mozilla/dom/network/Utils.h"
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
@ -1507,6 +1508,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CLASSINFO_DATA(USSDReceivedEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(DataErrorEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH,
|
||||
|
@ -4158,6 +4162,11 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(DataErrorEvent, nsIDOMDataErrorEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataErrorEvent)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEvent)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSFontFaceRule)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
|
|
@ -413,6 +413,8 @@ DOMCI_CLASS(MozMobileConnection)
|
|||
|
||||
DOMCI_CLASS(USSDReceivedEvent)
|
||||
|
||||
DOMCI_CLASS(DataErrorEvent)
|
||||
|
||||
// @font-face in CSS
|
||||
DOMCI_CLASS(CSSFontFaceRule)
|
||||
DOMCI_CLASS(CSSFontFaceStyleDecl)
|
||||
|
|
|
@ -18,6 +18,7 @@ XPIDLSRCS = \
|
|||
nsIDOMConnection.idl \
|
||||
nsIDOMUSSDReceivedEvent.idl \
|
||||
nsIDOMTCPSocket.idl \
|
||||
nsIDOMDataErrorEvent.idl \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_B2G_RIL
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "nsIDOMEvent.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(1cfc45ba-c5d4-11e1-b4c3-00265511db39)]
|
||||
interface nsIDOMDataErrorEvent : nsIDOMEvent
|
||||
{
|
||||
readonly attribute DOMString message;
|
||||
};
|
|
@ -0,0 +1,43 @@
|
|||
/* 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/. */
|
||||
|
||||
#include "DataErrorEvent.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
|
||||
DOMCI_DATA(DataErrorEvent, mozilla::dom::network::DataErrorEvent)
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace network {
|
||||
|
||||
already_AddRefed<DataErrorEvent>
|
||||
DataErrorEvent::Create(nsAString& aMessage)
|
||||
{
|
||||
NS_ASSERTION(!aMessage.IsEmpty(), "Empty message!");
|
||||
|
||||
nsRefPtr<DataErrorEvent> event = new DataErrorEvent();
|
||||
|
||||
event->mMessage = aMessage;
|
||||
|
||||
return event.forget();
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(DataErrorEvent, nsDOMEvent)
|
||||
NS_IMPL_RELEASE_INHERITED(DataErrorEvent, nsDOMEvent)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(DataErrorEvent)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDataErrorEvent)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DataErrorEvent)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
||||
|
||||
NS_IMETHODIMP
|
||||
DataErrorEvent::GetMessage(nsAString& aMessage)
|
||||
{
|
||||
aMessage.Assign(mMessage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_network_dataerrorevent_h
|
||||
#define mozilla_dom_network_dataerrorevent_h
|
||||
|
||||
#include "nsIDOMDataErrorEvent.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace network {
|
||||
|
||||
class DataErrorEvent : public nsDOMEvent,
|
||||
public nsIDOMDataErrorEvent
|
||||
{
|
||||
nsString mMessage;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_FORWARD_TO_NSDOMEVENT
|
||||
NS_DECL_NSIDOMDATAERROREVENT
|
||||
|
||||
static already_AddRefed<DataErrorEvent>
|
||||
Create(nsAString& aMessage);
|
||||
|
||||
nsresult
|
||||
Dispatch(nsIDOMEventTarget* aTarget, const nsAString& aEventType)
|
||||
{
|
||||
NS_ASSERTION(aTarget, "Null pointer!");
|
||||
NS_ASSERTION(!aEventType.IsEmpty(), "Empty event type!");
|
||||
|
||||
nsresult rv = InitEvent(aEventType, false, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = SetTrusted(true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIDOMEvent* thisEvent =
|
||||
static_cast<nsDOMEvent*>(const_cast<DataErrorEvent*>(this));
|
||||
|
||||
bool dummy;
|
||||
rv = aTarget->DispatchEvent(thisEvent, &dummy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
DataErrorEvent()
|
||||
: nsDOMEvent(nullptr, nullptr)
|
||||
{ }
|
||||
|
||||
~DataErrorEvent()
|
||||
{ }
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // mozilla_dom_network_dataerrorevent_h
|
|
@ -33,6 +33,7 @@ CPPSRCS = \
|
|||
Connection.cpp \
|
||||
Utils.cpp \
|
||||
USSDReceivedEvent.cpp \
|
||||
DataErrorEvent.cpp \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_B2G_RIL
|
||||
|
|
|
@ -536,7 +536,8 @@ var interfaceNamesInGlobalScope =
|
|||
"TCPSocket",
|
||||
"MozTimeManager",
|
||||
"MozNavigatorTime",
|
||||
"PermissionSettings"
|
||||
"PermissionSettings",
|
||||
"DataErrorEvent"
|
||||
]
|
||||
|
||||
for (var i in SpecialPowers.Components.interfaces) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче