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/print_job_worker.h" | 5 #include "chrome/browser/printing/print_job_worker.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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 void PrintJobWorker::UseDefaultSettings() { | 201 void PrintJobWorker::UseDefaultSettings() { |
202 PrintingContext::Result result = printing_context_->UseDefaultSettings(); | 202 PrintingContext::Result result = printing_context_->UseDefaultSettings(); |
203 GetSettingsDone(result); | 203 GetSettingsDone(result); |
204 } | 204 } |
205 | 205 |
206 void PrintJobWorker::StartPrinting(PrintedDocument* new_document) { | 206 void PrintJobWorker::StartPrinting(PrintedDocument* new_document) { |
207 DCHECK_EQ(message_loop(), base::MessageLoop::current()); | 207 DCHECK_EQ(message_loop(), base::MessageLoop::current()); |
208 DCHECK_EQ(page_number_, PageNumber::npos()); | 208 DCHECK_EQ(page_number_, PageNumber::npos()); |
209 DCHECK_EQ(document_, new_document); | 209 DCHECK_EQ(document_, new_document); |
210 DCHECK(document_.get()); | 210 DCHECK(document_.get()); |
211 DCHECK(new_document->settings().Equals(printing_context_->settings())); | |
212 | 211 |
213 if (!document_.get() || page_number_ != PageNumber::npos() || | 212 if (!document_.get() || page_number_ != PageNumber::npos() || |
214 document_.get() != new_document) { | 213 document_.get() != new_document) { |
215 return; | 214 return; |
216 } | 215 } |
217 | 216 |
218 string16 document_name = | 217 string16 document_name = |
219 printing::PrintBackend::SimplifyDocumentTitle(document_->name()); | 218 printing::PrintBackend::SimplifyDocumentTitle(document_->name()); |
220 if (document_name.empty()) { | 219 if (document_name.empty()) { |
221 document_name = printing::PrintBackend::SimplifyDocumentTitle( | 220 document_name = printing::PrintBackend::SimplifyDocumentTitle( |
(...skipping 11 matching lines...) Expand all Loading... |
233 OnNewPage(); | 232 OnNewPage(); |
234 // Don't touch this anymore since the instance could be destroyed. It happens | 233 // Don't touch this anymore since the instance could be destroyed. It happens |
235 // if all the pages are printed a one sweep and the client doesn't have a | 234 // if all the pages are printed a one sweep and the client doesn't have a |
236 // handle to us anymore. There's a timing issue involved between the worker | 235 // handle to us anymore. There's a timing issue involved between the worker |
237 // thread and the UI thread. Take no chance. | 236 // thread and the UI thread. Take no chance. |
238 } | 237 } |
239 | 238 |
240 void PrintJobWorker::OnDocumentChanged(PrintedDocument* new_document) { | 239 void PrintJobWorker::OnDocumentChanged(PrintedDocument* new_document) { |
241 DCHECK_EQ(message_loop(), base::MessageLoop::current()); | 240 DCHECK_EQ(message_loop(), base::MessageLoop::current()); |
242 DCHECK_EQ(page_number_, PageNumber::npos()); | 241 DCHECK_EQ(page_number_, PageNumber::npos()); |
243 DCHECK(!new_document || | |
244 new_document->settings().Equals(printing_context_->settings())); | |
245 | 242 |
246 if (page_number_ != PageNumber::npos()) | 243 if (page_number_ != PageNumber::npos()) |
247 return; | 244 return; |
248 | 245 |
249 document_ = new_document; | 246 document_ = new_document; |
250 } | 247 } |
251 | 248 |
252 void PrintJobWorker::OnNewPage() { | 249 void PrintJobWorker::OnNewPage() { |
253 if (!document_.get()) // Spurious message. | 250 if (!document_.get()) // Spurious message. |
254 return; | 251 return; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 JobEventDetails::FAILED, document_, | 377 JobEventDetails::FAILED, document_, |
381 scoped_refptr<PrintedPage>())); | 378 scoped_refptr<PrintedPage>())); |
382 Cancel(); | 379 Cancel(); |
383 | 380 |
384 // Makes sure the variables are reinitialized. | 381 // Makes sure the variables are reinitialized. |
385 document_ = NULL; | 382 document_ = NULL; |
386 page_number_ = PageNumber::npos(); | 383 page_number_ = PageNumber::npos(); |
387 } | 384 } |
388 | 385 |
389 } // namespace printing | 386 } // namespace printing |
OLD | NEW |