Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: content/browser/download/drag_download_file.cc

Issue 9384024: Prefer ScopedNestableTaskAllower over manual save/restore (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/download/drag_download_file.h" 5 #include "content/browser/download/drag_download_file.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/browser/download/download_stats.h" 10 #include "content/browser/download/download_stats.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Only do the check on Windows where two threads are involved. 216 // Only do the check on Windows where two threads are involved.
217 #if defined(OS_WIN) 217 #if defined(OS_WIN)
218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
219 #endif 219 #endif
220 } 220 }
221 221
222 #if defined(OS_WIN) 222 #if defined(OS_WIN)
223 void DragDownloadFile::StartNestedMessageLoop() { 223 void DragDownloadFile::StartNestedMessageLoop() {
224 AssertCurrentlyOnDragThread(); 224 AssertCurrentlyOnDragThread();
225 225
226 bool old_state = MessageLoop::current()->NestableTasksAllowed(); 226 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
227 MessageLoop::current()->SetNestableTasksAllowed(true);
228 is_running_nested_message_loop_ = true; 227 is_running_nested_message_loop_ = true;
229 MessageLoop::current()->Run(); 228 MessageLoop::current()->Run();
jar (doing other things) 2012/02/11 03:24:38 This looks suspiciously like a bug... but I'm not
dhollowa 2012/02/13 17:44:26 Done. I've added DCHECK to verify the logic. If
230 MessageLoop::current()->SetNestableTasksAllowed(old_state);
231 } 229 }
232 230
233 void DragDownloadFile::QuitNestedMessageLoop() { 231 void DragDownloadFile::QuitNestedMessageLoop() {
234 AssertCurrentlyOnDragThread(); 232 AssertCurrentlyOnDragThread();
235 233
236 if (is_running_nested_message_loop_) { 234 if (is_running_nested_message_loop_) {
237 is_running_nested_message_loop_ = false; 235 is_running_nested_message_loop_ = false;
238 MessageLoop::current()->Quit(); 236 MessageLoop::current()->Quit();
239 } 237 }
240 } 238 }
241 #endif 239 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698