OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void PrinterQuery::SetSettings(scoped_ptr<base::DictionaryValue> new_settings, | 88 void PrinterQuery::SetSettings(scoped_ptr<base::DictionaryValue> new_settings, |
89 const base::Closure& callback) { | 89 const base::Closure& callback) { |
90 StartWorker(callback); | 90 StartWorker(callback); |
91 | 91 |
92 worker_->PostTask(FROM_HERE, | 92 worker_->PostTask(FROM_HERE, |
93 base::Bind(&PrintJobWorker::SetSettings, | 93 base::Bind(&PrintJobWorker::SetSettings, |
94 base::Unretained(worker_.get()), | 94 base::Unretained(worker_.get()), |
95 base::Passed(&new_settings))); | 95 base::Passed(&new_settings))); |
96 } | 96 } |
97 | 97 |
98 void PrinterQuery::SetWorkerDestination( | |
99 PrintDestinationInterface* destination) { | |
100 worker_->SetPrintDestination(destination); | |
101 } | |
102 | |
103 void PrinterQuery::StartWorker(const base::Closure& callback) { | 98 void PrinterQuery::StartWorker(const base::Closure& callback) { |
104 DCHECK(callback_.is_null()); | 99 DCHECK(callback_.is_null()); |
105 DCHECK(worker_.get()); | 100 DCHECK(worker_.get()); |
106 | 101 |
107 // Lazily create the worker thread. There is one worker thread per print job. | 102 // Lazily create the worker thread. There is one worker thread per print job. |
108 if (!worker_->IsRunning()) | 103 if (!worker_->IsRunning()) |
109 worker_->Start(); | 104 worker_->Start(); |
110 | 105 |
111 callback_ = callback; | 106 callback_ = callback; |
112 } | 107 } |
(...skipping 11 matching lines...) Expand all Loading... |
124 | 119 |
125 bool PrinterQuery::is_callback_pending() const { | 120 bool PrinterQuery::is_callback_pending() const { |
126 return !callback_.is_null(); | 121 return !callback_.is_null(); |
127 } | 122 } |
128 | 123 |
129 bool PrinterQuery::is_valid() const { | 124 bool PrinterQuery::is_valid() const { |
130 return worker_.get() != NULL; | 125 return worker_.get() != NULL; |
131 } | 126 } |
132 | 127 |
133 } // namespace printing | 128 } // namespace printing |
OLD | NEW |