Backed out changeset 3e6be7551207 (bug 888595) for mochitest failure

This commit is contained in:
Carsten "Tomcat" Book 2013-08-12 18:08:19 +02:00
parent 5e3c55d3f4
commit 524da22e31
12 changed files with 87 additions and 107 deletions

View File

@ -59,6 +59,7 @@
#include "Telephony.h"
#endif
#ifdef MOZ_B2G_BT
#include "nsIDOMBluetoothManager.h"
#include "BluetoothManager.h"
#endif
#include "nsIDOMCameraManager.h"
@ -1248,7 +1249,7 @@ Navigator::GetMozMobileConnection(ErrorResult& aRv)
#endif // MOZ_B2G_RIL
#ifdef MOZ_B2G_BT
bluetooth::BluetoothManager*
nsIDOMBluetoothManager*
Navigator::GetMozBluetooth(ErrorResult& aRv)
{
if (!mBluetooth) {
@ -1275,7 +1276,7 @@ Navigator::EnsureMessagesManager()
nsresult rv;
nsCOMPtr<nsIDOMNavigatorSystemMessages> messageManager =
do_CreateInstance("@mozilla.org/system-message-manager;1", &rv);
nsCOMPtr<nsIDOMGlobalPropertyInitializer> gpi =
do_QueryInterface(messageManager);
NS_ENSURE_TRUE(gpi, NS_ERROR_FAILURE);

View File

@ -39,6 +39,10 @@ class nsIDOMMozVoicemail;
class nsIDOMMozIccManager;
#endif // MOZ_B2G_RIL
#ifdef MOZ_B2G_BT
class nsIDOMBluetoothManager;
#endif // MOZ_B2G_BT
#include "nsIDOMNavigatorSystemMessages.h"
#include "DOMCameraManager.h"
@ -87,12 +91,6 @@ class Telephony;
} // namespace Telephony;
#endif
#ifdef MOZ_B2G_BT
namespace bluetooth {
class BluetoothManager;
} // namespace bluetooth
#endif // MOZ_B2G_BT
namespace power {
class PowerManager;
} // namespace power
@ -231,7 +229,7 @@ public:
void GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
#endif // MOZ_GAMEPAD
#ifdef MOZ_B2G_BT
bluetooth::BluetoothManager* GetMozBluetooth(ErrorResult& aRv);
nsIDOMBluetoothManager* GetMozBluetooth(ErrorResult& aRv);
#endif // MOZ_B2G_BT
#ifdef MOZ_TIME_MANAGER
time::TimeManager* GetMozTime(ErrorResult& aRv);
@ -326,7 +324,7 @@ private:
nsRefPtr<icc::IccManager> mIccManager;
#endif
#ifdef MOZ_B2G_BT
nsCOMPtr<bluetooth::BluetoothManager> mBluetooth;
nsCOMPtr<nsIDOMBluetoothManager> mBluetooth;
#endif
#ifdef MOZ_AUDIO_CHANNEL_MANAGER
nsRefPtr<system::AudioChannelManager> mAudioChannelManager;

View File

@ -232,6 +232,7 @@ using mozilla::dom::workers::ResolveWorkerClasses;
#endif
#ifdef MOZ_B2G_BT
#include "BluetoothManager.h"
#include "BluetoothAdapter.h"
#include "BluetoothDevice.h"
#endif
@ -632,6 +633,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
#endif
#ifdef MOZ_B2G_BT
NS_DEFINE_CLASSINFO_DATA(BluetoothManager, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(BluetoothAdapter, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(BluetoothDevice, nsEventTargetSH,
@ -1524,6 +1527,10 @@ nsDOMClassInfo::Init()
#endif
#ifdef MOZ_B2G_BT
DOM_CLASSINFO_MAP_BEGIN(BluetoothManager, nsIDOMBluetoothManager)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothManager)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(BluetoothAdapter, nsIDOMBluetoothAdapter)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothAdapter)
DOM_CLASSINFO_MAP_END

View File

@ -136,6 +136,7 @@ DOMCI_CLASS(FMRadio)
#endif
#ifdef MOZ_B2G_BT
DOMCI_CLASS(BluetoothManager)
DOMCI_CLASS(BluetoothAdapter)
DOMCI_CLASS(BluetoothDevice)
#endif

View File

@ -150,11 +150,6 @@ DOMInterfaces = {
'headerFile': 'BatteryManager.h'
},
'BluetoothManager': {
'nativeType': 'mozilla::dom::bluetooth::BluetoothManager',
'headerFile': 'BluetoothManager.h'
},
'CallEvent': {
'nativeType': 'mozilla::dom::telephony::CallEvent',
'headerFile': 'CallEvent.h',
@ -1749,13 +1744,14 @@ addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
addExternalIface('LockedFile')
addExternalIface('MediaList')
addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
addExternalIface('MozBluetoothManager', nativeType='nsIDOMBluetoothManager')
addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
addExternalIface('MozCellBroadcast')
addExternalIface('MozConnection', headerFile='nsIDOMConnection.h')
addExternalIface('MozControllers', nativeType='nsIControllers')
addExternalIface('MozFrameLoader', nativeType='nsIFrameLoader', notflattened=True)
addExternalIface('MozIccManager', headerFile='nsIDOMIccManager.h')
addExternalIface('MozMediaStreamOptions', nativeType='nsIMediaStreamOptions',
addExternalIface('MozMediaStreamOptions', nativeType='nsIMediaStreamOptions',
headerFile='nsIDOMNavigatorUserMedia.h')
addExternalIface('MozMobileConnection', headerFile='nsIDOMMobileConnection.h')
addExternalIface('MozMobileMessageManager', headerFile='nsIDOMMobileMessageManager.h')

View File

@ -18,14 +18,16 @@
#include "nsThreadUtils.h"
#include "mozilla/Util.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/dom/BluetoothManagerBinding.h"
using namespace mozilla;
USING_BLUETOOTH_NAMESPACE
// QueryInterface implementation for BluetoothManager
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothManager)
DOMCI_DATA(BluetoothManager, BluetoothManager)
NS_INTERFACE_MAP_BEGIN(BluetoothManager)
NS_INTERFACE_MAP_ENTRY(nsIDOMBluetoothManager)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BluetoothManager)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(BluetoothManager, nsDOMEventTargetHelper)
@ -91,11 +93,9 @@ private:
};
BluetoothManager::BluetoothManager(nsPIDOMWindow *aWindow)
: nsDOMEventTargetHelper(aWindow)
, BluetoothPropertyContainer(BluetoothObjectType::TYPE_MANAGER)
: BluetoothPropertyContainer(BluetoothObjectType::TYPE_MANAGER)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(IsDOMBinding());
BindToOwner(aWindow);
mPath.AssignLiteral("/");
@ -124,44 +124,37 @@ BluetoothManager::SetPropertyByValue(const BluetoothNamedValue& aValue)
#endif
}
bool
BluetoothManager::GetEnabled(ErrorResult& aRv)
NS_IMETHODIMP
BluetoothManager::GetEnabled(bool* aEnabled)
{
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return false;
}
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
return bs->IsEnabled();
*aEnabled = bs->IsEnabled();
return NS_OK;
}
already_AddRefed<dom::DOMRequest>
BluetoothManager::GetDefaultAdapter(ErrorResult& aRv)
NS_IMETHODIMP
BluetoothManager::GetDefaultAdapter(nsIDOMDOMRequest** aAdapter)
{
nsCOMPtr<nsPIDOMWindow> win = GetOwner();
if (!win) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsCOMPtr<nsIDOMRequestService> rs =
do_GetService(DOMREQUEST_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(rs, NS_ERROR_FAILURE);
nsRefPtr<DOMRequest> request = new DOMRequest(win);
nsRefPtr<BluetoothReplyRunnable> results =
new GetAdapterTask(this, request);
nsCOMPtr<nsIDOMDOMRequest> request;
nsresult rv = rs->CreateRequest(GetOwner(), getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<BluetoothReplyRunnable> results = new GetAdapterTask(this, request);
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
NS_ENSURE_TRUE(bs, NS_ERROR_FAILURE);
if (NS_FAILED(bs->GetDefaultAdapterPathInternal(results))) {
return NS_ERROR_FAILURE;
}
nsresult rv = bs->GetDefaultAdapterPathInternal(results);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return nullptr;
}
return request.forget();
request.forget(aAdapter);
return NS_OK;
}
// static
@ -215,20 +208,19 @@ BluetoothManager::Notify(const BluetoothSignal& aData)
}
}
bool
BluetoothManager::IsConnected(uint16_t aProfileId, ErrorResult& aRv)
NS_IMETHODIMP
BluetoothManager::IsConnected(uint16_t aProfileId, bool* aConnected)
{
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return false;
NS_WARNING("BluetoothService not available!");
return NS_ERROR_FAILURE;
}
return bs->IsConnected(aProfileId);
*aConnected = bs->IsConnected(aProfileId);
return NS_OK;
}
NS_IMPL_EVENT_HANDLER(BluetoothManager, enabled)
NS_IMPL_EVENT_HANDLER(BluetoothManager, disabled)
NS_IMPL_EVENT_HANDLER(BluetoothManager, adapteradded)
JSObject*
BluetoothManager::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
return BluetoothManagerBinding::Wrap(aCx, aScope, this);
}

View File

@ -11,25 +11,23 @@
#include "BluetoothCommon.h"
#include "BluetoothPropertyContainer.h"
#include "nsDOMEventTargetHelper.h"
#include "nsIDOMBluetoothManager.h"
#include "mozilla/Observer.h"
#include "nsISupportsImpl.h"
namespace mozilla {
namespace dom {
class DOMRequest;
}
}
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothNamedValue;
class BluetoothManager : public nsDOMEventTargetHelper
, public nsIDOMBluetoothManager
, public BluetoothSignalObserver
, public BluetoothPropertyContainer
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMBLUETOOTHMANAGER
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
// Never returns null
static already_AddRefed<BluetoothManager>
@ -37,24 +35,6 @@ public:
static bool CheckPermission(nsPIDOMWindow* aWindow);
void Notify(const BluetoothSignal& aData);
virtual void SetPropertyByValue(const BluetoothNamedValue& aValue) MOZ_OVERRIDE;
bool GetEnabled(ErrorResult& aRv);
bool IsConnected(uint16_t aProfileId, ErrorResult& aRv);
already_AddRefed<DOMRequest> GetDefaultAdapter(ErrorResult& aRv);
IMPL_EVENT_HANDLER(enabled);
IMPL_EVENT_HANDLER(disabled);
IMPL_EVENT_HANDLER(adapteradded);
nsPIDOMWindow* GetParentObject() const
{
return GetOwner();
}
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
private:
BluetoothManager(nsPIDOMWindow* aWindow);
~BluetoothManager();

View File

@ -21,6 +21,7 @@ if CONFIG['MOZ_B2G_BT']:
'nsIDOMBluetoothAdapter.idl',
'nsIDOMBluetoothDevice.idl',
'nsIDOMBluetoothDeviceEvent.idl',
'nsIDOMBluetoothManager.idl',
'nsIDOMBluetoothStatusChangedEvent.idl',
]

View File

@ -0,0 +1,24 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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 "nsIDOMEventTarget.idl"
interface nsIDOMDOMRequest;
interface nsIDOMBluetoothAdapter;
[scriptable, builtinclass, uuid(303a262a-1dd1-486d-a108-d8c582e86765)]
interface nsIDOMBluetoothManager : nsIDOMEventTarget
{
readonly attribute bool enabled;
nsIDOMDOMRequest getDefaultAdapter();
bool isConnected(in unsigned short aProfile);
[implicit_jscontext] attribute jsval onenabled;
[implicit_jscontext] attribute jsval ondisabled;
[implicit_jscontext] attribute jsval onadapteradded;
};

View File

@ -1,21 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */
interface BluetoothManager : EventTarget {
[Throws]
readonly attribute boolean enabled;
[SetterThrows]
attribute EventHandler onenabled;
[SetterThrows]
attribute EventHandler ondisabled;
[SetterThrows]
attribute EventHandler onadapteradded;
[Throws]
boolean isConnected(unsigned short aProfile);
[Creator, Throws]
DOMRequest? getDefaultAdapter();
};

View File

@ -295,9 +295,11 @@ partial interface Navigator {
#endif // MOZ_GAMEPAD
#ifdef MOZ_B2G_BT
// nsIDOMNavigatorBluetooth
interface MozBluetoothManager;
partial interface Navigator {
[Throws, Func="Navigator::HasBluetoothSupport"]
readonly attribute BluetoothManager mozBluetooth;
readonly attribute MozBluetoothManager mozBluetooth;
};
#endif // MOZ_B2G_BT

View File

@ -477,7 +477,6 @@ webidl_files += \
ifdef MOZ_B2G_BT
webidl_files += \
BluetoothDeviceEvent.webidl \
BluetoothManager.webidl \
BluetoothStatusChangedEvent.webidl \
$(NULL)
endif