diff options
Diffstat (limited to 'chrome')
11 files changed, 43 insertions, 49 deletions
diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index bcc8f63..5165cd5 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -149,11 +149,9 @@ void AutomationProvider::WindowSimulateDrag( false, MessageLoop::QuitClosure()); MessageLoopForUI* loop = MessageLoopForUI::current(); - bool did_allow_task_nesting = loop->NestableTasksAllowed(); - loop->SetNestableTasksAllowed(true); views::AcceleratorHandler handler; + MessageLoop::ScopedNestableTaskAllower allow(loop); loop->RunWithDispatcher(&handler); - loop->SetNestableTasksAllowed(did_allow_task_nesting); } SendMessage(top_level_hwnd, up_message, wparam_flags, MAKELPARAM(end.x, end.y)); diff --git a/chrome/browser/printing/print_job.cc b/chrome/browser/printing/print_job.cc index b374b685..aa312de 100644 --- a/chrome/browser/printing/print_job.cc +++ b/chrome/browser/printing/print_job.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -202,11 +202,8 @@ bool PrintJob::FlushJob(int timeout_ms) { MessageLoop::current(), &MessageLoop::Quit); } - bool old_state = MessageLoop::current()->NestableTasksAllowed(); - MessageLoop::current()->SetNestableTasksAllowed(true); + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); MessageLoop::current()->Run(); - // Restore task state. - MessageLoop::current()->SetNestableTasksAllowed(old_state); return true; } diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 3a5bdd6..32403c2 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -556,11 +556,10 @@ bool PrintViewManager::RunInnerMessageLoop() { inside_inner_message_loop_ = true; // Need to enable recursive task. - bool old_state = MessageLoop::current()->NestableTasksAllowed(); - MessageLoop::current()->SetNestableTasksAllowed(true); - MessageLoop::current()->Run(); - // Restore task state. - MessageLoop::current()->SetNestableTasksAllowed(old_state); + { + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); + MessageLoop::current()->Run(); + } bool success = true; if (inside_inner_message_loop_) { diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index fb83dcb..7c576dc 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -475,10 +475,10 @@ class SessionRestoreImpl : public content::NotificationObserver { base::Bind(&SessionRestoreImpl::OnGotSession, base::Unretained(this))); if (synchronous_) { - bool old_state = MessageLoop::current()->NestableTasksAllowed(); - MessageLoop::current()->SetNestableTasksAllowed(true); - MessageLoop::current()->Run(); - MessageLoop::current()->SetNestableTasksAllowed(old_state); + { + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); + MessageLoop::current()->Run(); + } Browser* browser = ProcessSessionWindows(&windows_); delete this; return browser; diff --git a/chrome/browser/sync/profile_sync_service_harness.cc b/chrome/browser/sync/profile_sync_service_harness.cc index 34b6124..13fcc71 100644 --- a/chrome/browser/sync/profile_sync_service_harness.cc +++ b/chrome/browser/sync/profile_sync_service_harness.cc @@ -746,16 +746,17 @@ bool ProfileSyncServiceHarness::AwaitStatusChangeWithTimeout( } scoped_refptr<StateChangeTimeoutEvent> timeout_signal( new StateChangeTimeoutEvent(this, reason)); - MessageLoop* loop = MessageLoop::current(); - bool did_allow_nestable_tasks = loop->NestableTasksAllowed(); - loop->SetNestableTasksAllowed(true); - loop->PostDelayedTask( - FROM_HERE, - base::Bind(&StateChangeTimeoutEvent::Callback, - timeout_signal.get()), - base::TimeDelta::FromMilliseconds(timeout_milliseconds)); - loop->Run(); - loop->SetNestableTasksAllowed(did_allow_nestable_tasks); + { + MessageLoop* loop = MessageLoop::current(); + MessageLoop::ScopedNestableTaskAllower allow(loop); + loop->PostDelayedTask( + FROM_HERE, + base::Bind(&StateChangeTimeoutEvent::Callback, + timeout_signal.get()), + base::TimeDelta::FromMilliseconds(timeout_milliseconds)); + loop->Run(); + } + if (timeout_signal->Abort()) { DVLOG(1) << GetClientInfoString("AwaitStatusChangeWithTimeout succeeded"); return true; diff --git a/chrome/browser/ui/views/simple_message_box_views.cc b/chrome/browser/ui/views/simple_message_box_views.cc index c644a4e..596b7d9 100644 --- a/chrome/browser/ui/views/simple_message_box_views.cc +++ b/chrome/browser/ui/views/simple_message_box_views.cc @@ -63,10 +63,10 @@ bool SimpleMessageBoxViews::ShowYesNoBox(gfx::NativeWindow parent_window, aura::client::GetDispatcherClient()->RunWithDispatcher(dialog, parent_window, true); #else - bool old_state = MessageLoopForUI::current()->NestableTasksAllowed(); - MessageLoopForUI::current()->SetNestableTasksAllowed(true); - MessageLoopForUI::current()->RunWithDispatcher(dialog); - MessageLoopForUI::current()->SetNestableTasksAllowed(old_state); + { + MessageLoop::ScopedNestableTaskAllower allow(MessageLoopForUI::current()); + MessageLoopForUI::current()->RunWithDispatcher(dialog); + } #endif g_browser_process->ReleaseModule(); diff --git a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc index 795b967..ab1a843 100644 --- a/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc +++ b/chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc @@ -211,11 +211,12 @@ void NativeTabContentsViewAura::StartDragging(const WebDropData& drop_data, // We need to enable recursive tasks on the message loop so we can get // updates while in the system DoDragDrop loop. - bool old_state = MessageLoop::current()->NestableTasksAllowed(); - MessageLoop::current()->SetNestableTasksAllowed(true); - int result_op = aura::client::GetDragDropClient()->StartDragAndDrop( - data, ConvertFromWeb(ops)); - MessageLoop::current()->SetNestableTasksAllowed(old_state); + int result_op = 0; + { + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); + result_op = aura::client::GetDragDropClient()->StartDragAndDrop( + data, ConvertFromWeb(ops)); + } EndDrag(ConvertToWeb(result_op)); GetWebContents()->GetRenderViewHost()->DragSourceSystemDragEnded(); diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc b/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc index 2c289cb..58955a2 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc @@ -312,12 +312,14 @@ void TabContentsDragWin::DoDragging(const WebDropData& drop_data, // We need to enable recursive tasks on the message loop so we can get // updates while in the system DoDragDrop loop. - bool old_state = MessageLoop::current()->NestableTasksAllowed(); - MessageLoop::current()->SetNestableTasksAllowed(true); DWORD effect; - DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), drag_source_, - web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), &effect); - MessageLoop::current()->SetNestableTasksAllowed(old_state); + { + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); + DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), + drag_source_, + web_drag_utils_win::WebDragOpMaskToWinDragOpMask(ops), + &effect); + } // This works because WebDragSource::OnDragSourceDrop uses PostTask to // dispatch the actual event. diff --git a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc index 4325e40..45dde04 100644 --- a/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc +++ b/chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc @@ -362,10 +362,8 @@ void TabContentsViewViews::ShowContextMenu( // Enable recursive tasks on the message loop so we can get updates while // the context menu is being displayed. - bool old_state = MessageLoop::current()->NestableTasksAllowed(); - MessageLoop::current()->SetNestableTasksAllowed(true); + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); context_menu_->RunMenuAt(screen_point.x(), screen_point.y()); - MessageLoop::current()->SetNestableTasksAllowed(old_state); } void TabContentsViewViews::ShowPopupMenu(const gfx::Rect& bounds, diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc index 92ae005..7fbe6ac 100644 --- a/chrome/browser/ui/webui/downloads_dom_handler.cc +++ b/chrome/browser/ui/webui/downloads_dom_handler.cc @@ -268,7 +268,7 @@ void DownloadsDOMHandler::HandleDrag(const ListValue* args) { gfx::NativeView view = web_ui()->GetWebContents()->GetNativeView(); { // Enable nested tasks during DnD, while |DragDownload()| blocks. - MessageLoop::ScopedNestableTaskAllower allower(MessageLoop::current()); + MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); download_util::DragDownload(file, icon, view); } } diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc index dc68764..6a580d7 100644 --- a/chrome/test/base/ui_test_utils.cc +++ b/chrome/test/base/ui_test_utils.cc @@ -266,8 +266,7 @@ void RunMessageLoop() { MessageLoopForUI* ui_loop = content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ? MessageLoopForUI::current() : NULL; - bool did_allow_task_nesting = loop->NestableTasksAllowed(); - loop->SetNestableTasksAllowed(true); + MessageLoop::ScopedNestableTaskAllower allow(loop); if (ui_loop) { #if defined(USE_AURA) aura::RootWindow::GetInstance()->Run(); @@ -282,7 +281,6 @@ void RunMessageLoop() { } else { loop->Run(); } - loop->SetNestableTasksAllowed(did_allow_task_nesting); } void RunAllPendingInMessageLoop() { |