Bug 712910 - Use stdint types in HAL; r=cjones
authorMs2ger <ms2ger@gmail.com>
Fri, 25 May 2012 09:18:30 +0200
changeset 95321 fb91158d8c9a40803168bfbd4e5b2e8baea2b97f
parent 95320 1cb527eb50412c516ae7ed744592f2f115f707e9
child 95322 059b142ffbc68e3f34616d2ee313a19ca1559b8d
push idunknown
push userunknown
push dateunknown
reviewerscjones
bugs712910
milestone15.0a1
Bug 712910 - Use stdint types in HAL; r=cjones
dom/base/Navigator.cpp
hal/Hal.cpp
hal/Hal.h
hal/WindowIdentifier.cpp
hal/WindowIdentifier.h
hal/android/AndroidHal.cpp
hal/fallback/FallbackVibration.cpp
hal/gonk/GonkHal.cpp
hal/sandbox/SandboxHal.cpp
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -631,20 +631,20 @@ VibrateWindowListener::RemoveListener()
 /**
  * Converts a jsval into a vibration duration, checking that the duration is in
  * bounds (non-negative and not larger than sMaxVibrateMS).
  *
  * Returns true on success, false on failure.
  */
 bool
 GetVibrationDurationFromJsval(const jsval& aJSVal, JSContext* cx,
-                              PRInt32 *aOut)
+                              int32_t* aOut)
 {
   return JS_ValueToInt32(cx, aJSVal, aOut) &&
-         *aOut >= 0 && static_cast<PRUint32>(*aOut) <= sMaxVibrateMS;
+         *aOut >= 0 && static_cast<uint32_t>(*aOut) <= sMaxVibrateMS;
 }
 
 } // anonymous namespace
 
 NS_IMETHODIMP
 Navigator::MozVibrate(const jsval& aPattern, JSContext* cx)
 {
   nsCOMPtr<nsPIDOMWindow> win = do_QueryReferent(mWindow);
@@ -655,25 +655,25 @@ Navigator::MozVibrate(const jsval& aPatt
 
   bool hidden = true;
   domDoc->GetMozHidden(&hidden);
   if (hidden) {
     // Hidden documents cannot start or stop a vibration.
     return NS_OK;
   }
 
-  nsAutoTArray<PRUint32, 8> pattern;
+  nsAutoTArray<uint32_t, 8> pattern;
 
   // null or undefined pattern is an error.
   if (JSVAL_IS_NULL(aPattern) || JSVAL_IS_VOID(aPattern)) {
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
 
   if (JSVAL_IS_PRIMITIVE(aPattern)) {
-    PRInt32 p;
+    int32_t p;
     if (GetVibrationDurationFromJsval(aPattern, cx, &p)) {
       pattern.AppendElement(p);
     }
     else {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
   }
   else {
@@ -681,17 +681,17 @@ Navigator::MozVibrate(const jsval& aPatt
     PRUint32 length;
     if (!JS_GetArrayLength(cx, obj, &length) || length > sMaxVibrateListLen) {
       return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
     }
     pattern.SetLength(length);
 
     for (PRUint32 i = 0; i < length; ++i) {
       jsval v;
-      PRInt32 pv;
+      int32_t pv;
       if (JS_GetElement(cx, obj, i, &v) &&
           GetVibrationDurationFromJsval(v, cx, &pv)) {
         pattern[i] = pv;
       }
       else {
         return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
       }
     }
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -80,23 +80,23 @@ void InitLastIDToVibrate()
 {
   gLastIDToVibrate = new WindowIdentifier::IDArrayType();
   ClearOnShutdown(&gLastIDToVibrate);
 }
 
 } // anonymous namespace
 
 void
-Vibrate(const nsTArray<uint32>& pattern, nsIDOMWindow* window)
+Vibrate(const nsTArray<uint32_t>& pattern, nsIDOMWindow* window)
 {
   Vibrate(pattern, WindowIdentifier(window));
 }
 
 void
-Vibrate(const nsTArray<uint32>& pattern, const WindowIdentifier &id)
+Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id)
 {
   AssertMainThread();
 
   // Only active windows may start vibrations.  If |id| hasn't gone
   // through the IPC layer -- that is, if our caller is the outside
   // world, not hal_proxy -- check whether the window is active.  If
   // |id| has gone through IPC, don't check the window's visibility;
   // only the window corresponding to the bottommost process has its
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -63,19 +63,19 @@ namespace MOZ_HAL_NAMESPACE {
  *
  * Only an active window within an active tab may call Vibrate; calls
  * from inactive windows and windows on inactive tabs do nothing.
  *
  * If you're calling hal::Vibrate from the outside world, pass an
  * nsIDOMWindow* in place of the WindowIdentifier parameter.
  * The method with WindowIdentifier will be called automatically.
  */
-void Vibrate(const nsTArray<uint32>& pattern,
+void Vibrate(const nsTArray<uint32_t>& pattern,
              nsIDOMWindow* aWindow);
-void Vibrate(const nsTArray<uint32>& pattern,
+void Vibrate(const nsTArray<uint32_t>& pattern,
              const hal::WindowIdentifier &id);
 
 /**
  * Cancel a vibration started by the content window identified by
  * WindowIdentifier.
  *
  * If the window was the last window to start a vibration, the
  * cancellation request will go through even if the window is not
--- a/hal/WindowIdentifier.cpp
+++ b/hal/WindowIdentifier.cpp
@@ -19,32 +19,32 @@ WindowIdentifier::WindowIdentifier()
 
 WindowIdentifier::WindowIdentifier(nsIDOMWindow *window)
   : mWindow(window)
   , mIsEmpty(false)
 {
   mID.AppendElement(GetWindowID());
 }
 
-WindowIdentifier::WindowIdentifier(const nsTArray<uint64> &id, nsIDOMWindow *window)
+WindowIdentifier::WindowIdentifier(const nsTArray<uint64_t> &id, nsIDOMWindow *window)
   : mID(id)
   , mWindow(window)
   , mIsEmpty(false)
 {
   mID.AppendElement(GetWindowID());
 }
 
 WindowIdentifier::WindowIdentifier(const WindowIdentifier &other)
   : mID(other.mID)
   , mWindow(other.mWindow)
   , mIsEmpty(other.mIsEmpty)
 {
 }
 
-const InfallibleTArray<uint64>&
+const InfallibleTArray<uint64_t>&
 WindowIdentifier::AsArray() const
 {
   MOZ_ASSERT(!mIsEmpty);
   return mID;
 }
 
 bool
 WindowIdentifier::HasTraveledThroughIPC() const
@@ -55,23 +55,23 @@ WindowIdentifier::HasTraveledThroughIPC(
 
 void
 WindowIdentifier::AppendProcessID()
 {
   MOZ_ASSERT(!mIsEmpty);
   mID.AppendElement(dom::ContentChild::GetSingleton()->GetID());
 }
 
-uint64
+uint64_t
 WindowIdentifier::GetWindowID() const
 {
   MOZ_ASSERT(!mIsEmpty);
   nsCOMPtr<nsPIDOMWindow> pidomWindow = do_QueryInterface(mWindow);
   if (!pidomWindow) {
-    return uint64(-1);
+    return UINT64_MAX;
   }
   return pidomWindow->WindowID();
 }
 
 nsIDOMWindow*
 WindowIdentifier::GetWindow() const
 {
   MOZ_ASSERT(!mIsEmpty);
--- a/hal/WindowIdentifier.h
+++ b/hal/WindowIdentifier.h
@@ -61,22 +61,22 @@ public:
    */
   explicit WindowIdentifier(nsIDOMWindow* window);
 
   /**
    * Create a new WindowIdentifier with the given id array and window.
    * This automatically grabs the window's ID and appends it to the
    * array.
    */
-  WindowIdentifier(const nsTArray<uint64>& id, nsIDOMWindow* window);
+  WindowIdentifier(const nsTArray<uint64_t>& id, nsIDOMWindow* window);
 
   /**
    * Get the list of window and process IDs we contain.
    */
-  typedef InfallibleTArray<uint64> IDArrayType;
+  typedef InfallibleTArray<uint64_t> IDArrayType;
   const IDArrayType& AsArray() const;
 
   /**
    * Append the ID of the ContentChild singleton to our array of
    * window/process IDs.
    */
   void AppendProcessID();
 
@@ -91,19 +91,19 @@ public:
    * Get the window this object wraps.
    */
   nsIDOMWindow* GetWindow() const;
 
 private:
   /**
    * Get the ID of the window object we wrap.
    */
-  uint64 GetWindowID() const;
+  uint64_t GetWindowID() const;
 
-  AutoInfallibleTArray<uint64, 3> mID;
+  AutoInfallibleTArray<uint64_t, 3> mID;
   nsCOMPtr<nsIDOMWindow> mWindow;
   bool mIsEmpty;
 };
 
 } // namespace hal
 } // namespace mozilla
 
 #endif // mozilla_hal_WindowIdentifier_h
--- a/hal/android/AndroidHal.cpp
+++ b/hal/android/AndroidHal.cpp
@@ -13,27 +13,27 @@
 
 using namespace mozilla::dom;
 using namespace mozilla::hal;
 
 namespace mozilla {
 namespace hal_impl {
 
 void
-Vibrate(const nsTArray<uint32> &pattern, const WindowIdentifier &)
+Vibrate(const nsTArray<uint32_t> &pattern, const WindowIdentifier &)
 {
   // Ignore the WindowIdentifier parameter; it's here only because hal::Vibrate,
   // hal_sandbox::Vibrate, and hal_impl::Vibrate all must have the same
   // signature.
 
   // Strangely enough, the Android Java API seems to treat vibrate([0]) as a
   // nop.  But we want to treat vibrate([0]) like CancelVibrate!  (Note that we
   // also need to treat vibrate([]) as a call to CancelVibrate.)
   bool allZero = true;
-  for (uint32 i = 0; i < pattern.Length(); i++) {
+  for (uint32_t i = 0; i < pattern.Length(); i++) {
     if (pattern[i] != 0) {
       allZero = false;
       break;
     }
   }
 
   if (allZero) {
     hal_impl::CancelVibrate(WindowIdentifier());
--- a/hal/fallback/FallbackVibration.cpp
+++ b/hal/fallback/FallbackVibration.cpp
@@ -7,17 +7,17 @@
 #include "Hal.h"
 
 using mozilla::hal::WindowIdentifier;
 
 namespace mozilla {
 namespace hal_impl {
 
 void
-Vibrate(const nsTArray<uint32>& pattern, const hal::WindowIdentifier &)
+Vibrate(const nsTArray<uint32_t>& pattern, const hal::WindowIdentifier &)
 {}
 
 void
 CancelVibrate(const hal::WindowIdentifier &)
 {}
 
 } // hal_impl
 } // namespace mozilla
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -73,28 +73,28 @@ public:
 
     os->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, /* weak ref */ true);
   } 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIRUNNABLE
   NS_DECL_NSIOBSERVER
 
   // Run on the main thread, not the vibrator thread.
-  void Vibrate(const nsTArray<uint32> &pattern);
+  void Vibrate(const nsTArray<uint32_t> &pattern);
   void CancelVibrate();
 
 private:
   Monitor mMonitor;
 
   // The currently-playing pattern.
-  nsTArray<uint32> mPattern;
+  nsTArray<uint32_t> mPattern;
 
   // The index we're at in the currently-playing pattern.  If mIndex >=
   // mPattern.Length(), then we're not currently playing anything.
-  uint32 mIndex;
+  uint32_t mIndex;
 
   // Set to true in our shutdown observer.  When this is true, we kill the
   // vibrator thread.
   bool mShuttingDown;
 };
 
 NS_IMPL_ISUPPORTS2(VibratorRunnable, nsIRunnable, nsIObserver);
 
@@ -109,17 +109,17 @@ VibratorRunnable::Run()
   //
   // This doesn't worry me too much.  Note that we don't even start vibrating
   // immediately when VibratorRunnable::Vibrate is called -- we go through a
   // condvar onto another thread.  Better just to be chill about small errors in
   // the timing here.
 
   while (!mShuttingDown) {
     if (mIndex < mPattern.Length()) {
-      uint32 duration = mPattern[mIndex];
+      uint32_t duration = mPattern[mIndex];
       if (mIndex % 2 == 0) {
         vibrator_on(duration);
       }
       mIndex++;
       mMonitor.Wait(PR_MillisecondsToInterval(duration));
     }
     else {
       mMonitor.Wait();
@@ -136,17 +136,17 @@ VibratorRunnable::Observe(nsISupports *s
   MOZ_ASSERT(strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0);
   MonitorAutoLock lock(mMonitor);
   mShuttingDown = true;
   mMonitor.Notify();
   return NS_OK;
 }
 
 void
-VibratorRunnable::Vibrate(const nsTArray<uint32> &pattern)
+VibratorRunnable::Vibrate(const nsTArray<uint32_t> &pattern)
 {
   MonitorAutoLock lock(mMonitor);
   mPattern = pattern;
   mIndex = 0;
   mMonitor.Notify();
 }
 
 void
@@ -172,17 +172,17 @@ EnsureVibratorThreadInitialized()
   sVibratorRunnable = runnable;
   nsCOMPtr<nsIThread> thread;
   NS_NewThread(getter_AddRefs(thread), sVibratorRunnable);
 }
 
 } // anonymous namespace
 
 void
-Vibrate(const nsTArray<uint32> &pattern, const hal::WindowIdentifier &)
+Vibrate(const nsTArray<uint32_t> &pattern, const hal::WindowIdentifier &)
 {
   EnsureVibratorThreadInitialized();
   sVibratorRunnable->Vibrate(pattern);
 }
 
 void
 CancelVibrate(const hal::WindowIdentifier &)
 {
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -30,21 +30,21 @@ Hal()
 {
   if (!sHal) {
     sHal = ContentChild::GetSingleton()->SendPHalConstructor();
   }
   return sHal;
 }
 
 void
-Vibrate(const nsTArray<uint32>& pattern, const WindowIdentifier &id)
+Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id)
 {
   HAL_LOG(("Vibrate: Sending to parent process."));
 
-  AutoInfallibleTArray<uint32, 8> p(pattern);
+  AutoInfallibleTArray<uint32_t, 8> p(pattern);
 
   WindowIdentifier newID(id);
   newID.AppendProcessID();
   Hal()->SendVibrate(p, newID.AsArray(), GetTabChildFrom(newID.GetWindow()));
 }
 
 void
 CancelVibrate(const WindowIdentifier &id)
@@ -266,17 +266,17 @@ class HalParent : public PHalParent
                 , public ISensorObserver
                 , public WakeLockObserver
                 , public ScreenConfigurationObserver
                 , public SwitchObserver
 {
 public:
   NS_OVERRIDE virtual bool
   RecvVibrate(const InfallibleTArray<unsigned int>& pattern,
-              const InfallibleTArray<uint64> &id,
+              const InfallibleTArray<uint64_t> &id,
               PBrowserParent *browserParent)
   {
     // Check whether browserParent is active.  We should have already
     // checked that the corresponding window is active, but this check
     // isn't redundant.  A window may be inactive in an active
     // browser.  And a window is not notified synchronously when it's
     // deactivated, so the window may think it's active when the tab
     // is actually inactive.
@@ -292,17 +292,17 @@ public:
     nsCOMPtr<nsIDOMWindow> window =
       do_QueryInterface(tabParent->GetBrowserDOMWindow());
     WindowIdentifier newID(id, window);
     hal::Vibrate(pattern, newID);
     return true;
   }
 
   NS_OVERRIDE virtual bool
-  RecvCancelVibrate(const InfallibleTArray<uint64> &id,
+  RecvCancelVibrate(const InfallibleTArray<uint64_t> &id,
                     PBrowserParent *browserParent)
   {
     TabParent *tabParent = static_cast<TabParent*>(browserParent);
     nsCOMPtr<nsIDOMWindow> window =
       do_QueryInterface(tabParent->GetBrowserDOMWindow());
     WindowIdentifier newID(id, window);
     hal::CancelVibrate(newID);
     return true;