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

Side by Side Diff: chrome/browser/printing/print_job.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/printing/print_job.h" 5 #include "chrome/browser/printing/print_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 bool PrintJob::FlushJob(int timeout_ms) { 192 bool PrintJob::FlushJob(int timeout_ms) {
193 // Make sure the object outlive this message loop. 193 // Make sure the object outlive this message loop.
194 scoped_refptr<PrintJob> handle(this); 194 scoped_refptr<PrintJob> handle(this);
195 195
196 // Stop() will eventually be called, which will get out of the inner message 196 // Stop() will eventually be called, which will get out of the inner message
197 // loop. But, don't take it for granted and set a timer in case something goes 197 // loop. But, don't take it for granted and set a timer in case something goes
198 // wrong. 198 // wrong.
199 base::OneShotTimer<MessageLoop> quit_task; 199 base::OneShotTimer<MessageLoop> quit_task;
200 if (timeout_ms) { 200 if (timeout_ms) {
201 quit_task.Start(FROM_HERE, TimeDelta::FromMilliseconds(timeout_ms), 201 quit_task.Start(FROM_HERE, TimeDelta::FromMilliseconds(timeout_ms),
jar (doing other things) 2012/02/11 03:24:38 This is pretty evil/problematic... though not rela
dhollowa 2012/02/13 17:44:26 Looks like this was added by Darin. I'm not sure
jar (doing other things) 2012/02/13 18:03:02 Darin, This code looks pretty risky... especially
202 MessageLoop::current(), &MessageLoop::Quit); 202 MessageLoop::current(), &MessageLoop::Quit);
203 } 203 }
204 204
205 bool old_state = MessageLoop::current()->NestableTasksAllowed(); 205 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
206 MessageLoop::current()->SetNestableTasksAllowed(true);
207 MessageLoop::current()->Run(); 206 MessageLoop::current()->Run();
208 // Restore task state.
209 MessageLoop::current()->SetNestableTasksAllowed(old_state);
210 207
211 return true; 208 return true;
212 } 209 }
213 210
214 void PrintJob::DisconnectSource() { 211 void PrintJob::DisconnectSource() {
215 source_ = NULL; 212 source_ = NULL;
216 if (document_.get()) 213 if (document_.get())
217 document_->DisconnectSource(); 214 document_->DisconnectSource();
218 } 215 }
219 216
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 362
366 PrintedDocument* JobEventDetails::document() const { 363 PrintedDocument* JobEventDetails::document() const {
367 return document_; 364 return document_;
368 } 365 }
369 366
370 PrintedPage* JobEventDetails::page() const { 367 PrintedPage* JobEventDetails::page() const {
371 return page_; 368 return page_;
372 } 369 }
373 370
374 } // namespace printing 371 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698