| 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" | |
| 9 #include "chrome/browser/printing/print_job_worker.h" | 8 #include "chrome/browser/printing/print_job_worker.h" |
| 10 | 9 |
| 11 namespace printing { | 10 namespace printing { |
| 12 | 11 |
| 13 PrinterQuery::PrinterQuery() | 12 PrinterQuery::PrinterQuery() |
| 14 : io_message_loop_(MessageLoop::current()), | 13 : io_message_loop_(MessageLoop::current()), |
| 15 ALLOW_THIS_IN_INITIALIZER_LIST(worker_(new PrintJobWorker(this))), | 14 ALLOW_THIS_IN_INITIALIZER_LIST(worker_(new PrintJobWorker(this))), |
| 16 is_print_dialog_box_shown_(false), | 15 is_print_dialog_box_shown_(false), |
| 17 cookie_(PrintSettings::NewCookie()), | 16 cookie_(PrintSettings::NewCookie()), |
| 18 last_status_(PrintingContext::FAILED) { | 17 last_status_(PrintingContext::FAILED) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 &PrintJobWorker::GetSettings, | 89 &PrintJobWorker::GetSettings, |
| 91 is_print_dialog_box_shown_, | 90 is_print_dialog_box_shown_, |
| 92 parent_view, | 91 parent_view, |
| 93 expected_page_count, | 92 expected_page_count, |
| 94 has_selection, | 93 has_selection, |
| 95 use_overlays)); | 94 use_overlays)); |
| 96 } | 95 } |
| 97 | 96 |
| 98 void PrinterQuery::StopWorker() { | 97 void PrinterQuery::StopWorker() { |
| 99 if (worker_.get()) { | 98 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; | |
| 104 worker_->Stop(); | 99 worker_->Stop(); |
| 105 worker_.reset(); | 100 worker_.reset(); |
| 106 } | 101 } |
| 107 } | 102 } |
| 108 | 103 |
| 109 bool PrinterQuery::is_print_dialog_box_shown() const { | 104 bool PrinterQuery::is_print_dialog_box_shown() const { |
| 110 return is_print_dialog_box_shown_; | 105 return is_print_dialog_box_shown_; |
| 111 } | 106 } |
| 112 | 107 |
| 113 bool PrinterQuery::is_callback_pending() const { | 108 bool PrinterQuery::is_callback_pending() const { |
| 114 return callback_.get() != NULL; | 109 return callback_.get() != NULL; |
| 115 } | 110 } |
| 116 | 111 |
| 117 bool PrinterQuery::is_valid() const { | 112 bool PrinterQuery::is_valid() const { |
| 118 return worker_.get() != NULL; | 113 return worker_.get() != NULL; |
| 119 } | 114 } |
| 120 | 115 |
| 121 } // namespace printing | 116 } // namespace printing |
| OLD | NEW |