Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/browser/printing/print_job_worker.cc

Issue 6541036: Take out incorrect usage of MessageLoop::SetNestableTasksAllowed. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_worker.h" 5 #include "chrome/browser/printing/print_job_worker.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/browser_thread.h" 9 #include "chrome/browser/browser_thread.h"
10 #include "chrome/browser/printing/print_job.h" 10 #include "chrome/browser/printing/print_job.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void PrintJobWorker::GetSettings(bool ask_user_for_settings, 73 void PrintJobWorker::GetSettings(bool ask_user_for_settings,
74 gfx::NativeView parent_view, 74 gfx::NativeView parent_view,
75 int document_page_count, 75 int document_page_count,
76 bool has_selection, 76 bool has_selection,
77 bool use_overlays) { 77 bool use_overlays) {
78 DCHECK_EQ(message_loop(), MessageLoop::current()); 78 DCHECK_EQ(message_loop(), MessageLoop::current());
79 DCHECK_EQ(page_number_, PageNumber::npos()); 79 DCHECK_EQ(page_number_, PageNumber::npos());
80 80
81 // Recursive task processing is needed for the dialog in case it needs to be 81 // Recursive task processing is needed for the dialog in case it needs to be
82 // destroyed by a task. 82 // destroyed by a task.
83 MessageLoop::current()->SetNestableTasksAllowed(true); 83 // TODO: this code is wrong, SetNestableTasksAllowed(true) is needed on the
84 // thread where the PrintDlgEx is called, and definitely both calls should
85 // happen on the same thread. See http://crbug.com/73466
86 // MessageLoop::current()->SetNestableTasksAllowed(true);
84 printing_context_->set_use_overlays(use_overlays); 87 printing_context_->set_use_overlays(use_overlays);
M-A Ruel 2011/02/19 01:45:43 You want to move this to printing/printing_context
85 88
86 if (ask_user_for_settings) { 89 if (ask_user_for_settings) {
87 BrowserThread::PostTask( 90 BrowserThread::PostTask(
88 BrowserThread::UI, FROM_HERE, 91 BrowserThread::UI, FROM_HERE,
89 NewRunnableMethod(this, &PrintJobWorker::GetSettingsWithUI, 92 NewRunnableMethod(this, &PrintJobWorker::GetSettingsWithUI,
90 parent_view, document_page_count, 93 parent_view, document_page_count,
91 has_selection)); 94 has_selection));
92 } else { 95 } else {
93 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 96 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
94 NewRunnableMethod(this, &PrintJobWorker::UseDefaultSettings)); 97 NewRunnableMethod(this, &PrintJobWorker::UseDefaultSettings));
95 } 98 }
96 } 99 }
97 100
98 void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) { 101 void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) {
99 // Most PrintingContext functions may start a message loop and process 102 // Most PrintingContext functions may start a message loop and process
100 // message recursively, so disable recursive task processing. 103 // message recursively, so disable recursive task processing.
101 MessageLoop::current()->SetNestableTasksAllowed(false); 104 // TODO: see above comment. SetNestableTasksAllowed(false) needs to be called
105 // on the same thread as the previous call. See http://crbug.com/73466
106 // MessageLoop::current()->SetNestableTasksAllowed(false);
102 107
103 // We can't use OnFailure() here since owner_ may not support notifications. 108 // We can't use OnFailure() here since owner_ may not support notifications.
104 109
105 // PrintJob will create the new PrintedDocument. 110 // PrintJob will create the new PrintedDocument.
106 owner_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 111 owner_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
107 owner_, 112 owner_,
108 &PrintJobWorkerOwner::GetSettingsDone, 113 &PrintJobWorkerOwner::GetSettingsDone,
109 printing_context_->settings(), 114 printing_context_->settings(),
110 result)); 115 result));
111 } 116 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 printing::PrintJobWorker* obj) { 311 printing::PrintJobWorker* obj) {
307 DCHECK(!owner_.get()); 312 DCHECK(!owner_.get());
308 owner_ = obj->owner_; 313 owner_ = obj->owner_;
309 } 314 }
310 315
311 void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee( 316 void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee(
312 printing::PrintJobWorker* obj) { 317 printing::PrintJobWorker* obj) {
313 DCHECK_EQ(owner_, obj->owner_); 318 DCHECK_EQ(owner_, obj->owner_);
314 owner_ = NULL; 319 owner_ = NULL;
315 } 320 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698