Bug 795410 - patch 1: Basic function prototype, r=qdot

From 2231ac9d0fb159edabb891f8b89afc176fb15c2b Mon Sep 17 00:00:00 2001
This commit is contained in:
Eric Chou 2012-09-28 18:59:12 +08:00
parent 89fb61bffb
commit 6c110db3b7
9 changed files with 77 additions and 4 deletions

View File

@ -24,6 +24,7 @@
#include "nsXPCOMCIDInternal.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/LazyIdleThread.h"
#include "mozilla/Util.h"
@ -816,7 +817,37 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress,
nsIDOMBlob* aBlob,
nsIDOMDOMRequest** aRequest)
{
// Will implement in another patch
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
NS_WARNING("BluetoothService not available!");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMRequestService> rs = do_GetService("@mozilla.org/dom/dom-request-service;1");
if (!rs) {
NS_WARNING("No DOMRequest Service!");
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMDOMRequest> req;
nsresult rv = rs->CreateRequest(GetOwner(), getter_AddRefs(req));
if (NS_FAILED(rv)) {
NS_WARNING("Can't create DOMRequest!");
return NS_ERROR_FAILURE;
}
BlobChild* actor =
mozilla::dom::ContentChild::GetSingleton()->GetOrCreateActorForBlob(aBlob);
if (!actor) {
NS_WARNING("Can't create actor");
return NS_ERROR_FAILURE;
}
nsRefPtr<BluetoothVoidReplyRunnable> result = new BluetoothVoidReplyRunnable(req);
bs->SendFile(aDeviceAddress, nullptr, actor, result);
req.forget(aRequest);
return NS_OK;
}

View File

@ -12,8 +12,8 @@
#include "BluetoothServiceUuid.h"
#include "ObexBase.h"
#include "mozilla/dom/ipc/Blob.h"
#include "mozilla/RefPtr.h"
#include "nsIDOMFile.h"
USING_BLUETOOTH_NAMESPACE
using namespace mozilla::ipc;
@ -79,7 +79,7 @@ BluetoothOppManager::Disconnect()
}
bool
BluetoothOppManager::SendFile(BlobParent* aParent,
BluetoothOppManager::SendFile(BlobParent* aActor,
BluetoothReplyRunnable* aRunnable)
{
// will implement in another patch.

View File

@ -8,12 +8,12 @@
#define mozilla_dom_bluetooth_bluetoothoppmanager_h__
#include "BluetoothCommon.h"
#include "mozilla/dom/ipc/Blob.h"
#include "mozilla/ipc/UnixSocket.h"
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothReplyRunnable;
class BlobParent;
class BluetoothOppManager : public mozilla::ipc::UnixSocketConsumer
{

View File

@ -8,6 +8,7 @@
#define mozilla_dom_bluetooth_bluetootheventservice_h__
#include "BluetoothCommon.h"
#include "mozilla/dom/ipc/Blob.h"
#include "nsAutoPtr.h"
#include "nsClassHashtable.h"
#include "nsIObserver.h"
@ -279,6 +280,12 @@ public:
virtual void
DisconnectObjectPush(BluetoothReplyRunnable* aRunnable) = 0;
virtual bool
SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable) = 0;
bool
IsEnabled() const
{

View File

@ -15,6 +15,7 @@
* limitations under the License.
*/
#include "base/basictypes.h"
#include "BluetoothGonkService.h"
#include "BluetoothDBusService.h"

View File

@ -326,6 +326,17 @@ BluetoothServiceChildProcess::DisconnectObjectPush(
SendRequest(aRunnable, DisconnectObjectPushRequest());
}
bool
BluetoothServiceChildProcess::SendFile(
const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable)
{
// Will implement in another patch
return true;
}
nsresult
BluetoothServiceChildProcess::HandleStartup()
{

View File

@ -138,6 +138,12 @@ public:
virtual void
DisconnectObjectPush(BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
virtual bool
SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable) MOZ_OVERRIDE;
protected:
BluetoothServiceChildProcess();
virtual ~BluetoothServiceChildProcess();

View File

@ -2409,3 +2409,14 @@ BluetoothDBusService::GetSocketViaService(const nsAString& aObjectPath,
return NS_OK;
}
bool
BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable)
{
BluetoothOppManager* opp = BluetoothOppManager::Get();
opp->SendFile(aBlobParent, aRunnable);
return true;
}

View File

@ -128,6 +128,12 @@ public:
virtual void
DisconnectObjectPush(BluetoothReplyRunnable* aRunnable);
virtual bool
SendFile(const nsAString& aDeviceAddress,
BlobParent* aBlobParent,
BlobChild* aBlobChild,
BluetoothReplyRunnable* aRunnable);
private:
nsresult SendGetPropertyMessage(const nsAString& aPath,
const char* aInterface,