summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/message_loop.h15
-rw-r--r--base/message_loop_unittest.cc8
-rw-r--r--base/tracked_objects.h2
-rw-r--r--chrome/browser/automation/automation_provider_win.cc6
-rw-r--r--chrome/browser/printing/print_job.cc7
-rw-r--r--chrome/browser/printing/print_view_manager.cc9
-rw-r--r--chrome/browser/sessions/session_restore.cc8
-rw-r--r--chrome/browser/sync/profile_sync_service_harness.cc21
-rw-r--r--chrome/browser/ui/views/simple_message_box_views.cc8
-rw-r--r--chrome/browser/ui/views/tab_contents/native_tab_contents_view_aura.cc11
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc12
-rw-r--r--chrome/browser/ui/views/tab_contents/tab_contents_view_views.cc4
-rw-r--r--chrome/browser/ui/webui/downloads_dom_handler.cc2
-rw-r--r--chrome/test/base/ui_test_utils.cc4
-rw-r--r--content/browser/download/drag_download_file.cc5
-rw-r--r--content/renderer/devtools_agent.cc4
-rw-r--r--ipc/ipc_sync_channel.cc8
-rw-r--r--net/base/file_stream_unittest.cc4
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc8
-rw-r--r--net/socket/transport_client_socket_pool_unittest.cc3
-rw-r--r--ppapi/proxy/ppb_testing_proxy.cc4
-rw-r--r--ui/views/controls/menu/menu_controller.cc10
-rw-r--r--webkit/database/database_connections.cc4
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.cc4
-rw-r--r--webkit/plugins/ppapi/ppb_flash_message_loop_impl.cc10
-rw-r--r--webkit/support/webkit_support.cc8
-rw-r--r--webkit/tools/test_shell/test_shell_devtools_agent.cc6
28 files changed, 89 insertions, 110 deletions
diff --git a/base/message_loop.h b/base/message_loop.h
index e14baa7..f940502 100644
--- a/base/message_loop.h
+++ b/base/message_loop.h
@@ -67,11 +67,12 @@ class Histogram;
// (DoDragDrop), printer functions (StartDoc) and *many* others.
//
// Sample workaround when inner task processing is needed:
-// bool old_state = MessageLoop::current()->NestableTasksAllowed();
-// MessageLoop::current()->SetNestableTasksAllowed(true);
-// HRESULT hr = DoDragDrop(...); // Implicitly runs a modal message loop here.
-// MessageLoop::current()->SetNestableTasksAllowed(old_state);
-// // Process hr (the result returned by DoDragDrop().
+// HRESULT hr;
+// {
+// MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
+// hr = DoDragDrop(...); // Implicitly runs a modal message loop.
+// }
+// // Process |hr| (the result returned by DoDragDrop()).
//
// Please be SURE your task is reentrant (nestable) and all global variables
// are stable and accessible before calling SetNestableTasksAllowed(true).
@@ -264,6 +265,10 @@ class BASE_EXPORT MessageLoop : public base::MessagePump::Delegate {
// using common controls or printer functions. By default, recursive task
// processing is disabled.
//
+ // Please utilize |ScopedNestableTaskAllower| instead of calling these methods
+ // directly. In general nestable message loops are to be avoided. They are
+ // dangerous and difficult to get right, so please use with extreme caution.
+ //
// The specific case where tasks get queued is:
// - The thread is running a message loop.
// - It receives a task #1 and execute it.
diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc
index 85ee568..b404dc8 100644
--- a/base/message_loop_unittest.cc
+++ b/base/message_loop_unittest.cc
@@ -985,10 +985,10 @@ void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) {
void FuncThatPumps(TaskList* order, int cookie) {
order->RecordStart(PUMPS, cookie);
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
- MessageLoop::current()->RunAllPending();
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
+ {
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
+ MessageLoop::current()->RunAllPending();
+ }
order->RecordEnd(PUMPS, cookie);
}
diff --git a/base/tracked_objects.h b/base/tracked_objects.h
index a108388..96814f6 100644
--- a/base/tracked_objects.h
+++ b/base/tracked_objects.h
@@ -185,8 +185,6 @@
// DeathData that is reset (as synchronously as possible) during each snapshot.
// This will facilitate displaying a max value for each snapshot period.
-class MessageLoop;
-
namespace tracked_objects {
//------------------------------------------------------------------------------
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() {
diff --git a/content/browser/download/drag_download_file.cc b/content/browser/download/drag_download_file.cc
index cecb9be..c4bb898 100644
--- a/content/browser/download/drag_download_file.cc
+++ b/content/browser/download/drag_download_file.cc
@@ -223,11 +223,10 @@ void DragDownloadFile::AssertCurrentlyOnUIThread() {
void DragDownloadFile::StartNestedMessageLoop() {
AssertCurrentlyOnDragThread();
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
is_running_nested_message_loop_ = true;
MessageLoop::current()->Run();
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
+ DCHECK(!is_running_nested_message_loop_);
}
void DragDownloadFile::QuitNestedMessageLoop() {
diff --git a/content/renderer/devtools_agent.cc b/content/renderer/devtools_agent.cc
index c596a83..1d2c906 100644
--- a/content/renderer/devtools_agent.cc
+++ b/content/renderer/devtools_agent.cc
@@ -38,10 +38,8 @@ class WebKitClientMessageLoopImpl
message_loop_ = NULL;
}
virtual void run() {
- bool old_state = message_loop_->NestableTasksAllowed();
- message_loop_->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(message_loop_);
message_loop_->Run();
- message_loop_->SetNestableTasksAllowed(old_state);
}
virtual void quitNow() {
message_loop_->QuitNow();
diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc
index 74d9744..be8315c 100644
--- a/ipc/ipc_sync_channel.cc
+++ b/ipc/ipc_sync_channel.cc
@@ -506,11 +506,11 @@ void SyncChannel::WaitForReplyWithNestedMessageLoop(SyncContext* context) {
sync_msg_queue->set_top_send_done_watcher(&send_done_watcher);
send_done_watcher.StartWatching(context->GetSendDoneEvent(), context);
- 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();
+ }
sync_msg_queue->set_top_send_done_watcher(old_send_done_event_watcher);
if (old_send_done_event_watcher && old_event) {
diff --git a/net/base/file_stream_unittest.cc b/net/base/file_stream_unittest.cc
index a0500c1..712904e 100644
--- a/net/base/file_stream_unittest.cc
+++ b/net/base/file_stream_unittest.cc
@@ -749,10 +749,8 @@ class TestWriteReadCompletionCallback {
char buf[4];
rv = stream_->Read(buf, arraysize(buf), callback.callback());
if (rv == ERR_IO_PENDING) {
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
rv = callback.WaitForResult();
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
EXPECT_LE(0, rv);
if (rv <= 0)
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 3ef34c4..b1c1a99 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -1410,8 +1410,10 @@ class RequestSocketCallback : public TestCompletionCallbackBase {
handle_->socket()->Disconnect();
handle_->Reset();
{
- MessageLoop::ScopedNestableTaskAllower nestable(
- MessageLoop::current());
+ // TODO: Resolve conflicting intentions of stopping recursion with the
+ // |!within_callback_| test (above) and the call to |RunAllPending()|
+ // below. http://crbug.com/114130.
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
MessageLoop::current()->RunAllPending();
}
within_callback_ = true;
@@ -1437,7 +1439,7 @@ class RequestSocketCallback : public TestCompletionCallbackBase {
// operations that happen on timers (e.g. cleanup of idle
// connections) can execute.
{
- MessageLoop::ScopedNestableTaskAllower nestable(
+ MessageLoop::ScopedNestableTaskAllower allow(
MessageLoop::current());
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
EXPECT_EQ(OK, next_job_callback.WaitForResult());
diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc
index 3012518..3aeda50 100644
--- a/net/socket/transport_client_socket_pool_unittest.cc
+++ b/net/socket/transport_client_socket_pool_unittest.cc
@@ -797,8 +797,7 @@ class RequestSocketCallback : public TestCompletionCallbackBase {
handle_->socket()->Disconnect();
handle_->Reset();
{
- MessageLoop::ScopedNestableTaskAllower nestable(
- MessageLoop::current());
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
MessageLoop::current()->RunAllPending();
}
within_callback_ = true;
diff --git a/ppapi/proxy/ppb_testing_proxy.cc b/ppapi/proxy/ppb_testing_proxy.cc
index 9c0a14b..d1f5cec 100644
--- a/ppapi/proxy/ppb_testing_proxy.cc
+++ b/ppapi/proxy/ppb_testing_proxy.cc
@@ -50,10 +50,8 @@ PP_Bool ReadImageData(PP_Resource graphics_2d,
}
void RunMessageLoop(PP_Instance instance) {
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
MessageLoop::current()->Run();
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
void QuitMessageLoop(PP_Instance instance) {
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index 873fcf5..73149c2 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -323,11 +323,11 @@ MenuItemView* MenuController::Run(Widget* parent,
aura::client::GetDispatcherClient()->RunWithDispatcher(this,
parent->GetNativeWindow(), true);
#else
- MessageLoopForUI* loop = MessageLoopForUI::current();
- bool did_allow_task_nesting = loop->NestableTasksAllowed();
- loop->SetNestableTasksAllowed(true);
- loop->RunWithDispatcher(this);
- loop->SetNestableTasksAllowed(did_allow_task_nesting);
+ {
+ MessageLoopForUI* loop = MessageLoopForUI::current();
+ MessageLoop::ScopedNestableTaskAllower allow(loop);
+ loop->RunWithDispatcher(this);
+ }
#endif
if (ViewsDelegate::views_delegate)
diff --git a/webkit/database/database_connections.cc b/webkit/database/database_connections.cc
index f38a869..e16080c 100644
--- a/webkit/database/database_connections.cc
+++ b/webkit/database/database_connections.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.
@@ -132,7 +132,7 @@ void DatabaseConnectionsWrapper::WaitForAllDatabasesToClose() {
DCHECK(main_thread_->BelongsToCurrentThread());
if (HasOpenConnections()) {
AutoReset<bool> auto_reset(&waiting_for_dbs_to_close_, true);
- MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current());
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
MessageLoop::current()->Run();
}
}
diff --git a/webkit/plugins/ppapi/plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 93d8161..5a7a4e9 100644
--- a/webkit/plugins/ppapi/plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -211,10 +211,8 @@ PP_Bool ReadImageData(PP_Resource device_context_2d,
}
void RunMessageLoop(PP_Instance instance) {
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
MessageLoop::current()->Run();
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
void QuitMessageLoop(PP_Instance instance) {
diff --git a/webkit/plugins/ppapi/ppb_flash_impl.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc
index c1133ba..2dc7842 100644
--- a/webkit/plugins/ppapi/ppb_flash_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl.cc
@@ -199,10 +199,8 @@ int32_t Navigate11(PP_Resource request_id,
}
void RunMessageLoop(PP_Instance instance) {
- bool old_state = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
MessageLoop::current()->Run();
- MessageLoop::current()->SetNestableTasksAllowed(old_state);
}
void QuitMessageLoop(PP_Instance instance) {
diff --git a/webkit/plugins/ppapi/ppb_flash_message_loop_impl.cc b/webkit/plugins/ppapi/ppb_flash_message_loop_impl.cc
index 8a3ff48..647e1a8 100644
--- a/webkit/plugins/ppapi/ppb_flash_message_loop_impl.cc
+++ b/webkit/plugins/ppapi/ppb_flash_message_loop_impl.cc
@@ -87,14 +87,12 @@ int32_t PPB_Flash_MessageLoop_Impl::InternalRun(
// It is possible that the PPB_Flash_MessageLoop_Impl object has been
// destroyed when the nested message loop exits.
scoped_refptr<State> state_protector(state_);
-
- bool old_value = MessageLoop::current()->NestableTasksAllowed();
- MessageLoop::current()->SetNestableTasksAllowed(true);
- MessageLoop::current()->Run();
-
+ {
+ MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
+ MessageLoop::current()->Run();
+ }
// Don't access data members of the class below.
- MessageLoop::current()->SetNestableTasksAllowed(old_value);
return state_protector->result();
}
diff --git a/webkit/support/webkit_support.cc b/webkit/support/webkit_support.cc
index 8c312ef..db6be26 100644
--- a/webkit/support/webkit_support.cc
+++ b/webkit/support/webkit_support.cc
@@ -213,10 +213,8 @@ class WebKitClientMessageLoopImpl
message_loop_ = NULL;
}
virtual void run() {
- bool old_state = message_loop_->NestableTasksAllowed();
- message_loop_->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(message_loop_);
message_loop_->Run();
- message_loop_->SetNestableTasksAllowed(old_state);
}
virtual void quitNow() {
message_loop_->QuitNow();
@@ -450,10 +448,8 @@ void MessageLoopSetNestableTasksAllowed(bool allowed) {
void DispatchMessageLoop() {
MessageLoop* current = MessageLoop::current();
- bool old_state = current->NestableTasksAllowed();
- current->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(current);
current->RunAllPending();
- current->SetNestableTasksAllowed(old_state);
}
WebDevToolsAgentClient::WebKitClientMessageLoop* CreateDevToolsMessageLoop() {
diff --git a/webkit/tools/test_shell/test_shell_devtools_agent.cc b/webkit/tools/test_shell/test_shell_devtools_agent.cc
index b2e4a95..e4ae508 100644
--- a/webkit/tools/test_shell/test_shell_devtools_agent.cc
+++ b/webkit/tools/test_shell/test_shell_devtools_agent.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.
@@ -29,10 +29,8 @@ class WebKitClientMessageLoopImpl
message_loop_ = NULL;
}
virtual void run() {
- bool old_state = message_loop_->NestableTasksAllowed();
- message_loop_->SetNestableTasksAllowed(true);
+ MessageLoop::ScopedNestableTaskAllower allow(message_loop_);
message_loop_->Run();
- message_loop_->SetNestableTasksAllowed(old_state);
}
virtual void quitNow() {
message_loop_->QuitNow();