Bug 1059813: Use getter/setter methods of |UnixSocketRawData| in NFC helpers, r=allstars.chh
☠☠ backed out by 927da4815ef9 ☠ ☠
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 03 Sep 2014 16:43:13 +0200
changeset 203370 d08a91fee65a4e4c95fe92e2dbc28b5a13633d78
parent 203369 7bd0ecf96e592fc7050c06236d340decdd65668e
child 203371 ab4056a1aa06d05695a4ecfff2ee7d0356fa3cff
push id48665
push userryanvm@gmail.com
push dateWed, 03 Sep 2014 20:40:15 +0000
treeherdermozilla-inbound@0da762e6868a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersallstars.chh
bugs1059813
milestone35.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 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
@@ -209,36 +209,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;