dom/bluetooth/ipc/BluetoothParent.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/bluetooth/ipc/BluetoothParent.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,647 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "base/basictypes.h"
    1.11 +
    1.12 +#include "BluetoothParent.h"
    1.13 +
    1.14 +#include "mozilla/Assertions.h"
    1.15 +#include "mozilla/unused.h"
    1.16 +#include "nsDebug.h"
    1.17 +#include "nsISupportsImpl.h"
    1.18 +#include "nsThreadUtils.h"
    1.19 +
    1.20 +#include "BluetoothReplyRunnable.h"
    1.21 +#include "BluetoothService.h"
    1.22 +
    1.23 +using mozilla::unused;
    1.24 +USING_BLUETOOTH_NAMESPACE
    1.25 +
    1.26 +/*******************************************************************************
    1.27 + * BluetoothRequestParent::ReplyRunnable
    1.28 + ******************************************************************************/
    1.29 +
    1.30 +class BluetoothRequestParent::ReplyRunnable : public BluetoothReplyRunnable
    1.31 +{
    1.32 +  BluetoothRequestParent* mRequest;
    1.33 +
    1.34 +public:
    1.35 +  ReplyRunnable(BluetoothRequestParent* aRequest)
    1.36 +  : BluetoothReplyRunnable(nullptr), mRequest(aRequest)
    1.37 +  {
    1.38 +    MOZ_ASSERT(NS_IsMainThread());
    1.39 +    MOZ_ASSERT(aRequest);
    1.40 +  }
    1.41 +
    1.42 +  NS_IMETHOD
    1.43 +  Run() MOZ_OVERRIDE
    1.44 +  {
    1.45 +    MOZ_ASSERT(NS_IsMainThread());
    1.46 +    MOZ_ASSERT(mReply);
    1.47 +
    1.48 +    if (mRequest) {
    1.49 +      // Must do this first because Send__delete__ will delete mRequest.
    1.50 +      mRequest->RequestComplete();
    1.51 +
    1.52 +      if (!mRequest->Send__delete__(mRequest, *mReply)) {
    1.53 +        BT_WARNING("Failed to send response to child process!");
    1.54 +        return NS_ERROR_FAILURE;
    1.55 +      }
    1.56 +    }
    1.57 +
    1.58 +    ReleaseMembers();
    1.59 +    return NS_OK;
    1.60 +  }
    1.61 +
    1.62 +  void
    1.63 +  Revoke()
    1.64 +  {
    1.65 +    MOZ_ASSERT(NS_IsMainThread());
    1.66 +    mRequest = nullptr;
    1.67 +  }
    1.68 +
    1.69 +  virtual bool
    1.70 +  ParseSuccessfulReply(JS::MutableHandle<JS::Value> aValue) MOZ_OVERRIDE
    1.71 +  {
    1.72 +    MOZ_CRASH("This should never be called!");
    1.73 +  }
    1.74 +};
    1.75 +
    1.76 +/*******************************************************************************
    1.77 + * BluetoothParent
    1.78 + ******************************************************************************/
    1.79 +
    1.80 +BluetoothParent::BluetoothParent()
    1.81 +: mShutdownState(Running)
    1.82 +{
    1.83 +  MOZ_COUNT_CTOR(BluetoothParent);
    1.84 +}
    1.85 +
    1.86 +BluetoothParent::~BluetoothParent()
    1.87 +{
    1.88 +  MOZ_COUNT_DTOR(BluetoothParent);
    1.89 +  MOZ_ASSERT(!mService);
    1.90 +  MOZ_ASSERT(mShutdownState == Dead);
    1.91 +}
    1.92 +
    1.93 +void
    1.94 +BluetoothParent::BeginShutdown()
    1.95 +{
    1.96 +  // Only do something here if we haven't yet begun the shutdown sequence.
    1.97 +  if (mShutdownState == Running) {
    1.98 +    unused << SendBeginShutdown();
    1.99 +    mShutdownState = SentBeginShutdown;
   1.100 +  }
   1.101 +}
   1.102 +
   1.103 +bool
   1.104 +BluetoothParent::InitWithService(BluetoothService* aService)
   1.105 +{
   1.106 +  MOZ_ASSERT(aService);
   1.107 +  MOZ_ASSERT(!mService);
   1.108 +
   1.109 +  if (!SendEnabled(aService->IsEnabled())) {
   1.110 +    return false;
   1.111 +  }
   1.112 +
   1.113 +  mService = aService;
   1.114 +  return true;
   1.115 +}
   1.116 +
   1.117 +void
   1.118 +BluetoothParent::UnregisterAllSignalHandlers()
   1.119 +{
   1.120 +  MOZ_ASSERT(mService);
   1.121 +  mService->UnregisterAllSignalHandlers(this);
   1.122 +}
   1.123 +
   1.124 +void
   1.125 +BluetoothParent::ActorDestroy(ActorDestroyReason aWhy)
   1.126 +{
   1.127 +  if (mService) {
   1.128 +    UnregisterAllSignalHandlers();
   1.129 +#ifdef DEBUG
   1.130 +    mService = nullptr;
   1.131 +#endif
   1.132 +  }
   1.133 +
   1.134 +#ifdef DEBUG
   1.135 +  mShutdownState = Dead;
   1.136 +#endif
   1.137 +}
   1.138 +
   1.139 +bool
   1.140 +BluetoothParent::RecvRegisterSignalHandler(const nsString& aNode)
   1.141 +{
   1.142 +  MOZ_ASSERT(mService);
   1.143 +  mService->RegisterBluetoothSignalHandler(aNode, this);
   1.144 +  return true;
   1.145 +}
   1.146 +
   1.147 +bool
   1.148 +BluetoothParent::RecvUnregisterSignalHandler(const nsString& aNode)
   1.149 +{
   1.150 +  MOZ_ASSERT(mService);
   1.151 +  mService->UnregisterBluetoothSignalHandler(aNode, this);
   1.152 +  return true;
   1.153 +}
   1.154 +
   1.155 +bool
   1.156 +BluetoothParent::RecvStopNotifying()
   1.157 +{
   1.158 +  MOZ_ASSERT(mService);
   1.159 +
   1.160 +  if (mShutdownState != Running && mShutdownState != SentBeginShutdown) {
   1.161 +    MOZ_ASSERT(false, "Bad state!");
   1.162 +    return false;
   1.163 +  }
   1.164 +
   1.165 +  mShutdownState = ReceivedStopNotifying;
   1.166 +
   1.167 +  UnregisterAllSignalHandlers();
   1.168 +
   1.169 +  if (SendNotificationsStopped()) {
   1.170 +    mShutdownState = SentNotificationsStopped;
   1.171 +    return true;
   1.172 +  }
   1.173 +
   1.174 +  return false;
   1.175 +}
   1.176 +
   1.177 +bool
   1.178 +BluetoothParent::RecvPBluetoothRequestConstructor(
   1.179 +                                                PBluetoothRequestParent* aActor,
   1.180 +                                                const Request& aRequest)
   1.181 +{
   1.182 +  BluetoothRequestParent* actor = static_cast<BluetoothRequestParent*>(aActor);
   1.183 +
   1.184 +#ifdef DEBUG
   1.185 +  actor->mRequestType = aRequest.type();
   1.186 +#endif
   1.187 +
   1.188 +  switch (aRequest.type()) {
   1.189 +    case Request::TDefaultAdapterPathRequest:
   1.190 +      return actor->DoRequest(aRequest.get_DefaultAdapterPathRequest());
   1.191 +    case Request::TSetPropertyRequest:
   1.192 +      return actor->DoRequest(aRequest.get_SetPropertyRequest());
   1.193 +    case Request::TStartDiscoveryRequest:
   1.194 +      return actor->DoRequest(aRequest.get_StartDiscoveryRequest());
   1.195 +    case Request::TStopDiscoveryRequest:
   1.196 +      return actor->DoRequest(aRequest.get_StopDiscoveryRequest());
   1.197 +    case Request::TPairRequest:
   1.198 +      return actor->DoRequest(aRequest.get_PairRequest());
   1.199 +    case Request::TUnpairRequest:
   1.200 +      return actor->DoRequest(aRequest.get_UnpairRequest());
   1.201 +    case Request::TPairedDevicePropertiesRequest:
   1.202 +      return actor->DoRequest(aRequest.get_PairedDevicePropertiesRequest());
   1.203 +    case Request::TConnectedDevicePropertiesRequest:
   1.204 +      return actor->DoRequest(aRequest.get_ConnectedDevicePropertiesRequest());
   1.205 +    case Request::TSetPinCodeRequest:
   1.206 +      return actor->DoRequest(aRequest.get_SetPinCodeRequest());
   1.207 +    case Request::TSetPasskeyRequest:
   1.208 +      return actor->DoRequest(aRequest.get_SetPasskeyRequest());
   1.209 +    case Request::TConfirmPairingConfirmationRequest:
   1.210 +      return actor->DoRequest(aRequest.get_ConfirmPairingConfirmationRequest());
   1.211 +    case Request::TDenyPairingConfirmationRequest:
   1.212 +      return actor->DoRequest(aRequest.get_DenyPairingConfirmationRequest());
   1.213 +    case Request::TConnectRequest:
   1.214 +      return actor->DoRequest(aRequest.get_ConnectRequest());
   1.215 +    case Request::TDisconnectRequest:
   1.216 +      return actor->DoRequest(aRequest.get_DisconnectRequest());
   1.217 +    case Request::TSendFileRequest:
   1.218 +      return actor->DoRequest(aRequest.get_SendFileRequest());
   1.219 +    case Request::TStopSendingFileRequest:
   1.220 +      return actor->DoRequest(aRequest.get_StopSendingFileRequest());
   1.221 +    case Request::TConfirmReceivingFileRequest:
   1.222 +      return actor->DoRequest(aRequest.get_ConfirmReceivingFileRequest());
   1.223 +    case Request::TDenyReceivingFileRequest:
   1.224 +      return actor->DoRequest(aRequest.get_DenyReceivingFileRequest());
   1.225 +    case Request::TConnectScoRequest:
   1.226 +      return actor->DoRequest(aRequest.get_ConnectScoRequest());
   1.227 +    case Request::TDisconnectScoRequest:
   1.228 +      return actor->DoRequest(aRequest.get_DisconnectScoRequest());
   1.229 +    case Request::TIsScoConnectedRequest:
   1.230 +      return actor->DoRequest(aRequest.get_IsScoConnectedRequest());
   1.231 +#ifdef MOZ_B2G_RIL
   1.232 +    case Request::TAnswerWaitingCallRequest:
   1.233 +      return actor->DoRequest(aRequest.get_AnswerWaitingCallRequest());
   1.234 +    case Request::TIgnoreWaitingCallRequest:
   1.235 +      return actor->DoRequest(aRequest.get_IgnoreWaitingCallRequest());
   1.236 +    case Request::TToggleCallsRequest:
   1.237 +      return actor->DoRequest(aRequest.get_ToggleCallsRequest());
   1.238 +#endif
   1.239 +    case Request::TSendMetaDataRequest:
   1.240 +      return actor->DoRequest(aRequest.get_SendMetaDataRequest());
   1.241 +    case Request::TSendPlayStatusRequest:
   1.242 +      return actor->DoRequest(aRequest.get_SendPlayStatusRequest());
   1.243 +    default:
   1.244 +      MOZ_CRASH("Unknown type!");
   1.245 +  }
   1.246 +
   1.247 +  MOZ_CRASH("Should never get here!");
   1.248 +}
   1.249 +
   1.250 +PBluetoothRequestParent*
   1.251 +BluetoothParent::AllocPBluetoothRequestParent(const Request& aRequest)
   1.252 +{
   1.253 +  MOZ_ASSERT(mService);
   1.254 +  return new BluetoothRequestParent(mService);
   1.255 +}
   1.256 +
   1.257 +bool
   1.258 +BluetoothParent::DeallocPBluetoothRequestParent(PBluetoothRequestParent* aActor)
   1.259 +{
   1.260 +  delete aActor;
   1.261 +  return true;
   1.262 +}
   1.263 +
   1.264 +void
   1.265 +BluetoothParent::Notify(const BluetoothSignal& aSignal)
   1.266 +{
   1.267 +  unused << SendNotify(aSignal);
   1.268 +}
   1.269 +
   1.270 +/*******************************************************************************
   1.271 + * BluetoothRequestParent
   1.272 + ******************************************************************************/
   1.273 +
   1.274 +BluetoothRequestParent::BluetoothRequestParent(BluetoothService* aService)
   1.275 +: mService(aService)
   1.276 +#ifdef DEBUG
   1.277 +  , mRequestType(Request::T__None)
   1.278 +#endif
   1.279 +{
   1.280 +  MOZ_COUNT_CTOR(BluetoothRequestParent);
   1.281 +  MOZ_ASSERT(aService);
   1.282 +
   1.283 +  mReplyRunnable = new ReplyRunnable(this);
   1.284 +}
   1.285 +
   1.286 +BluetoothRequestParent::~BluetoothRequestParent()
   1.287 +{
   1.288 +  MOZ_COUNT_DTOR(BluetoothRequestParent);
   1.289 +
   1.290 +  // mReplyRunnable will be automatically revoked.
   1.291 +}
   1.292 +
   1.293 +void
   1.294 +BluetoothRequestParent::ActorDestroy(ActorDestroyReason aWhy)
   1.295 +{
   1.296 +  mReplyRunnable.Revoke();
   1.297 +}
   1.298 +
   1.299 +void
   1.300 +BluetoothRequestParent::RequestComplete()
   1.301 +{
   1.302 +  MOZ_ASSERT(NS_IsMainThread());
   1.303 +  MOZ_ASSERT(mReplyRunnable.IsPending());
   1.304 +
   1.305 +  mReplyRunnable.Forget();
   1.306 +}
   1.307 +
   1.308 +bool
   1.309 +BluetoothRequestParent::DoRequest(const DefaultAdapterPathRequest& aRequest)
   1.310 +{
   1.311 +  MOZ_ASSERT(mService);
   1.312 +  MOZ_ASSERT(mRequestType == Request::TDefaultAdapterPathRequest);
   1.313 +
   1.314 +  nsresult rv = mService->GetDefaultAdapterPathInternal(mReplyRunnable.get());
   1.315 +  NS_ENSURE_SUCCESS(rv, false);
   1.316 +
   1.317 +  return true;
   1.318 +}
   1.319 +
   1.320 +bool
   1.321 +BluetoothRequestParent::DoRequest(const SetPropertyRequest& aRequest)
   1.322 +{
   1.323 +  MOZ_ASSERT(mService);
   1.324 +  MOZ_ASSERT(mRequestType == Request::TSetPropertyRequest);
   1.325 +
   1.326 +  nsresult rv =
   1.327 +    mService->SetProperty(aRequest.type(), aRequest.value(),
   1.328 +                          mReplyRunnable.get());
   1.329 +  NS_ENSURE_SUCCESS(rv, false);
   1.330 +
   1.331 +  return true;
   1.332 +}
   1.333 +
   1.334 +bool
   1.335 +BluetoothRequestParent::DoRequest(const StartDiscoveryRequest& aRequest)
   1.336 +{
   1.337 +  MOZ_ASSERT(mService);
   1.338 +  MOZ_ASSERT(mRequestType == Request::TStartDiscoveryRequest);
   1.339 +
   1.340 +  nsresult rv =
   1.341 +    mService->StartDiscoveryInternal(mReplyRunnable.get());
   1.342 +  NS_ENSURE_SUCCESS(rv, false);
   1.343 +
   1.344 +  return true;
   1.345 +}
   1.346 +
   1.347 +bool
   1.348 +BluetoothRequestParent::DoRequest(const StopDiscoveryRequest& aRequest)
   1.349 +{
   1.350 +  MOZ_ASSERT(mService);
   1.351 +  MOZ_ASSERT(mRequestType == Request::TStopDiscoveryRequest);
   1.352 +
   1.353 +  nsresult rv =
   1.354 +    mService->StopDiscoveryInternal(mReplyRunnable.get());
   1.355 +  NS_ENSURE_SUCCESS(rv, false);
   1.356 +
   1.357 +  return true;
   1.358 +}
   1.359 +
   1.360 +bool
   1.361 +BluetoothRequestParent::DoRequest(const PairRequest& aRequest)
   1.362 +{
   1.363 +  MOZ_ASSERT(mService);
   1.364 +  MOZ_ASSERT(mRequestType == Request::TPairRequest);
   1.365 +
   1.366 +  nsresult rv =
   1.367 +    mService->CreatePairedDeviceInternal(aRequest.address(),
   1.368 +                                         aRequest.timeoutMS(),
   1.369 +                                         mReplyRunnable.get());
   1.370 +  NS_ENSURE_SUCCESS(rv, false);
   1.371 +
   1.372 +  return true;
   1.373 +}
   1.374 +
   1.375 +bool
   1.376 +BluetoothRequestParent::DoRequest(const UnpairRequest& aRequest)
   1.377 +{
   1.378 +  MOZ_ASSERT(mService);
   1.379 +  MOZ_ASSERT(mRequestType == Request::TUnpairRequest);
   1.380 +
   1.381 +  nsresult rv =
   1.382 +    mService->RemoveDeviceInternal(aRequest.address(),
   1.383 +                                   mReplyRunnable.get());
   1.384 +  NS_ENSURE_SUCCESS(rv, false);
   1.385 +
   1.386 +  return true;
   1.387 +}
   1.388 +
   1.389 +bool
   1.390 +BluetoothRequestParent::DoRequest(const PairedDevicePropertiesRequest& aRequest)
   1.391 +{
   1.392 +  MOZ_ASSERT(mService);
   1.393 +  MOZ_ASSERT(mRequestType == Request::TPairedDevicePropertiesRequest);
   1.394 +
   1.395 +  nsresult rv =
   1.396 +    mService->GetPairedDevicePropertiesInternal(aRequest.addresses(),
   1.397 +                                                mReplyRunnable.get());
   1.398 +  NS_ENSURE_SUCCESS(rv, false);
   1.399 +  return true;
   1.400 +}
   1.401 +
   1.402 +bool
   1.403 +BluetoothRequestParent::DoRequest(const ConnectedDevicePropertiesRequest& aRequest)
   1.404 +{
   1.405 +  MOZ_ASSERT(mService);
   1.406 +  MOZ_ASSERT(mRequestType == Request::TConnectedDevicePropertiesRequest);
   1.407 +  nsresult rv =
   1.408 +    mService->GetConnectedDevicePropertiesInternal(aRequest.serviceUuid(),
   1.409 +                                                   mReplyRunnable.get());
   1.410 +  NS_ENSURE_SUCCESS(rv, false);
   1.411 +
   1.412 +  return true;
   1.413 +}
   1.414 +
   1.415 +bool
   1.416 +BluetoothRequestParent::DoRequest(const SetPinCodeRequest& aRequest)
   1.417 +{
   1.418 +  MOZ_ASSERT(mService);
   1.419 +  MOZ_ASSERT(mRequestType == Request::TSetPinCodeRequest);
   1.420 +
   1.421 +  bool result =
   1.422 +    mService->SetPinCodeInternal(aRequest.path(),
   1.423 +                                 aRequest.pincode(),
   1.424 +                                 mReplyRunnable.get());
   1.425 +
   1.426 +  NS_ENSURE_TRUE(result, false);
   1.427 +
   1.428 +  return true;
   1.429 +}
   1.430 +
   1.431 +bool
   1.432 +BluetoothRequestParent::DoRequest(const SetPasskeyRequest& aRequest)
   1.433 +{
   1.434 +  MOZ_ASSERT(mService);
   1.435 +  MOZ_ASSERT(mRequestType == Request::TSetPasskeyRequest);
   1.436 +
   1.437 +  bool result =
   1.438 +    mService->SetPasskeyInternal(aRequest.path(),
   1.439 +                                 aRequest.passkey(),
   1.440 +                                 mReplyRunnable.get());
   1.441 +
   1.442 +  NS_ENSURE_TRUE(result, false);
   1.443 +
   1.444 +  return true;
   1.445 +}
   1.446 +
   1.447 +bool
   1.448 +BluetoothRequestParent::DoRequest(const ConfirmPairingConfirmationRequest&
   1.449 +                                  aRequest)
   1.450 +{
   1.451 +  MOZ_ASSERT(mService);
   1.452 +  MOZ_ASSERT(mRequestType == Request::TConfirmPairingConfirmationRequest);
   1.453 +
   1.454 +  bool result =
   1.455 +    mService->SetPairingConfirmationInternal(aRequest.path(),
   1.456 +                                             true,
   1.457 +                                             mReplyRunnable.get());
   1.458 +
   1.459 +  NS_ENSURE_TRUE(result, false);
   1.460 +
   1.461 +  return true;
   1.462 +}
   1.463 +
   1.464 +bool
   1.465 +BluetoothRequestParent::DoRequest(const DenyPairingConfirmationRequest&
   1.466 +                                  aRequest)
   1.467 +{
   1.468 +  MOZ_ASSERT(mService);
   1.469 +  MOZ_ASSERT(mRequestType == Request::TDenyPairingConfirmationRequest);
   1.470 +
   1.471 +  bool result =
   1.472 +    mService->SetPairingConfirmationInternal(aRequest.path(),
   1.473 +                                             false,
   1.474 +                                             mReplyRunnable.get());
   1.475 +
   1.476 +  NS_ENSURE_TRUE(result, false);
   1.477 +
   1.478 +  return true;
   1.479 +}
   1.480 +
   1.481 +bool
   1.482 +BluetoothRequestParent::DoRequest(const ConnectRequest& aRequest)
   1.483 +{
   1.484 +  MOZ_ASSERT(mService);
   1.485 +  MOZ_ASSERT(mRequestType == Request::TConnectRequest);
   1.486 +
   1.487 +  mService->Connect(aRequest.address(),
   1.488 +                    aRequest.cod(),
   1.489 +                    aRequest.serviceUuid(),
   1.490 +                    mReplyRunnable.get());
   1.491 +
   1.492 +  return true;
   1.493 +}
   1.494 +
   1.495 +bool
   1.496 +BluetoothRequestParent::DoRequest(const DisconnectRequest& aRequest)
   1.497 +{
   1.498 +  MOZ_ASSERT(mService);
   1.499 +  MOZ_ASSERT(mRequestType == Request::TDisconnectRequest);
   1.500 +
   1.501 +  mService->Disconnect(aRequest.address(),
   1.502 +                       aRequest.serviceUuid(),
   1.503 +                       mReplyRunnable.get());
   1.504 +
   1.505 +  return true;
   1.506 +}
   1.507 +
   1.508 +bool
   1.509 +BluetoothRequestParent::DoRequest(const SendFileRequest& aRequest)
   1.510 +{
   1.511 +  MOZ_ASSERT(mService);
   1.512 +  MOZ_ASSERT(mRequestType == Request::TSendFileRequest);
   1.513 +
   1.514 +  mService->SendFile(aRequest.devicePath(),
   1.515 +                     (BlobParent*)aRequest.blobParent(),
   1.516 +                     (BlobChild*)aRequest.blobChild(),
   1.517 +                     mReplyRunnable.get());
   1.518 +
   1.519 +  return true;
   1.520 +}
   1.521 +
   1.522 +bool
   1.523 +BluetoothRequestParent::DoRequest(const StopSendingFileRequest& aRequest)
   1.524 +{
   1.525 +  MOZ_ASSERT(mService);
   1.526 +  MOZ_ASSERT(mRequestType == Request::TStopSendingFileRequest);
   1.527 +
   1.528 +  mService->StopSendingFile(aRequest.devicePath(),
   1.529 +                            mReplyRunnable.get());
   1.530 +
   1.531 +  return true;
   1.532 +}
   1.533 +
   1.534 +bool
   1.535 +BluetoothRequestParent::DoRequest(const ConfirmReceivingFileRequest& aRequest)
   1.536 +{
   1.537 +  MOZ_ASSERT(mService);
   1.538 +  MOZ_ASSERT(mRequestType == Request::TConfirmReceivingFileRequest);
   1.539 +
   1.540 +  mService->ConfirmReceivingFile(aRequest.devicePath(),
   1.541 +                                 true,
   1.542 +                                 mReplyRunnable.get());
   1.543 +  return true;
   1.544 +}
   1.545 +
   1.546 +bool
   1.547 +BluetoothRequestParent::DoRequest(const DenyReceivingFileRequest& aRequest)
   1.548 +{
   1.549 +  MOZ_ASSERT(mService);
   1.550 +  MOZ_ASSERT(mRequestType == Request::TDenyReceivingFileRequest);
   1.551 +
   1.552 +  mService->ConfirmReceivingFile(aRequest.devicePath(),
   1.553 +                                 false,
   1.554 +                                 mReplyRunnable.get());
   1.555 +  return true;
   1.556 +}
   1.557 +
   1.558 +bool
   1.559 +BluetoothRequestParent::DoRequest(const ConnectScoRequest& aRequest)
   1.560 +{
   1.561 +  MOZ_ASSERT(mService);
   1.562 +  MOZ_ASSERT(mRequestType == Request::TConnectScoRequest);
   1.563 +
   1.564 +  mService->ConnectSco(mReplyRunnable.get());
   1.565 +  return true;
   1.566 +}
   1.567 +
   1.568 +bool
   1.569 +BluetoothRequestParent::DoRequest(const DisconnectScoRequest& aRequest)
   1.570 +{
   1.571 +  MOZ_ASSERT(mService);
   1.572 +  MOZ_ASSERT(mRequestType == Request::TDisconnectScoRequest);
   1.573 +
   1.574 +  mService->DisconnectSco(mReplyRunnable.get());
   1.575 +  return true;
   1.576 +}
   1.577 +
   1.578 +bool
   1.579 +BluetoothRequestParent::DoRequest(const IsScoConnectedRequest& aRequest)
   1.580 +{
   1.581 +  MOZ_ASSERT(mService);
   1.582 +  MOZ_ASSERT(mRequestType == Request::TIsScoConnectedRequest);
   1.583 +
   1.584 +  mService->IsScoConnected(mReplyRunnable.get());
   1.585 +  return true;
   1.586 +}
   1.587 +
   1.588 +#ifdef MOZ_B2G_RIL
   1.589 +bool
   1.590 +BluetoothRequestParent::DoRequest(const AnswerWaitingCallRequest& aRequest)
   1.591 +{
   1.592 +  MOZ_ASSERT(mService);
   1.593 +  MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
   1.594 +
   1.595 +  mService->AnswerWaitingCall(mReplyRunnable.get());
   1.596 +
   1.597 +  return true;
   1.598 +}
   1.599 +
   1.600 +bool
   1.601 +BluetoothRequestParent::DoRequest(const IgnoreWaitingCallRequest& aRequest)
   1.602 +{
   1.603 +  MOZ_ASSERT(mService);
   1.604 +  MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
   1.605 +
   1.606 +  mService->IgnoreWaitingCall(mReplyRunnable.get());
   1.607 +
   1.608 +  return true;
   1.609 +}
   1.610 +
   1.611 +bool
   1.612 +BluetoothRequestParent::DoRequest(const ToggleCallsRequest& aRequest)
   1.613 +{
   1.614 +  MOZ_ASSERT(mService);
   1.615 +  MOZ_ASSERT(mRequestType == Request::TAnswerWaitingCallRequest);
   1.616 +
   1.617 +  mService->ToggleCalls(mReplyRunnable.get());
   1.618 +
   1.619 +  return true;
   1.620 +}
   1.621 +#endif // MOZ_B2G_RIL
   1.622 +
   1.623 +bool
   1.624 +BluetoothRequestParent::DoRequest(const SendMetaDataRequest& aRequest)
   1.625 +{
   1.626 +  MOZ_ASSERT(mService);
   1.627 +  MOZ_ASSERT(mRequestType == Request::TSendMetaDataRequest);
   1.628 +
   1.629 +  mService->SendMetaData(aRequest.title(),
   1.630 +                         aRequest.artist(),
   1.631 +                         aRequest.album(),
   1.632 +                         aRequest.mediaNumber(),
   1.633 +                         aRequest.totalMediaCount(),
   1.634 +                         aRequest.duration(),
   1.635 +                         mReplyRunnable.get());
   1.636 +  return true;
   1.637 +}
   1.638 +
   1.639 +bool
   1.640 +BluetoothRequestParent::DoRequest(const SendPlayStatusRequest& aRequest)
   1.641 +{
   1.642 +  MOZ_ASSERT(mService);
   1.643 +  MOZ_ASSERT(mRequestType == Request::TSendPlayStatusRequest);
   1.644 +
   1.645 +  mService->SendPlayStatus(aRequest.duration(),
   1.646 +                           aRequest.position(),
   1.647 +                           aRequest.playStatus(),
   1.648 +                           mReplyRunnable.get());
   1.649 +  return true;
   1.650 +}

mercurial