Skip to content

Commit

Permalink
Bug 1266595: Replace Chromium Task with Runnable. r=froydnj
Browse files Browse the repository at this point in the history
  • Loading branch information
khuey committed Apr 28, 2016
1 parent 5c1108c commit eb9be48
Show file tree
Hide file tree
Showing 108 changed files with 653 additions and 2,198 deletions.
4 changes: 2 additions & 2 deletions dom/ipc/ContentBridgeChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ ContentBridgeChild::ContentBridgeChild(Transport* aTransport)

ContentBridgeChild::~ContentBridgeChild()
{
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new DeleteTask<Transport>(mTransport));
RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(mTransport);
XRE_GetIOMessageLoop()->PostTask(task.forget());
}

void
ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
{
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy));
}

Expand Down
5 changes: 2 additions & 3 deletions dom/ipc/ContentBridgeParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ ContentBridgeParent::ContentBridgeParent(Transport* aTransport)

ContentBridgeParent::~ContentBridgeParent()
{
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new DeleteTask<Transport>(mTransport));
RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(mTransport);
XRE_GetIOMessageLoop()->PostTask(task.forget());
}

void
Expand All @@ -37,7 +38,6 @@ ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
os->RemoveObserver(this, "content-child-shutdown");
}
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy));
}

Expand Down Expand Up @@ -169,7 +169,6 @@ ContentBridgeParent::NotifyTabDestroyed()
int32_t numLiveTabs = ManagedPBrowserParent().Count();
if (numLiveTabs == 1) {
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentBridgeParent::Close));
}
}
Expand Down
10 changes: 5 additions & 5 deletions dom/ipc/ContentChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ ContentChild::RecvBidiKeyboardNotify(const bool& aIsLangRTL)
return true;
}

static CancelableTask* sFirstIdleTask;
static CancelableRunnable* sFirstIdleTask;

static void FirstIdle(void)
{
Expand Down Expand Up @@ -1599,8 +1599,9 @@ ContentChild::RecvPBrowserConstructor(PBrowserChild* aActor,
hasRunOnce = true;

MOZ_ASSERT(!sFirstIdleTask);
sFirstIdleTask = NewRunnableFunction(FirstIdle);
MessageLoop::current()->PostIdleTask(FROM_HERE, sFirstIdleTask);
RefPtr<CancelableRunnable> firstIdleTask = NewRunnableFunction(FirstIdle);
sFirstIdleTask = firstIdleTask;
MessageLoop::current()->PostIdleTask(firstIdleTask.forget());

// Redo InitProcessAttributes() when the app or browser is really
// launching so the attributes will be correct.
Expand Down Expand Up @@ -2626,8 +2627,7 @@ ContentChild::RecvAppInit()
#ifdef MOZ_NUWA_PROCESS
if (IsNuwaProcess()) {
ContentChild::GetSingleton()->RecvGarbageCollect();
MessageLoop::current()->PostTask(
FROM_HERE, NewRunnableFunction(OnFinishNuwaPreparation));
MessageLoop::current()->PostTask(NewRunnableFunction(OnFinishNuwaPreparation));
}
#endif

Expand Down
6 changes: 1 addition & 5 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,8 +800,7 @@ ContentParent::JoinAllSubprocesses()

bool done = false;
Monitor monitor("mozilla.dom.ContentParent.JoinAllSubprocesses");
XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
NewRunnableFunction(
XRE_GetIOMessageLoop()->PostTask(NewRunnableFunction(
&ContentParent::JoinProcessesIOThread,
&processes, &monitor, &done));
{
Expand Down Expand Up @@ -2180,7 +2179,6 @@ ContentParent::ActorDestroy(ActorDestroyReason why)
for(uint32_t i = 0; i < childIDArray.Length(); i++) {
ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]);
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
}
Expand Down Expand Up @@ -2264,7 +2262,6 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId,
// In the case of normal shutdown, send a shutdown message to child to
// allow it to perform shutdown tasks.
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
}
Expand Down Expand Up @@ -3629,7 +3626,6 @@ ContentParent::KillHard(const char* aReason)

// EnsureProcessTerminated has responsibilty for closing otherProcessHandle.
XRE_GetIOMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(&ProcessWatcher::EnsureProcessTerminated,
otherProcessHandle, /*force=*/true));
}
Expand Down
8 changes: 3 additions & 5 deletions dom/ipc/PreallocatedProcessManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ PreallocatedProcessManagerImpl::AllocateAfterDelay()
}

MessageLoop::current()->PostDelayedTask(
FROM_HERE,
NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle),
Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
DEFAULT_ALLOCATE_DELAY));
Expand All @@ -219,7 +218,6 @@ PreallocatedProcessManagerImpl::AllocateOnIdle()
}

MessageLoop::current()->PostIdleTask(
FROM_HERE,
NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow));
}

Expand All @@ -245,10 +243,10 @@ PreallocatedProcessManagerImpl::ScheduleDelayedNuwaFork()
return;
}

mPreallocateAppProcessTask = NewRunnableMethod(
RefPtr<CancelableTask> task = NewRunnableMethod(
this, &PreallocatedProcessManagerImpl::DelayedNuwaFork);
MessageLoop::current()->PostDelayedTask(
FROM_HERE, mPreallocateAppProcessTask,
mPreallocateAppProcessTask = task;
MessageLoop::current()->PostDelayedTask(task.forget(),
Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
DEFAULT_ALLOCATE_DELAY));
}
Expand Down
16 changes: 4 additions & 12 deletions dom/ipc/ProcessHangMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ HangMonitorChild::~HangMonitorChild()
{
// For some reason IPDL doesn't automatically delete the channel for a
// bridged protocol (bug 1090570). So we have to do it ourselves.
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new DeleteTask<Transport>(GetTransport()));
RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(GetTransport());
XRE_GetIOMessageLoop()->PostTask(task.forget());

MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_ASSERT(sInstance == this);
Expand Down Expand Up @@ -303,7 +304,6 @@ HangMonitorChild::ActorDestroy(ActorDestroyReason aWhy)
// We use a task here to ensure that IPDL is finished with this
// HangMonitorChild before it gets deleted on the main thread.
MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &HangMonitorChild::ShutdownOnThread));
}

Expand Down Expand Up @@ -391,7 +391,6 @@ HangMonitorChild::NotifySlowScript(nsITabChild* aTabChild,
nsAutoCString filename(aFileName);

MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &HangMonitorChild::NotifySlowScriptAsync,
id, filename, aLineNo));
return SlowScriptAction::Continue;
Expand Down Expand Up @@ -422,7 +421,6 @@ HangMonitorChild::NotifyPluginHang(uint32_t aPluginId)

// bounce to background thread
MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(this,
&HangMonitorChild::NotifyPluginHangAsync,
aPluginId));
Expand All @@ -448,7 +446,6 @@ HangMonitorChild::ClearHang()
if (mSentReport) {
// bounce to background thread
MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &HangMonitorChild::ClearHangAsync));

MonitorAutoLock lock(mMonitor);
Expand Down Expand Up @@ -487,7 +484,8 @@ HangMonitorParent::~HangMonitorParent()
{
// For some reason IPDL doesn't automatically delete the channel for a
// bridged protocol (bug 1090570). So we have to do it ourselves.
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new DeleteTask<Transport>(GetTransport()));
RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(GetTransport());
XRE_GetIOMessageLoop()->PostTask(task.forget());

#ifdef MOZ_CRASHREPORTER
MutexAutoLock lock(mBrowserCrashDumpHashLock);
Expand All @@ -514,7 +512,6 @@ HangMonitorParent::Shutdown()
}

MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &HangMonitorParent::ShutdownOnThread));

while (!mShutdownDone) {
Expand Down Expand Up @@ -836,7 +833,6 @@ HangMonitoredProcess::TerminateScript()
}

ProcessHangMonitor::Get()->MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(mActor, &HangMonitorParent::TerminateScript));
return NS_OK;
}
Expand All @@ -854,7 +850,6 @@ HangMonitoredProcess::BeginStartingDebugger()
}

ProcessHangMonitor::Get()->MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(mActor, &HangMonitorParent::BeginStartingDebugger));
return NS_OK;
}
Expand All @@ -872,7 +867,6 @@ HangMonitoredProcess::EndStartingDebugger()
}

ProcessHangMonitor::Get()->MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(mActor, &HangMonitorParent::EndStartingDebugger));
return NS_OK;
}
Expand Down Expand Up @@ -1052,7 +1046,6 @@ mozilla::CreateHangMonitorParent(ContentParent* aContentParent,
parent->SetProcess(process);

monitor->MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(parent, &HangMonitorParent::Open,
aTransport, aOtherPid, XRE_GetIOMessageLoop()));

Expand All @@ -1069,7 +1062,6 @@ mozilla::CreateHangMonitorChild(mozilla::ipc::Transport* aTransport,
HangMonitorChild* child = new HangMonitorChild(monitor);

monitor->MonitorLoop()->PostTask(
FROM_HERE,
NewRunnableMethod(child, &HangMonitorChild::Open,
aTransport, aOtherPid, XRE_GetIOMessageLoop()));

Expand Down
Loading

0 comments on commit eb9be48

Please sign in to comment.