Bug 1059813: Use getter/setter methods of |UnixSocketRawData| in NFC helpers, r=allstars.chh
authorThomas Zimmermann <tdz@users.sourceforge.net>
Mon, 08 Sep 2014 11:44:01 +0200
changeset 203946 38867ab63da70564d7b8d3a32f91d8f4bfdfc878
parent 203945 26df995c1141c3c67ed8d2a3b803ff88a69500f0
child 203947 903d7d5824ce59f9e5604d88d7e82393f50309fd
push id10451
push usertdz@users.sourceforge.net
push dateMon, 08 Sep 2014 09:46:56 +0000
treeherderb2g-inbound@e8ba4019d6a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstars.chh
bugs1059813
milestone35.0a1
Bug 1059813: Use getter/setter methods of |UnixSocketRawData| in NFC helpers, r=allstars.chh
dom/nfc/gonk/NfcService.cpp
--- a/dom/nfc/gonk/NfcService.cpp
+++ b/dom/nfc/gonk/NfcService.cpp
@@ -194,36 +194,32 @@ public:
   {
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   NS_IMETHOD Run()
   {
     assertIsNfcServiceThread();
 
-    size_t size = mData->mSize;
-    size_t offset = 0;
-
-    while (size > 0) {
+    while (mData->GetSize()) {
       EventOptions event;
-      const uint8_t* data = mData->mData.get();
-      uint32_t parcelSize = ((data[offset + 0] & 0xff) << 24) |
-                            ((data[offset + 1] & 0xff) << 16) |
-                            ((data[offset + 2] & 0xff) <<  8) |
-                             (data[offset + 3] & 0xff);
-      MOZ_ASSERT(parcelSize <= (mData->mSize - offset));
+      const uint8_t* data = mData->GetData();
+      uint32_t parcelSize = ((data[0] & 0xff) << 24) |
+                            ((data[1] & 0xff) << 16) |
+                            ((data[2] & 0xff) <<  8) |
+                             (data[3] & 0xff);
+      MOZ_ASSERT(parcelSize <= mData->GetSize());
 
       Parcel parcel;
-      parcel.setData(&data[offset], parcelSize + sizeof(int));
+      parcel.setData(mData->GetData(), parcelSize + sizeof(parcelSize));
       mHandler->Unmarshall(parcel, event);
       nsCOMPtr<nsIRunnable> runnable = new NfcEventDispatcher(event);
       NS_DispatchToMainThread(runnable);
 
-      size -= parcel.dataSize();
-      offset += parcel.dataSize();
+      mData->Consume(parcelSize + sizeof(parcelSize));
     }
 
     return NS_OK;
   }
 
 private:
   NfcMessageHandler* mHandler;
   nsAutoPtr<UnixSocketRawData> mData;