blob: 4a533017636a319401a4c996dddf33e49fe5536b [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/message_loop/message_loop.h"
#include "build/build_config.h"
namespace base {
#if !defined(OS_NACL)
//------------------------------------------------------------------------------
// MessageLoopForUI
MessageLoopForUI::MessageLoopForUI(Type type) : MessageLoop(type) {
#if defined(OS_ANDROID)
DCHECK(type == TYPE_UI || type == TYPE_JAVA);
#else
DCHECK_EQ(type, TYPE_UI);
#endif
}
// static
MessageLoopCurrentForUI MessageLoopForUI::current() {
return MessageLoopCurrentForUI::Get();
}
// static
bool MessageLoopForUI::IsCurrent() {
return MessageLoopCurrentForUI::IsSet();
}
#if defined(OS_IOS)
void MessageLoopForUI::Attach() {
static_cast<MessagePumpUIApplication*>(pump_.get())->Attach(this);
}
#endif // defined(OS_IOS)
#if defined(OS_ANDROID)
void MessageLoopForUI::Abort() {
static_cast<MessagePumpForUI*>(pump_.get())->Abort();
}
bool MessageLoopForUI::IsAborted() {
return static_cast<MessagePumpForUI*>(pump_.get())->IsAborted();
}
void MessageLoopForUI::QuitWhenIdle(base::OnceClosure callback) {
static_cast<MessagePumpForUI*>(pump_.get())
->QuitWhenIdle(std::move(callback));
}
#endif // defined(OS_ANDROID)
#if defined(OS_WIN)
void MessageLoopForUI::EnableWmQuit() {
static_cast<MessagePumpForUI*>(pump_.get())->EnableWmQuit();
}
#endif // defined(OS_WIN)
#endif // !defined(OS_NACL)
//------------------------------------------------------------------------------
// MessageLoopForIO
// static
MessageLoopCurrentForIO MessageLoopForIO::current() {
return MessageLoopCurrentForIO::Get();
}
// static
bool MessageLoopForIO::IsCurrent() {
return MessageLoopCurrentForIO::IsSet();
}
} // namespace