| OLD | NEW |
| 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/printer_query.h" | 5 #include "chrome/browser/printing/printer_query.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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 const base::Closure& callback) { | 93 const base::Closure& callback) { |
| 94 StartWorker(callback); | 94 StartWorker(callback); |
| 95 | 95 |
| 96 worker_->message_loop()->PostTask( | 96 worker_->message_loop()->PostTask( |
| 97 FROM_HERE, | 97 FROM_HERE, |
| 98 base::Bind(&PrintJobWorker::SetSettings, | 98 base::Bind(&PrintJobWorker::SetSettings, |
| 99 base::Unretained(worker_.get()), | 99 base::Unretained(worker_.get()), |
| 100 new_settings.DeepCopy())); | 100 new_settings.DeepCopy())); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void PrinterQuery::SetWorkerDestination( |
| 104 PrintDestinationInterface* destination) { |
| 105 worker_->SetPrintDestination(destination); |
| 106 } |
| 107 |
| 103 void PrinterQuery::StartWorker(const base::Closure& callback) { | 108 void PrinterQuery::StartWorker(const base::Closure& callback) { |
| 104 DCHECK(callback_.is_null()); | 109 DCHECK(callback_.is_null()); |
| 105 DCHECK(worker_.get()); | 110 DCHECK(worker_.get()); |
| 106 | 111 |
| 107 // Lazily create the worker thread. There is one worker thread per print job. | 112 // Lazily create the worker thread. There is one worker thread per print job. |
| 108 if (!worker_->message_loop()) | 113 if (!worker_->message_loop()) |
| 109 worker_->Start(); | 114 worker_->Start(); |
| 110 | 115 |
| 111 callback_ = callback; | 116 callback_ = callback; |
| 112 } | 117 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 124 | 129 |
| 125 bool PrinterQuery::is_callback_pending() const { | 130 bool PrinterQuery::is_callback_pending() const { |
| 126 return !callback_.is_null(); | 131 return !callback_.is_null(); |
| 127 } | 132 } |
| 128 | 133 |
| 129 bool PrinterQuery::is_valid() const { | 134 bool PrinterQuery::is_valid() const { |
| 130 return worker_.get() != NULL; | 135 return worker_.get() != NULL; |
| 131 } | 136 } |
| 132 | 137 |
| 133 } // namespace printing | 138 } // namespace printing |
| OLD | NEW |