mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 10:54:33 +00:00
Bug 712910 - Use stdint types in HAL; r=cjones
This commit is contained in:
parent
686e870ccd
commit
3bfe10a2e0
@ -636,10 +636,10 @@ VibrateWindowListener::RemoveListener()
|
||||
*/
|
||||
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
|
||||
@ -660,7 +660,7 @@ Navigator::MozVibrate(const jsval& aPattern, JSContext* cx)
|
||||
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)) {
|
||||
@ -668,7 +668,7 @@ Navigator::MozVibrate(const jsval& aPattern, JSContext* cx)
|
||||
}
|
||||
|
||||
if (JSVAL_IS_PRIMITIVE(aPattern)) {
|
||||
PRInt32 p;
|
||||
int32_t p;
|
||||
if (GetVibrationDurationFromJsval(aPattern, cx, &p)) {
|
||||
pattern.AppendElement(p);
|
||||
}
|
||||
@ -686,7 +686,7 @@ Navigator::MozVibrate(const jsval& aPattern, JSContext* cx)
|
||||
|
||||
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;
|
||||
|
@ -85,13 +85,13 @@ void InitLastIDToVibrate()
|
||||
} // 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();
|
||||
|
||||
|
@ -68,9 +68,9 @@ namespace MOZ_HAL_NAMESPACE {
|
||||
* 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);
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ WindowIdentifier::WindowIdentifier(nsIDOMWindow *window)
|
||||
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)
|
||||
@ -39,7 +39,7 @@ WindowIdentifier::WindowIdentifier(const WindowIdentifier &other)
|
||||
{
|
||||
}
|
||||
|
||||
const InfallibleTArray<uint64>&
|
||||
const InfallibleTArray<uint64_t>&
|
||||
WindowIdentifier::AsArray() const
|
||||
{
|
||||
MOZ_ASSERT(!mIsEmpty);
|
||||
@ -60,13 +60,13 @@ WindowIdentifier::AppendProcessID()
|
||||
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();
|
||||
}
|
||||
|
@ -66,12 +66,12 @@ public:
|
||||
* 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;
|
||||
|
||||
/**
|
||||
@ -96,9 +96,9 @@ 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;
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ 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
|
||||
@ -28,7 +28,7 @@ Vibrate(const nsTArray<uint32> &pattern, const WindowIdentifier &)
|
||||
// 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;
|
||||
|
@ -12,7 +12,7 @@ namespace mozilla {
|
||||
namespace hal_impl {
|
||||
|
||||
void
|
||||
Vibrate(const nsTArray<uint32>& pattern, const hal::WindowIdentifier &)
|
||||
Vibrate(const nsTArray<uint32_t>& pattern, const hal::WindowIdentifier &)
|
||||
{}
|
||||
|
||||
void
|
||||
|
@ -78,18 +78,18 @@ public:
|
||||
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.
|
||||
@ -114,7 +114,7 @@ VibratorRunnable::Run()
|
||||
|
||||
while (!mShuttingDown) {
|
||||
if (mIndex < mPattern.Length()) {
|
||||
uint32 duration = mPattern[mIndex];
|
||||
uint32_t duration = mPattern[mIndex];
|
||||
if (mIndex % 2 == 0) {
|
||||
vibrator_on(duration);
|
||||
}
|
||||
@ -141,7 +141,7 @@ VibratorRunnable::Observe(nsISupports *subject, const char *topic,
|
||||
}
|
||||
|
||||
void
|
||||
VibratorRunnable::Vibrate(const nsTArray<uint32> &pattern)
|
||||
VibratorRunnable::Vibrate(const nsTArray<uint32_t> &pattern)
|
||||
{
|
||||
MonitorAutoLock lock(mMonitor);
|
||||
mPattern = pattern;
|
||||
@ -177,7 +177,7 @@ EnsureVibratorThreadInitialized()
|
||||
} // anonymous namespace
|
||||
|
||||
void
|
||||
Vibrate(const nsTArray<uint32> &pattern, const hal::WindowIdentifier &)
|
||||
Vibrate(const nsTArray<uint32_t> &pattern, const hal::WindowIdentifier &)
|
||||
{
|
||||
EnsureVibratorThreadInitialized();
|
||||
sVibratorRunnable->Vibrate(pattern);
|
||||
|
@ -35,11 +35,11 @@ Hal()
|
||||
}
|
||||
|
||||
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();
|
||||
@ -271,7 +271,7 @@ class HalParent : public PHalParent
|
||||
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
|
||||
@ -297,7 +297,7 @@ public:
|
||||
}
|
||||
|
||||
NS_OVERRIDE virtual bool
|
||||
RecvCancelVibrate(const InfallibleTArray<uint64> &id,
|
||||
RecvCancelVibrate(const InfallibleTArray<uint64_t> &id,
|
||||
PBrowserParent *browserParent)
|
||||
{
|
||||
TabParent *tabParent = static_cast<TabParent*>(browserParent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user