summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul <sadrul@chromium.org>2016-01-28 08:16:24 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-28 16:17:23 +0000
commitd3af96a7d69ccf2a6a0387f31074d9b5482f9a6f (patch)
treeb277020a964e030f94d9100cfd3ee1d888d24087 /ash
parentd3641e1cd52ef1c5fb3abdfd2d066d1789720c68 (diff)
downloadchromium_src-d3af96a7d69ccf2a6a0387f31074d9b5482f9a6f.zip
chromium_src-d3af96a7d69ccf2a6a0387f31074d9b5482f9a6f.tar.gz
chromium_src-d3af96a7d69ccf2a6a0387f31074d9b5482f9a6f.tar.bz2
ash: Do not use MessageLoopForUI when not needed.
Use ThreadTaskRunnerHandle to get thet task runner, and use that for posting tasks from the ash code. BUG=none Review URL: https://codereview.chromium.org/1640503002 Cr-Commit-Position: refs/heads/master@{#372096}
Diffstat (limited to 'ash')
-rw-r--r--ash/accelerators/key_hold_detector.cc4
-rw-r--r--ash/display/display_animator_chromeos.cc5
-rw-r--r--ash/display/display_manager.cc8
-rw-r--r--ash/display/mirror_window_controller.cc3
-rw-r--r--ash/display/window_tree_host_manager.cc3
-rw-r--r--ash/drag_drop/drag_drop_controller.cc10
-rw-r--r--ash/shelf/shelf_tooltip_manager.cc4
-rw-r--r--ash/shell/content/client/shell_browser_main_parts.cc2
-rw-r--r--ash/shell/shell_delegate_impl.cc2
-rw-r--r--ash/shell_unittest.cc7
-rw-r--r--ash/system/chromeos/brightness/tray_brightness.cc9
-rw-r--r--ash/system/chromeos/network/network_state_list_detailed_view.cc4
-rw-r--r--ash/system/tray/system_tray_bubble.cc4
-rw-r--r--ash/system/web_notification/web_notification_tray.cc3
-rw-r--r--ash/wm/overview/window_selector_unittest.cc10
-rw-r--r--ash/wm/toplevel_window_event_handler.cc2
-rw-r--r--ash/wm/toplevel_window_event_handler_unittest.cc6
-rw-r--r--ash/wm/workspace/workspace_event_handler_unittest.cc3
18 files changed, 47 insertions, 42 deletions
diff --git a/ash/accelerators/key_hold_detector.cc b/ash/accelerators/key_hold_detector.cc
index 0c8d1ed..9139150 100644
--- a/ash/accelerators/key_hold_detector.cc
+++ b/ash/accelerators/key_hold_detector.cc
@@ -7,7 +7,7 @@
#include <utility>
#include "ash/shell.h"
-#include "base/message_loop/message_loop.h"
+#include "base/thread_task_runner_handle.h"
#include "ui/aura/window_tracker.h"
#include "ui/aura/window_tree_host.h"
#include "ui/events/event_dispatcher.h"
@@ -37,7 +37,7 @@ void PostPressedEvent(ui::KeyEvent* event) {
scoped_ptr<aura::WindowTracker> tracker(new aura::WindowTracker);
tracker->Add(static_cast<aura::Window*>(event->target()));
- base::MessageLoopForUI::current()->PostTask(
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&DispatchPressedEvent, pressed_event, base::Passed(&tracker)));
}
diff --git a/ash/display/display_animator_chromeos.cc b/ash/display/display_animator_chromeos.cc
index 572c013..0d9636c 100644
--- a/ash/display/display_animator_chromeos.cc
+++ b/ash/display/display_animator_chromeos.cc
@@ -8,6 +8,7 @@
#include "ash/shell_window_ids.h"
#include "base/bind.h"
#include "base/stl_util.h"
+#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
@@ -40,9 +41,9 @@ class CallbackRunningObserver {
void OnSingleTaskCompleted() {
completed_counter_++;
if (completed_counter_ >= observer_list_.size()) {
- base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, this);
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
if (!animation_aborted_)
- base::MessageLoopForUI::current()->PostTask(FROM_HERE, callback_);
+ base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback_);
}
}
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index f46fff7..d403857 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -29,6 +29,7 @@
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/thread_task_runner_handle.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/display.h"
@@ -1046,10 +1047,9 @@ void DisplayManager::CreateMirrorWindowAsyncIfAny() {
// ash::Shell::Init() will call this after the compositor is initialized.
if (software_mirroring_display_list_.empty() || !delegate_)
return;
- base::MessageLoopForUI::current()->PostTask(
- FROM_HERE,
- base::Bind(&DisplayManager::CreateMirrorWindowIfAny,
- weak_ptr_factory_.GetWeakPtr()));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&DisplayManager::CreateMirrorWindowIfAny,
+ weak_ptr_factory_.GetWeakPtr()));
}
scoped_ptr<MouseWarpController> DisplayManager::CreateMouseWarpController(
diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc
index c93bba0..929b8d7 100644
--- a/ash/display/mirror_window_controller.cc
+++ b/ash/display/mirror_window_controller.cc
@@ -26,6 +26,7 @@
#include "ash/root_window_settings.h"
#include "ash/shell.h"
#include "base/strings/stringprintf.h"
+#include "base/thread_task_runner_handle.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/env.h"
#include "ui/aura/window_delegate.h"
@@ -379,7 +380,7 @@ void MirrorWindowController::CloseAndDeleteHost(MirroringHostInfo* host_info,
// was deleted as a result of input event (e.g. shortcut), so don't delete
// now.
if (delay_host_deletion)
- base::MessageLoop::current()->DeleteSoon(FROM_HERE, host_info);
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info);
else
delete host_info;
}
diff --git a/ash/display/window_tree_host_manager.cc b/ash/display/window_tree_host_manager.cc
index f298e9c..486a40b 100644
--- a/ash/display/window_tree_host_manager.cc
+++ b/ash/display/window_tree_host_manager.cc
@@ -33,6 +33,7 @@
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/thread_task_runner_handle.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/screen_position_client.h"
@@ -643,7 +644,7 @@ void WindowTreeHostManager::DeleteHost(AshWindowTreeHost* host_to_delete) {
// Delete most of root window related objects, but don't delete
// root window itself yet because the stack may be using it.
controller->Shutdown();
- base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller);
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, controller);
}
void WindowTreeHostManager::OnDisplayRemoved(const gfx::Display& display) {
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc
index ad87b7c..1ec53aa 100644
--- a/ash/drag_drop/drag_drop_controller.cc
+++ b/ash/drag_drop/drag_drop_controller.cc
@@ -13,6 +13,7 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram_macros.h"
#include "base/run_loop.h"
+#include "base/thread_task_runner_handle.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
@@ -222,7 +223,7 @@ int DragDropController::StartDragAndDrop(
if (should_block_during_drag_drop_) {
base::RunLoop run_loop;
quit_closure_ = run_loop.QuitClosure();
- base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
+ base::MessageLoop* loop = base::MessageLoop::current();
base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
run_loop.Run();
}
@@ -501,10 +502,9 @@ void DragDropController::AnimationEnded(const gfx::Animation* animation) {
ForwardPendingLongTap();
} else {
// See comment about this in OnGestureEvent().
- base::MessageLoopForUI::current()->PostTask(
- FROM_HERE,
- base::Bind(&DragDropController::ForwardPendingLongTap,
- weak_factory_.GetWeakPtr()));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&DragDropController::ForwardPendingLongTap,
+ weak_factory_.GetWeakPtr()));
}
}
}
diff --git a/ash/shelf/shelf_tooltip_manager.cc b/ash/shelf/shelf_tooltip_manager.cc
index 0f65ee6..66f583f 100644
--- a/ash/shelf/shelf_tooltip_manager.cc
+++ b/ash/shelf/shelf_tooltip_manager.cc
@@ -10,7 +10,7 @@
#include "ash/shell_window_ids.h"
#include "ash/wm/window_animations.h"
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
+#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "ui/aura/window.h"
@@ -326,7 +326,7 @@ void ShelfTooltipManager::CancelHidingAnimation() {
}
void ShelfTooltipManager::CloseSoon() {
- base::MessageLoopForUI::current()->PostTask(
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&ShelfTooltipManager::Close, weak_factory_.GetWeakPtr()));
}
diff --git a/ash/shell/content/client/shell_browser_main_parts.cc b/ash/shell/content/client/shell_browser_main_parts.cc
index 73bde55..aa13b3b 100644
--- a/ash/shell/content/client/shell_browser_main_parts.cc
+++ b/ash/shell/content/client/shell_browser_main_parts.cc
@@ -168,7 +168,7 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() {
}
bool ShellBrowserMainParts::MainMessageLoopRun(int* result_code) {
- base::MessageLoopForUI::current()->Run();
+ base::MessageLoop::current()->Run();
return true;
}
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index b7a1858..c750ae4 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -172,7 +172,7 @@ void ShellDelegateImpl::PreShutdown() {
}
void ShellDelegateImpl::Exit() {
- base::MessageLoopForUI::current()->QuitWhenIdle();
+ base::MessageLoop::current()->QuitWhenIdle();
}
keyboard::KeyboardUI* ShellDelegateImpl::CreateKeyboardUI() {
diff --git a/ash/shell_unittest.cc b/ash/shell_unittest.cc
index f74fdb0..74d29bf 100644
--- a/ash/shell_unittest.cc
+++ b/ash/shell_unittest.cc
@@ -23,6 +23,7 @@
#include "ash/wm/root_window_layout_manager.h"
#include "ash/wm/window_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/thread_task_runner_handle.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
@@ -361,9 +362,9 @@ TEST_F(ShellTest, LockScreenClosesActiveMenu) {
// When MenuRunner runs a nested loop the LockScreenAndVerifyMenuClosed
// command will fire, check the menu state and ensure the nested menu loop
// is exited so that the test will terminate.
- base::MessageLoopForUI::current()->PostTask(FROM_HERE,
- base::Bind(&ShellTest::LockScreenAndVerifyMenuClosed,
- base::Unretained(this)));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&ShellTest::LockScreenAndVerifyMenuClosed,
+ base::Unretained(this)));
EXPECT_EQ(views::MenuRunner::NORMAL_EXIT,
menu_runner->RunMenuAt(widget,
diff --git a/ash/system/chromeos/brightness/tray_brightness.cc b/ash/system/chromeos/brightness/tray_brightness.cc
index 3e8b330..2a8e621 100644
--- a/ash/system/chromeos/brightness/tray_brightness.cc
+++ b/ash/system/chromeos/brightness/tray_brightness.cc
@@ -18,8 +18,8 @@
#include "ash/system/tray/tray_constants.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "base/bind.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/thread_task_runner_handle.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
#include "grit/ash_resources.h"
@@ -180,10 +180,9 @@ TrayBrightness::TrayBrightness(SystemTray* system_tray)
weak_ptr_factory_(this) {
// Post a task to get the initial brightness; the BrightnessControlDelegate
// isn't created yet.
- base::MessageLoopForUI::current()->PostTask(
- FROM_HERE,
- base::Bind(&TrayBrightness::GetInitialBrightness,
- weak_ptr_factory_.GetWeakPtr()));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(&TrayBrightness::GetInitialBrightness,
+ weak_ptr_factory_.GetWeakPtr()));
chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
AddObserver(this);
}
diff --git a/ash/system/chromeos/network/network_state_list_detailed_view.cc b/ash/system/chromeos/network/network_state_list_detailed_view.cc
index ff68bac..f45ce15 100644
--- a/ash/system/chromeos/network/network_state_list_detailed_view.cc
+++ b/ash/system/chromeos/network/network_state_list_detailed_view.cc
@@ -27,9 +27,9 @@
#include "ash/system/tray/tray_popup_header_button.h"
#include "ash/system/tray/tray_popup_label_button.h"
#include "base/command_line.h"
-#include "base/message_loop/message_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/login/login_state.h"
@@ -820,7 +820,7 @@ void NetworkStateListDetailedView::CallRequestScan() {
VLOG(1) << "Requesting Network Scan.";
NetworkHandler::Get()->network_state_handler()->RequestScan();
// Periodically request a scan while this UI is open.
- base::MessageLoopForUI::current()->PostDelayedTask(
+ base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&NetworkStateListDetailedView::CallRequestScan, AsWeakPtr()),
base::TimeDelta::FromSeconds(kRequestScanDelaySeconds));
diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc
index 6f95ba2..eab4b1c 100644
--- a/ash/system/tray/system_tray_bubble.cc
+++ b/ash/system/tray/system_tray_bubble.cc
@@ -11,7 +11,7 @@
#include "ash/system/tray/tray_bubble_wrapper.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_popup_item_container.h"
-#include "base/message_loop/message_loop.h"
+#include "base/thread_task_runner_handle.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
@@ -49,7 +49,7 @@ class AnimationObserverDeleteLayer : public ui::ImplicitAnimationObserver {
~AnimationObserverDeleteLayer() override {}
void OnImplicitAnimationsCompleted() override {
- base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, this);
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
}
private:
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index 4b3c0b5..b6fe944 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -22,6 +22,7 @@
#include "base/i18n/number_formatting.h"
#include "base/i18n/rtl.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/thread_task_runner_handle.h"
#include "grit/ash_strings.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
@@ -445,7 +446,7 @@ void WebNotificationTray::OnMessageCenterTrayChanged() {
// consecutively, and calling Update in the middle of those events will show
// intermediate unread counts for a moment.
should_update_tray_content_ = true;
- base::MessageLoop::current()->PostTask(
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&WebNotificationTray::UpdateTrayContent, AsWeakPtr()));
}
diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc
index 54cbb9d..a72c77e 100644
--- a/ash/wm/overview/window_selector_unittest.cc
+++ b/ash/wm/overview/window_selector_unittest.cc
@@ -37,6 +37,7 @@
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/user_action_tester.h"
+#include "base/thread_task_runner_handle.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/focus_client.h"
@@ -1192,10 +1193,11 @@ TEST_F(WindowSelectorTest, DISABLED_DragDropInProgress) {
ash::DragDropController* drag_drop_controller =
shell_test_api.drag_drop_controller();
ui::OSExchangeData data;
- base::MessageLoopForUI::current()->PostTask(FROM_HERE,
- base::Bind(&WindowSelectorTest::ToggleOverview,
- base::Unretained(this)));
- base::MessageLoopForUI::current()->PostTask(FROM_HERE,
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this)));
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test));
data.SetString(base::UTF8ToUTF16("I am being dragged"));
drag_drop_controller->StartDragAndDrop(data, window->GetRootWindow(),
diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/toplevel_window_event_handler.cc
index 1b7ae90..c7a00c2 100644
--- a/ash/wm/toplevel_window_event_handler.cc
+++ b/ash/wm/toplevel_window_event_handler.cc
@@ -421,7 +421,7 @@ aura::client::WindowMoveResult ToplevelWindowEventHandler::RunMoveLoop(
in_move_loop_ = true;
bool destroyed = false;
destroyed_ = &destroyed;
- base::MessageLoopForUI* loop = base::MessageLoopForUI::current();
+ base::MessageLoop* loop = base::MessageLoop::current();
base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
base::RunLoop run_loop;
quit_closure_ = run_loop.QuitClosure();
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc
index 749d5fc..55129eb 100644
--- a/ash/wm/toplevel_window_event_handler_unittest.cc
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc
@@ -14,7 +14,6 @@
#include "ash/wm/window_util.h"
#include "ash/wm/workspace_controller.h"
#include "base/compiler_specific.h"
-#include "base/message_loop/message_loop.h"
#include "base/thread_task_runner_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
@@ -718,11 +717,10 @@ TEST_F(ToplevelWindowEventHandlerTest, CaptureLossAfterMouseRelease) {
aura::client::WindowMoveClient* move_client =
aura::client::GetWindowMoveClient(window->GetRootWindow());
- base::MessageLoopForUI::current()->PostTask(
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&SendMouseReleaseAndReleaseCapture,
- base::Unretained(&generator),
- base::Unretained(window.get())));
+ base::Unretained(&generator), base::Unretained(window.get())));
EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
move_client->RunMoveLoop(window.get(), gfx::Vector2d(),
aura::client::WINDOW_MOVE_SOURCE_MOUSE));
diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc
index 2d9ecc3..5c5e6a8 100644
--- a/ash/wm/workspace/workspace_event_handler_unittest.cc
+++ b/ash/wm/workspace/workspace_event_handler_unittest.cc
@@ -12,6 +12,7 @@
#include "ash/wm/wm_event.h"
#include "ash/wm/workspace_controller.h"
#include "ash/wm/workspace_controller_test_helper.h"
+#include "base/thread_task_runner_handle.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/window.h"
@@ -457,7 +458,7 @@ TEST_F(WorkspaceEventHandlerTest, DeleteWhileInRunLoop) {
delegate.set_window_component(HTCAPTION);
ASSERT_TRUE(aura::client::GetWindowMoveClient(window->GetRootWindow()));
- base::MessageLoop::current()->DeleteSoon(FROM_HERE, window.get());
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window.get());
aura::client::GetWindowMoveClient(window->GetRootWindow())
->RunMoveLoop(window.release(),
gfx::Vector2d(),