| 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.h" | 5 #include "chrome/browser/printing/print_job.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" |
| 11 #include "base/threading/worker_pool.h" | 11 #include "base/threading/worker_pool.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/printing/print_job_worker.h" | 14 #include "chrome/browser/printing/print_job_worker.h" |
| 15 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 16 #include "printing/printed_document.h" | 17 #include "printing/printed_document.h" |
| 17 #include "printing/printed_page.h" | 18 #include "printing/printed_page.h" |
| 18 | 19 |
| 19 using base::TimeDelta; | 20 using base::TimeDelta; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // Helper function to ensure |owner| is valid until at least |callback| returns. | 24 // Helper function to ensure |owner| is valid until at least |callback| returns. |
| 24 void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner, | 25 void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 DCHECK(!source_); | 63 DCHECK(!source_); |
| 63 DCHECK(!worker_.get()); | 64 DCHECK(!worker_.get()); |
| 64 DCHECK(!is_job_pending_); | 65 DCHECK(!is_job_pending_); |
| 65 DCHECK(!is_canceling_); | 66 DCHECK(!is_canceling_); |
| 66 DCHECK(!document_.get()); | 67 DCHECK(!document_.get()); |
| 67 source_ = source; | 68 source_ = source; |
| 68 worker_.reset(job->DetachWorker(this)); | 69 worker_.reset(job->DetachWorker(this)); |
| 69 settings_ = job->settings(); | 70 settings_ = job->settings(); |
| 70 | 71 |
| 71 PrintedDocument* new_doc = | 72 PrintedDocument* new_doc = |
| 72 new PrintedDocument(settings_, source_, job->cookie()); | 73 new PrintedDocument(settings_, |
| 74 source_, |
| 75 job->cookie(), |
| 76 content::BrowserThread::GetBlockingPool()); |
| 73 new_doc->set_page_count(page_count); | 77 new_doc->set_page_count(page_count); |
| 74 UpdatePrintedDocument(new_doc); | 78 UpdatePrintedDocument(new_doc); |
| 75 | 79 |
| 76 // Don't forget to register to our own messages. | 80 // Don't forget to register to our own messages. |
| 77 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, | 81 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, |
| 78 content::Source<PrintJob>(this)); | 82 content::Source<PrintJob>(this)); |
| 79 } | 83 } |
| 80 | 84 |
| 81 void PrintJob::Observe(int type, | 85 void PrintJob::Observe(int type, |
| 82 const content::NotificationSource& source, | 86 const content::NotificationSource& source, |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 358 } |
| 355 | 359 |
| 356 JobEventDetails::~JobEventDetails() { | 360 JobEventDetails::~JobEventDetails() { |
| 357 } | 361 } |
| 358 | 362 |
| 359 PrintedDocument* JobEventDetails::document() const { return document_.get(); } | 363 PrintedDocument* JobEventDetails::document() const { return document_.get(); } |
| 360 | 364 |
| 361 PrintedPage* JobEventDetails::page() const { return page_.get(); } | 365 PrintedPage* JobEventDetails::page() const { return page_.get(); } |
| 362 | 366 |
| 363 } // namespace printing | 367 } // namespace printing |
| OLD | NEW |