Bug 795410 - patch 2: Complete call flow, r=qdot
authorEric Chou <echou@mozilla.com>
Fri, 28 Sep 2012 19:42:04 +0800
changeset 108725 02747dcace863372fef293993a714720af1b8763
parent 108724 17f579c381b17d9035f425cf48e9716c421642c4
child 108726 5b799e7132346d8cf4cde4c1738fdfb4f5edb2d6
push id23585
push useremorley@mozilla.com
push dateMon, 01 Oct 2012 13:02:21 +0000
treeherdermozilla-central@d4355e045ea7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs795410
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 795410 - patch 2: Complete call flow, r=qdot From 9fb76c07818c989ec8edc26b54ba84e1e6ec41ed Mon Sep 17 00:00:00 2001
dom/bluetooth/ipc/BluetoothParent.cpp
dom/bluetooth/ipc/BluetoothParent.h
dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
dom/bluetooth/ipc/PBluetooth.ipdl
dom/bluetooth/linux/BluetoothDBusService.cpp
--- a/dom/bluetooth/ipc/BluetoothParent.cpp
+++ b/dom/bluetooth/ipc/BluetoothParent.cpp
@@ -216,16 +216,18 @@ BluetoothParent::RecvPBluetoothRequestCo
     case Request::TConnectHeadsetRequest:
       return actor->DoRequest(aRequest.get_ConnectHeadsetRequest());
     case Request::TConnectObjectPushRequest:
       return actor->DoRequest(aRequest.get_ConnectObjectPushRequest());
     case Request::TDisconnectHeadsetRequest:
       return actor->DoRequest(aRequest.get_DisconnectHeadsetRequest());
     case Request::TDisconnectObjectPushRequest:
       return actor->DoRequest(aRequest.get_DisconnectObjectPushRequest());
+    case Request::TSendFileRequest:
+      return actor->DoRequest(aRequest.get_SendFileRequest());
     default:
       MOZ_NOT_REACHED("Unknown type!");
       return false;
   }
 
   MOZ_NOT_REACHED("Should never get here!");
   return false;
 }
@@ -533,8 +535,20 @@ BluetoothRequestParent::DoRequest(const 
 {
   MOZ_ASSERT(mService);
   MOZ_ASSERT(mRequestType == Request::TDenyAuthorizationRequest);
 
   mService->DisconnectObjectPush(mReplyRunnable.get());
 
   return true;
 }
+
+bool
+BluetoothRequestParent::DoRequest(const SendFileRequest& aRequest)
+{
+  MOZ_ASSERT(mService);
+  MOZ_ASSERT(mRequestType == Request::TSendFileRequest);
+
+  return mService->SendFile(aRequest.devicePath(),
+                            (BlobParent*)aRequest.blobParent(),
+                            (BlobChild*)aRequest.blobChild(),
+                            mReplyRunnable.get());
+}
--- a/dom/bluetooth/ipc/BluetoothParent.h
+++ b/dom/bluetooth/ipc/BluetoothParent.h
@@ -172,13 +172,16 @@ protected:
   bool
   DoRequest(const ConnectObjectPushRequest& aRequest);
 
   bool
   DoRequest(const DisconnectHeadsetRequest& aRequest);
 
   bool
   DoRequest(const DisconnectObjectPushRequest& aRequest);
+
+  bool
+  DoRequest(const SendFileRequest& aRequest);
 };
 
 END_BLUETOOTH_NAMESPACE
 
 #endif // mozilla_dom_bluetooth_ipc_bluetoothparent_h__
--- a/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
+++ b/dom/bluetooth/ipc/BluetoothServiceChildProcess.cpp
@@ -328,17 +328,18 @@ BluetoothServiceChildProcess::Disconnect
 
 bool
 BluetoothServiceChildProcess::SendFile(
   const nsAString& aDeviceAddress,
   BlobParent* aBlobParent,
   BlobChild* aBlobChild,
   BluetoothReplyRunnable* aRunnable)
 {
-  // Will implement in another patch
+  SendRequest(aRunnable,
+              SendFileRequest(nsString(aDeviceAddress), nullptr, aBlobChild));
   return true;
 }
 
 nsresult
 BluetoothServiceChildProcess::HandleStartup()
 {
   // Don't need to do anything here for startup since our Create function takes
   // care of the actor machinery.
--- a/dom/bluetooth/ipc/PBluetooth.ipdl
+++ b/dom/bluetooth/ipc/PBluetooth.ipdl
@@ -1,14 +1,15 @@
 /* -*- 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 protocol PBlob;
 include protocol PBluetoothRequest;
 include protocol PContent;
 
 include BluetoothTypes;
 
 include "mozilla/dom/bluetooth/ipc/BluetoothMessageUtils.h";
 
 using mozilla::dom::bluetooth::BluetoothObjectType;
@@ -110,16 +111,22 @@ struct ConnectObjectPushRequest
 };
 
 struct DisconnectHeadsetRequest
 {};
 
 struct DisconnectObjectPushRequest
 {};
 
+struct SendFileRequest
+{
+  nsString devicePath;
+  PBlob blob;
+};
+
 union Request
 {
   DefaultAdapterPathRequest;
   SetPropertyRequest;
   GetPropertyRequest;
   StartDiscoveryRequest;
   StopDiscoveryRequest;
   PairRequest;
@@ -130,16 +137,17 @@ union Request
   DenyPairingConfirmationRequest;
   ConfirmAuthorizationRequest;
   DenyAuthorizationRequest;
   DevicePropertiesRequest;
   ConnectHeadsetRequest;
   ConnectObjectPushRequest;
   DisconnectHeadsetRequest;
   DisconnectObjectPushRequest;
+  SendFileRequest;
 };
 
 protocol PBluetooth
 {
   manager PContent;
   manages PBluetoothRequest;
 
   /**
--- a/dom/bluetooth/linux/BluetoothDBusService.cpp
+++ b/dom/bluetooth/linux/BluetoothDBusService.cpp
@@ -2410,13 +2410,17 @@ BluetoothDBusService::GetSocketViaServic
 }
 
 bool
 BluetoothDBusService::SendFile(const nsAString& aDeviceAddress,
                                BlobParent* aBlobParent,
                                BlobChild* aBlobChild,
                                BluetoothReplyRunnable* aRunnable)
 {
+  // Currently we only support one device sending one file at a time,
+  // so we don't need aDeviceAddress here because the target device
+  // has been determined when calling 'Connect()'. Nevertheless, keep
+  // it for future use.
   BluetoothOppManager* opp = BluetoothOppManager::Get();
   opp->SendFile(aBlobParent, aRunnable);
 
   return true;
 }