Backed out changeset 00f8c8fde8ca (bug 1222101) for build bustage CLOSED TREE

MozReview-Commit-ID: F6PINhcfsF4
This commit is contained in:
Wes Kocher 2016-03-30 10:19:29 -07:00
Родитель 7d22a5cb40
Коммит dd58e668a4
6 изменённых файлов: 38 добавлений и 52 удалений

Просмотреть файл

@ -89,7 +89,7 @@ MessageLoop* MessageLoop::current() {
static mozilla::Atomic<int32_t> message_loop_id_seq(0);
MessageLoop::MessageLoop(Type type, nsIThread* aThread)
MessageLoop::MessageLoop(Type type)
: type_(type),
id_(++message_loop_id_seq),
nestable_tasks_allowed_(true),
@ -107,11 +107,9 @@ MessageLoop::MessageLoop(Type type, nsIThread* aThread)
switch (type_) {
case TYPE_MOZILLA_PARENT:
MOZ_RELEASE_ASSERT(!aThread);
pump_ = new mozilla::ipc::MessagePump(aThread);
pump_ = new mozilla::ipc::MessagePump();
return;
case TYPE_MOZILLA_CHILD:
MOZ_RELEASE_ASSERT(!aThread);
pump_ = new mozilla::ipc::MessagePumpForChildProcess();
// There is a MessageLoop Run call from XRE_InitChildProcess
// and another one from MessagePumpForChildProcess. The one
@ -121,11 +119,11 @@ MessageLoop::MessageLoop(Type type, nsIThread* aThread)
run_depth_base_ = 2;
return;
case TYPE_MOZILLA_NONMAINTHREAD:
pump_ = new mozilla::ipc::MessagePumpForNonMainThreads(aThread);
pump_ = new mozilla::ipc::MessagePumpForNonMainThreads();
return;
#if defined(OS_WIN)
case TYPE_MOZILLA_NONMAINUITHREAD:
pump_ = new mozilla::ipc::MessagePumpForNonMainUIThreads(aThread);
pump_ = new mozilla::ipc::MessagePumpForNonMainUIThreads();
return;
#endif
default:

Просмотреть файл

@ -27,8 +27,6 @@
#include "nsAutoPtr.h"
class nsIThread;
namespace mozilla {
namespace ipc {
@ -225,7 +223,7 @@ public:
// Normally, it is not necessary to instantiate a MessageLoop. Instead, it
// is typical to make use of the current thread's MessageLoop instance.
explicit MessageLoop(Type type = TYPE_DEFAULT, nsIThread* aThread = nullptr);
explicit MessageLoop(Type type = TYPE_DEFAULT);
~MessageLoop();
// Returns the type passed to the constructor.

Просмотреть файл

@ -9,7 +9,6 @@
#include "base/waitable_event.h"
#include "GeckoProfiler.h"
#include "mozilla/IOInterposer.h"
#include "nsThreadUtils.h"
#ifdef MOZ_TASK_TRACER
#include "GeckoTaskTracer.h"
@ -152,8 +151,7 @@ void Thread::ThreadMain() {
mozilla::IOInterposer::RegisterCurrentThread();
// The message loop for this thread.
MessageLoop message_loop(startup_data_->options.message_loop_type,
NS_GetCurrentThread());
MessageLoop message_loop(startup_data_->options.message_loop_type);
// Complete the initialization of our Thread object.
thread_id_ = PlatformThread::CurrentId();

Просмотреть файл

@ -66,8 +66,8 @@ private:
} /* namespace ipc */
} /* namespace mozilla */
MessagePump::MessagePump(nsIThread* aThread)
: mThread(aThread)
MessagePump::MessagePump()
: mThread(nullptr)
{
mDoWorkEvent = new DoWorkRunnable(this);
}
@ -80,12 +80,11 @@ void
MessagePump::Run(MessagePump::Delegate* aDelegate)
{
MOZ_ASSERT(keep_running_);
MOZ_RELEASE_ASSERT(NS_IsMainThread(),
"Use mozilla::ipc::MessagePumpForNonMainThreads instead!");
MOZ_RELEASE_ASSERT(!mThread);
MOZ_ASSERT(NS_IsMainThread(),
"Use mozilla::ipc::MessagePumpForNonMainThreads instead!");
nsIThread* thisThread = NS_GetCurrentThread();
MOZ_ASSERT(thisThread);
mThread = NS_GetCurrentThread();
MOZ_ASSERT(mThread);
mDelayedWorkTimer = do_CreateInstance(kNS_TIMER_CID);
MOZ_ASSERT(mDelayedWorkTimer);
@ -95,7 +94,7 @@ MessagePump::Run(MessagePump::Delegate* aDelegate)
for (;;) {
autoReleasePool.Recycle();
bool did_work = NS_ProcessNextEvent(thisThread, false) ? true : false;
bool did_work = NS_ProcessNextEvent(mThread, false) ? true : false;
if (!keep_running_)
break;
@ -127,7 +126,7 @@ if (did_work && delayed_work_time_.is_null()
continue;
// This will either sleep or process an event.
NS_ProcessNextEvent(thisThread, true);
NS_ProcessNextEvent(mThread, true);
}
#ifdef MOZ_NUWA_PROCESS
@ -144,7 +143,8 @@ MessagePump::ScheduleWork()
// Make sure the event loop wakes up.
if (mThread) {
mThread->Dispatch(mDoWorkEvent, NS_DISPATCH_NORMAL);
} else {
}
else {
// Some things (like xpcshell) don't use the app shell and so Run hasn't
// been called. We still need to wake up the main thread.
NS_DispatchToMainThread(mDoWorkEvent);
@ -169,11 +169,6 @@ MessagePump::ScheduleDelayedWork(const base::TimeTicks& aDelayedTime)
return;
#endif
// To avoid racing on mDelayedWorkTimer, we need to be on the same thread as
// ::Run().
MOZ_RELEASE_ASSERT(NS_GetCurrentThread() == mThread ||
(!mThread && NS_IsMainThread()));
if (!mDelayedWorkTimer) {
mDelayedWorkTimer = do_CreateInstance(kNS_TIMER_CID);
if (!mDelayedWorkTimer) {
@ -304,21 +299,21 @@ void
MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate* aDelegate)
{
MOZ_ASSERT(keep_running_);
MOZ_RELEASE_ASSERT(!NS_IsMainThread(), "Use mozilla::ipc::MessagePump instead!");
MOZ_ASSERT(!NS_IsMainThread(), "Use mozilla::ipc::MessagePump instead!");
nsIThread* thread = NS_GetCurrentThread();
MOZ_RELEASE_ASSERT(mThread == thread);
mThread = NS_GetCurrentThread();
MOZ_ASSERT(mThread);
mDelayedWorkTimer = do_CreateInstance(kNS_TIMER_CID);
MOZ_ASSERT(mDelayedWorkTimer);
if (NS_FAILED(mDelayedWorkTimer->SetTarget(thread))) {
if (NS_FAILED(mDelayedWorkTimer->SetTarget(mThread))) {
MOZ_CRASH("Failed to set timer target!");
}
// Chromium event notifications to be processed will be received by this
// event loop as a DoWorkRunnables via ScheduleWork. Chromium events that
// were received before our thread is valid, however, will not generate
// were received before our mThread is valid, however, will not generate
// runnable wrappers. We must process any of these before we enter this
// loop, or we will forever have unprocessed chromium messages in our queue.
//
@ -334,7 +329,7 @@ MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate* aDelegate)
for (;;) {
autoReleasePool.Recycle();
bool didWork = NS_ProcessNextEvent(thread, false) ? true : false;
bool didWork = NS_ProcessNextEvent(mThread, false) ? true : false;
if (!keep_running_) {
break;
}
@ -363,7 +358,7 @@ MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate* aDelegate)
}
// This will either sleep or process an event.
NS_ProcessNextEvent(thread, true);
NS_ProcessNextEvent(mThread, true);
}
mDelayedWorkTimer->Cancel();
@ -377,19 +372,16 @@ NS_IMPL_QUERY_INTERFACE(MessagePumpForNonMainUIThreads, nsIThreadObserver)
#define CHECK_QUIT_STATE { if (state_->should_quit) { break; } }
void
MessagePumpForNonMainUIThreads::DoRunLoop()
void MessagePumpForNonMainUIThreads::DoRunLoop()
{
MOZ_RELEASE_ASSERT(!NS_IsMainThread(), "Use mozilla::ipc::MessagePump instead!");
// If this is a chromium thread and no nsThread is associated
// with it, this call will create a new nsThread.
nsIThread* thread = NS_GetCurrentThread();
MOZ_ASSERT(thread);
mThread = NS_GetCurrentThread();
MOZ_ASSERT(mThread);
// Set the main thread observer so we can wake up when
// xpcom events need to get processed.
nsCOMPtr<nsIThreadInternal> ti(do_QueryInterface(thread));
nsCOMPtr<nsIThreadInternal> ti(do_QueryInterface(mThread));
MOZ_ASSERT(ti);
ti->SetObserver(this);
@ -397,7 +389,7 @@ MessagePumpForNonMainUIThreads::DoRunLoop()
for (;;) {
autoReleasePool.Recycle();
bool didWork = NS_ProcessNextEvent(thread, false);
bool didWork = NS_ProcessNextEvent(mThread, false);
didWork |= ProcessNextWindowsMessage();
CHECK_QUIT_STATE
@ -419,7 +411,7 @@ MessagePumpForNonMainUIThreads::DoRunLoop()
CHECK_QUIT_STATE
SetInWait();
bool hasWork = NS_HasPendingEvents(thread);
bool hasWork = NS_HasPendingEvents(mThread);
if (didWork || hasWork) {
ClearInWait();
continue;

Просмотреть файл

@ -30,7 +30,7 @@ class MessagePump : public base::MessagePumpDefault
friend class DoWorkRunnable;
public:
MessagePump(nsIThread* aThread);
MessagePump();
// From base::MessagePump.
virtual void
@ -56,11 +56,10 @@ private:
void DoDelayedWork(base::MessagePump::Delegate* aDelegate);
protected:
nsIThread* mThread;
// mDelayedWorkTimer and mThread are set in Run() by this class or its
// subclasses.
nsCOMPtr<nsITimer> mDelayedWorkTimer;
nsIThread* mThread;
private:
// Only accessed by this class.
@ -71,8 +70,7 @@ class MessagePumpForChildProcess final: public MessagePump
{
public:
MessagePumpForChildProcess()
: MessagePump(nullptr),
mFirstRun(true)
: mFirstRun(true)
{ }
virtual void Run(base::MessagePump::Delegate* aDelegate) override;
@ -87,8 +85,7 @@ private:
class MessagePumpForNonMainThreads final : public MessagePump
{
public:
MessagePumpForNonMainThreads(nsIThread* aThread)
: MessagePump(aThread)
MessagePumpForNonMainThreads()
{ }
virtual void Run(base::MessagePump::Delegate* aDelegate) override;
@ -119,7 +116,8 @@ public:
NS_DECL_NSITHREADOBSERVER
public:
MessagePumpForNonMainUIThreads(nsIThread* aThread) :
MessagePumpForNonMainUIThreads() :
mThread(nullptr),
mInWait(false),
mWaitLock("mInWait")
{
@ -129,6 +127,8 @@ public:
virtual void DoRunLoop() override;
protected:
nsIThread* mThread;
void SetInWait() {
MutexAutoLock lock(mWaitLock);
mInWait = true;

Просмотреть файл

@ -390,7 +390,7 @@ nsThread::ThreadFunc(void* aArg)
{
// Scope for MessageLoop.
nsAutoPtr<MessageLoop> loop(
new MessageLoop(MessageLoop::TYPE_MOZILLA_NONMAINTHREAD, self));
new MessageLoop(MessageLoop::TYPE_MOZILLA_NONMAINTHREAD));
// Now, process incoming events...
loop->Run();