Bug 822754 - Fix B2G AutoMounter to deal with out-of-order events. r=philikon, a=tracking+
authorDave Hylands <dhylands@mozilla.com>
Fri, 04 Jan 2013 16:19:00 -0800
changeset 118649 4508594f93230453c7196bd2db59e9eae2b5f574
parent 118648 aabed455127edd47e11e90f17286fd3218887fff
child 118650 cc8bbc6ac3900ae4b51dab630fb9e7f509811d54
push id516
push userryanvm@gmail.com
push dateWed, 06 Mar 2013 21:54:09 +0000
reviewersphilikon, tracking
bugs822754
milestone18.0
Bug 822754 - Fix B2G AutoMounter to deal with out-of-order events. r=philikon, a=tracking+
dom/system/gonk/Volume.cpp
--- a/dom/system/gonk/Volume.cpp
+++ b/dom/system/gonk/Volume.cpp
@@ -86,22 +86,23 @@ Volume::SetMediaPresent(bool aMediaPrese
   //    605 Volume sdcard /mnt/sdcard state changed from 1 (Idle-Unmounted) to 0 (No-Media)
   //
   // When sharing with a PC, it goes Mounted -> Idle -> Shared
   // When unsharing with a PC, it goes Shared -> Idle -> Mounted
   //
   // The AutoMounter needs to know whether the media is present or not when
   // processing the Idle state.
 
-  if (mMediaPresent != aMediaPresent) {
-    LOG("Volume: %s media %s", NameStr(), aMediaPresent ? "inserted" : "removed");
-    mMediaPresent = aMediaPresent;
-    // No need to broadcast the change. A state change will be coming right away,
-    // and that will serve the purpose.
+  if (mMediaPresent == aMediaPresent) {
+    return;
   }
+
+  LOG("Volume: %s media %s", NameStr(), aMediaPresent ? "inserted" : "removed");
+  mMediaPresent = aMediaPresent;
+  mEventObserverList.Broadcast(this);
 }
 
 void
 Volume::SetState(Volume::STATE aNewState)
 {
   MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
   MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());