OLD | NEW |
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/printer_query.h" | 5 #include "chrome/browser/printing/printer_query.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/thread_restrictions.h" |
8 #include "chrome/browser/printing/print_job_worker.h" | 9 #include "chrome/browser/printing/print_job_worker.h" |
9 | 10 |
10 namespace printing { | 11 namespace printing { |
11 | 12 |
12 PrinterQuery::PrinterQuery() | 13 PrinterQuery::PrinterQuery() |
13 : io_message_loop_(MessageLoop::current()), | 14 : io_message_loop_(MessageLoop::current()), |
14 ALLOW_THIS_IN_INITIALIZER_LIST(worker_(new PrintJobWorker(this))), | 15 ALLOW_THIS_IN_INITIALIZER_LIST(worker_(new PrintJobWorker(this))), |
15 is_print_dialog_box_shown_(false), | 16 is_print_dialog_box_shown_(false), |
16 cookie_(PrintSettings::NewCookie()), | 17 cookie_(PrintSettings::NewCookie()), |
17 last_status_(PrintingContext::FAILED) { | 18 last_status_(PrintingContext::FAILED) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 &PrintJobWorker::GetSettings, | 90 &PrintJobWorker::GetSettings, |
90 is_print_dialog_box_shown_, | 91 is_print_dialog_box_shown_, |
91 parent_view, | 92 parent_view, |
92 expected_page_count, | 93 expected_page_count, |
93 has_selection, | 94 has_selection, |
94 use_overlays)); | 95 use_overlays)); |
95 } | 96 } |
96 | 97 |
97 void PrinterQuery::StopWorker() { | 98 void PrinterQuery::StopWorker() { |
98 if (worker_.get()) { | 99 if (worker_.get()) { |
| 100 // http://crbug.com/66082: We're blocking on the PrinterQuery's worker |
| 101 // thread. It's not clear to me if this may result in blocking the current |
| 102 // thread for an unacceptable time. We should probably fix it. |
| 103 base::ThreadRestrictions::ScopedAllowIO allow_io; |
99 worker_->Stop(); | 104 worker_->Stop(); |
100 worker_.reset(); | 105 worker_.reset(); |
101 } | 106 } |
102 } | 107 } |
103 | 108 |
104 bool PrinterQuery::is_print_dialog_box_shown() const { | 109 bool PrinterQuery::is_print_dialog_box_shown() const { |
105 return is_print_dialog_box_shown_; | 110 return is_print_dialog_box_shown_; |
106 } | 111 } |
107 | 112 |
108 bool PrinterQuery::is_callback_pending() const { | 113 bool PrinterQuery::is_callback_pending() const { |
109 return callback_.get() != NULL; | 114 return callback_.get() != NULL; |
110 } | 115 } |
111 | 116 |
112 bool PrinterQuery::is_valid() const { | 117 bool PrinterQuery::is_valid() const { |
113 return worker_.get() != NULL; | 118 return worker_.get() != NULL; |
114 } | 119 } |
115 | 120 |
116 } // namespace printing | 121 } // namespace printing |
OLD | NEW |