summaryrefslogtreecommitdiffstats
path: root/base/message_loop.h
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 19:33:52 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-14 19:33:52 +0000
commitb5717a4f9f66283a9fe04ae1f9a3a89920d5b6b0 (patch)
tree9d14cf64e2cbeed63b232ba09a8c1274280d81b0 /base/message_loop.h
parentbbdfcab9e264df0f264f56d8cb5f7ef61e5f96b6 (diff)
downloadchromium_src-b5717a4f9f66283a9fe04ae1f9a3a89920d5b6b0.zip
chromium_src-b5717a4f9f66283a9fe04ae1f9a3a89920d5b6b0.tar.gz
chromium_src-b5717a4f9f66283a9fe04ae1f9a3a89920d5b6b0.tar.bz2
Prefer ScopedNestableTaskAllower over manual save/restore
Cleanup. Changes various calls sites to use the ScopedNestableTaskAllower class to save/restore nestable task state. BUG=None TEST=Existing unit tests R=jar@chromium.org, scottbyer@chromium.org, sky@chromium.org, akalin@chromium.org, rsleevi@chromium.org, brettw@chromium.org, tony@chromium.org Review URL: https://chromiumcodereview.appspot.com/9384024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop.h')
-rw-r--r--base/message_loop.h15
1 files changed, 10 insertions, 5 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.