mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 1320753 - Adding nsINamed naming to nsITimer (r=ehsan)
MozReview-Commit-ID: AbyLcMhRvbx
This commit is contained in:
parent
972fbd3fdf
commit
6df682a091
@ -149,6 +149,8 @@ public:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetName(nsACString& aName) override;
|
||||
|
||||
nsTimerEvent()
|
||||
: mTimer()
|
||||
, mGeneration(0)
|
||||
@ -267,6 +269,16 @@ nsTimerEvent::DeleteAllocatorIfNeeded()
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimerEvent::GetName(nsACString& aName)
|
||||
{
|
||||
bool current;
|
||||
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(mTimer->mEventTarget->IsOnCurrentThread(¤t)) && current);
|
||||
|
||||
mTimer->GetName(aName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTimerEvent::Run()
|
||||
{
|
||||
|
@ -651,6 +651,42 @@ nsTimerImpl::SetDelayInternal(uint32_t aDelay, TimeStamp aBase)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTimerImpl::GetName(nsACString& aName)
|
||||
{
|
||||
switch (mCallbackType) {
|
||||
case CallbackType::Function:
|
||||
if (mName.is<NameString>()) {
|
||||
aName.Assign(mName.as<NameString>());
|
||||
} else if (mName.is<NameFunc>()) {
|
||||
static const size_t buflen = 1024;
|
||||
char buf[buflen];
|
||||
mName.as<NameFunc>()(mITimer, mClosure, buf, buflen);
|
||||
aName.Assign(buf);
|
||||
} else {
|
||||
MOZ_ASSERT(mName.is<NameNothing>());
|
||||
aName.Truncate();
|
||||
}
|
||||
break;
|
||||
|
||||
case CallbackType::Interface:
|
||||
if (nsCOMPtr<nsINamed> named = do_QueryInterface(mCallback.i)) {
|
||||
named->GetName(aName);
|
||||
}
|
||||
break;
|
||||
|
||||
case CallbackType::Observer:
|
||||
if (nsCOMPtr<nsINamed> named = do_QueryInterface(mCallback.o)) {
|
||||
named->GetName(aName);
|
||||
}
|
||||
break;
|
||||
|
||||
case CallbackType::Unknown:
|
||||
aName.Truncate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nsTimer::~nsTimer()
|
||||
{
|
||||
}
|
||||
|
@ -111,6 +111,8 @@ public:
|
||||
return mType >= nsITimer::TYPE_REPEATING_PRECISE;
|
||||
}
|
||||
|
||||
void GetName(nsACString& aName);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> mEventTarget;
|
||||
|
||||
void* mClosure;
|
||||
|
Loading…
Reference in New Issue
Block a user