Bug 712910 - Use stdint types in HAL; r=cjones

This commit is contained in:
Ms2ger
2012-05-25 09:18:30 +02:00
parent e848a8c034
commit bd867a9461
9 changed files with 30 additions and 30 deletions

View File

@@ -636,10 +636,10 @@ VibrateWindowListener::RemoveListener()
*/ */
bool bool
GetVibrationDurationFromJsval(const jsval& aJSVal, JSContext* cx, GetVibrationDurationFromJsval(const jsval& aJSVal, JSContext* cx,
PRInt32 *aOut) int32_t* aOut)
{ {
return JS_ValueToInt32(cx, aJSVal, aOut) && return JS_ValueToInt32(cx, aJSVal, aOut) &&
*aOut >= 0 && static_cast<PRUint32>(*aOut) <= sMaxVibrateMS; *aOut >= 0 && static_cast<uint32_t>(*aOut) <= sMaxVibrateMS;
} }
} // anonymous namespace } // anonymous namespace
@@ -660,7 +660,7 @@ Navigator::MozVibrate(const jsval& aPattern, JSContext* cx)
return NS_OK; return NS_OK;
} }
nsAutoTArray<PRUint32, 8> pattern; nsAutoTArray<uint32_t, 8> pattern;
// null or undefined pattern is an error. // null or undefined pattern is an error.
if (JSVAL_IS_NULL(aPattern) || JSVAL_IS_VOID(aPattern)) { if (JSVAL_IS_NULL(aPattern) || JSVAL_IS_VOID(aPattern)) {
@@ -668,7 +668,7 @@ Navigator::MozVibrate(const jsval& aPattern, JSContext* cx)
} }
if (JSVAL_IS_PRIMITIVE(aPattern)) { if (JSVAL_IS_PRIMITIVE(aPattern)) {
PRInt32 p; int32_t p;
if (GetVibrationDurationFromJsval(aPattern, cx, &p)) { if (GetVibrationDurationFromJsval(aPattern, cx, &p)) {
pattern.AppendElement(p); pattern.AppendElement(p);
} }
@@ -686,7 +686,7 @@ Navigator::MozVibrate(const jsval& aPattern, JSContext* cx)
for (PRUint32 i = 0; i < length; ++i) { for (PRUint32 i = 0; i < length; ++i) {
jsval v; jsval v;
PRInt32 pv; int32_t pv;
if (JS_GetElement(cx, obj, i, &v) && if (JS_GetElement(cx, obj, i, &v) &&
GetVibrationDurationFromJsval(v, cx, &pv)) { GetVibrationDurationFromJsval(v, cx, &pv)) {
pattern[i] = pv; pattern[i] = pv;

View File

@@ -85,13 +85,13 @@ void InitLastIDToVibrate()
} // anonymous namespace } // anonymous namespace
void void
Vibrate(const nsTArray<uint32>& pattern, nsIDOMWindow* window) Vibrate(const nsTArray<uint32_t>& pattern, nsIDOMWindow* window)
{ {
Vibrate(pattern, WindowIdentifier(window)); Vibrate(pattern, WindowIdentifier(window));
} }
void void
Vibrate(const nsTArray<uint32>& pattern, const WindowIdentifier &id) Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id)
{ {
AssertMainThread(); AssertMainThread();

View File

@@ -68,9 +68,9 @@ namespace MOZ_HAL_NAMESPACE {
* nsIDOMWindow* in place of the WindowIdentifier parameter. * nsIDOMWindow* in place of the WindowIdentifier parameter.
* The method with WindowIdentifier will be called automatically. * The method with WindowIdentifier will be called automatically.
*/ */
void Vibrate(const nsTArray<uint32>& pattern, void Vibrate(const nsTArray<uint32_t>& pattern,
nsIDOMWindow* aWindow); nsIDOMWindow* aWindow);
void Vibrate(const nsTArray<uint32>& pattern, void Vibrate(const nsTArray<uint32_t>& pattern,
const hal::WindowIdentifier &id); const hal::WindowIdentifier &id);
/** /**

View File

@@ -24,7 +24,7 @@ WindowIdentifier::WindowIdentifier(nsIDOMWindow *window)
mID.AppendElement(GetWindowID()); mID.AppendElement(GetWindowID());
} }
WindowIdentifier::WindowIdentifier(const nsTArray<uint64> &id, nsIDOMWindow *window) WindowIdentifier::WindowIdentifier(const nsTArray<uint64_t> &id, nsIDOMWindow *window)
: mID(id) : mID(id)
, mWindow(window) , mWindow(window)
, mIsEmpty(false) , mIsEmpty(false)
@@ -39,7 +39,7 @@ WindowIdentifier::WindowIdentifier(const WindowIdentifier &other)
{ {
} }
const InfallibleTArray<uint64>& const InfallibleTArray<uint64_t>&
WindowIdentifier::AsArray() const WindowIdentifier::AsArray() const
{ {
MOZ_ASSERT(!mIsEmpty); MOZ_ASSERT(!mIsEmpty);
@@ -60,13 +60,13 @@ WindowIdentifier::AppendProcessID()
mID.AppendElement(dom::ContentChild::GetSingleton()->GetID()); mID.AppendElement(dom::ContentChild::GetSingleton()->GetID());
} }
uint64 uint64_t
WindowIdentifier::GetWindowID() const WindowIdentifier::GetWindowID() const
{ {
MOZ_ASSERT(!mIsEmpty); MOZ_ASSERT(!mIsEmpty);
nsCOMPtr<nsPIDOMWindow> pidomWindow = do_QueryInterface(mWindow); nsCOMPtr<nsPIDOMWindow> pidomWindow = do_QueryInterface(mWindow);
if (!pidomWindow) { if (!pidomWindow) {
return uint64(-1); return UINT64_MAX;
} }
return pidomWindow->WindowID(); return pidomWindow->WindowID();
} }

View File

@@ -66,12 +66,12 @@ public:
* This automatically grabs the window's ID and appends it to the * This automatically grabs the window's ID and appends it to the
* array. * 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. * Get the list of window and process IDs we contain.
*/ */
typedef InfallibleTArray<uint64> IDArrayType; typedef InfallibleTArray<uint64_t> IDArrayType;
const IDArrayType& AsArray() const; const IDArrayType& AsArray() const;
/** /**
@@ -96,9 +96,9 @@ private:
/** /**
* Get the ID of the window object we wrap. * 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; nsCOMPtr<nsIDOMWindow> mWindow;
bool mIsEmpty; bool mIsEmpty;
}; };

View File

@@ -18,7 +18,7 @@ namespace mozilla {
namespace hal_impl { namespace hal_impl {
void 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, // Ignore the WindowIdentifier parameter; it's here only because hal::Vibrate,
// hal_sandbox::Vibrate, and hal_impl::Vibrate all must have the same // hal_sandbox::Vibrate, and hal_impl::Vibrate all must have the same
@@ -28,7 +28,7 @@ Vibrate(const nsTArray<uint32> &pattern, const WindowIdentifier &)
// nop. But we want to treat vibrate([0]) like CancelVibrate! (Note that we // nop. But we want to treat vibrate([0]) like CancelVibrate! (Note that we
// also need to treat vibrate([]) as a call to CancelVibrate.) // also need to treat vibrate([]) as a call to CancelVibrate.)
bool allZero = true; bool allZero = true;
for (uint32 i = 0; i < pattern.Length(); i++) { for (uint32_t i = 0; i < pattern.Length(); i++) {
if (pattern[i] != 0) { if (pattern[i] != 0) {
allZero = false; allZero = false;
break; break;

View File

@@ -12,7 +12,7 @@ namespace mozilla {
namespace hal_impl { namespace hal_impl {
void void
Vibrate(const nsTArray<uint32>& pattern, const hal::WindowIdentifier &) Vibrate(const nsTArray<uint32_t>& pattern, const hal::WindowIdentifier &)
{} {}
void void

View File

@@ -78,18 +78,18 @@ public:
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
// Run on the main thread, not the vibrator thread. // Run on the main thread, not the vibrator thread.
void Vibrate(const nsTArray<uint32> &pattern); void Vibrate(const nsTArray<uint32_t> &pattern);
void CancelVibrate(); void CancelVibrate();
private: private:
Monitor mMonitor; Monitor mMonitor;
// The currently-playing pattern. // The currently-playing pattern.
nsTArray<uint32> mPattern; nsTArray<uint32_t> mPattern;
// The index we're at in the currently-playing pattern. If mIndex >= // The index we're at in the currently-playing pattern. If mIndex >=
// mPattern.Length(), then we're not currently playing anything. // 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 // Set to true in our shutdown observer. When this is true, we kill the
// vibrator thread. // vibrator thread.
@@ -114,7 +114,7 @@ VibratorRunnable::Run()
while (!mShuttingDown) { while (!mShuttingDown) {
if (mIndex < mPattern.Length()) { if (mIndex < mPattern.Length()) {
uint32 duration = mPattern[mIndex]; uint32_t duration = mPattern[mIndex];
if (mIndex % 2 == 0) { if (mIndex % 2 == 0) {
vibrator_on(duration); vibrator_on(duration);
} }
@@ -141,7 +141,7 @@ VibratorRunnable::Observe(nsISupports *subject, const char *topic,
} }
void void
VibratorRunnable::Vibrate(const nsTArray<uint32> &pattern) VibratorRunnable::Vibrate(const nsTArray<uint32_t> &pattern)
{ {
MonitorAutoLock lock(mMonitor); MonitorAutoLock lock(mMonitor);
mPattern = pattern; mPattern = pattern;
@@ -177,7 +177,7 @@ EnsureVibratorThreadInitialized()
} // anonymous namespace } // anonymous namespace
void void
Vibrate(const nsTArray<uint32> &pattern, const hal::WindowIdentifier &) Vibrate(const nsTArray<uint32_t> &pattern, const hal::WindowIdentifier &)
{ {
EnsureVibratorThreadInitialized(); EnsureVibratorThreadInitialized();
sVibratorRunnable->Vibrate(pattern); sVibratorRunnable->Vibrate(pattern);

View File

@@ -35,11 +35,11 @@ Hal()
} }
void 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.")); HAL_LOG(("Vibrate: Sending to parent process."));
AutoInfallibleTArray<uint32, 8> p(pattern); AutoInfallibleTArray<uint32_t, 8> p(pattern);
WindowIdentifier newID(id); WindowIdentifier newID(id);
newID.AppendProcessID(); newID.AppendProcessID();
@@ -271,7 +271,7 @@ class HalParent : public PHalParent
public: public:
NS_OVERRIDE virtual bool NS_OVERRIDE virtual bool
RecvVibrate(const InfallibleTArray<unsigned int>& pattern, RecvVibrate(const InfallibleTArray<unsigned int>& pattern,
const InfallibleTArray<uint64> &id, const InfallibleTArray<uint64_t> &id,
PBrowserParent *browserParent) PBrowserParent *browserParent)
{ {
// Check whether browserParent is active. We should have already // Check whether browserParent is active. We should have already
@@ -297,7 +297,7 @@ public:
} }
NS_OVERRIDE virtual bool NS_OVERRIDE virtual bool
RecvCancelVibrate(const InfallibleTArray<uint64> &id, RecvCancelVibrate(const InfallibleTArray<uint64_t> &id,
PBrowserParent *browserParent) PBrowserParent *browserParent)
{ {
TabParent *tabParent = static_cast<TabParent*>(browserParent); TabParent *tabParent = static_cast<TabParent*>(browserParent);