Bug 1073003 - Avoid returning a reference to a temporary. r=jhlin
authorBotond Ballo <botond@mozilla.com>
Tue, 23 Dec 2014 03:25:21 -0500
changeset 235589 dd0a52ad9cb3cf32f5c837b06cc155d1ddb0ed52
parent 235588 0f9759d2b5215509dd36a9e1e954b65e8c462354
child 235590 6550cdd34f6fce661f2fb72da4974013449ae701
push id366
push usercmanchester@mozilla.com
push dateThu, 08 Jan 2015 16:40:24 +0000
reviewersjhlin
bugs1073003
milestone37.0a1
Bug 1073003 - Avoid returning a reference to a temporary. r=jhlin
dom/media/omx/mediaresourcemanager/MediaResourceManagerService.cpp
dom/media/omx/mediaresourcemanager/MediaResourceManagerService.h
--- a/dom/media/omx/mediaresourcemanager/MediaResourceManagerService.cpp
+++ b/dom/media/omx/mediaresourcemanager/MediaResourceManagerService.cpp
@@ -143,17 +143,17 @@ void MediaResourceManagerService::onMess
     return;
   }
 
   // Exit if no request.
   if (!mResources.hasRequest(type)) {
     return;
   }
 
-  const sp<IBinder>& req = mResources.nextRequest(type);
+  sp<IBinder> req = mResources.nextRequest(type);
   mResources.aquireResource(req, type, found);
   // Notify resource assignment to the client.
   sp<IMediaResourceManagerClient> client = interface_cast<IMediaResourceManagerClient>(req);
   client->statusChanged(MediaResourceManagerClient::CLIENT_STATE_RESOURCE_ASSIGNED);
   mResources.dequeueRequest(type);
 }
 
 void MediaResourceManagerService::cancelClientLocked(const sp<IBinder>& binder,
@@ -287,17 +287,17 @@ uint32_t MediaResourceManagerService::Re
     // Unsupported type.
     return 0;
   }
 
   const Fifo& queue = mMap.valueAt(found).mRequestQueue;
   return queue.size();
 }
 
-const sp<IBinder>& MediaResourceManagerService::ResourceTable::nextRequest(ResourceType type)
+sp<IBinder> MediaResourceManagerService::ResourceTable::nextRequest(ResourceType type)
 {
   ssize_t found = mMap.indexOfKey(type);
   if (found == NAME_NOT_FOUND) {
     // Unsupported type.
     return nullptr;
   }
 
   const Fifo& queue = mMap.valueAt(found).mRequestQueue;
--- a/dom/media/omx/mediaresourcemanager/MediaResourceManagerService.h
+++ b/dom/media/omx/mediaresourcemanager/MediaResourceManagerService.h
@@ -94,17 +94,17 @@ private:
     bool supportsType(ResourceType type);
     ssize_t findAvailableResource(ResourceType type, size_t number_needed = 1);
     bool isOwnedByClient(const sp<IBinder>& client, ResourceType type, size_t index);
     status_t aquireResource(const sp<IBinder>& client, ResourceType type, size_t index);
     ResourceSlot* resourceOfTypeAt(ResourceType type, size_t index);
     // Request operations.
     bool hasRequest(ResourceType type);
     uint32_t countRequests(ResourceType type);
-    const sp<IBinder>& nextRequest(ResourceType type);
+    sp<IBinder> nextRequest(ResourceType type);
     status_t enqueueRequest(const sp<IBinder>& client, ResourceType type);
     status_t dequeueRequest(ResourceType type);
     status_t forgetClient(const sp<IBinder>& client, ResourceType type);
     status_t forgetClient(const sp<IBinder>& client);
 
     friend class MediaResourceManagerService;
 
     // A map for all types of supported resources.