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/location.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" |
10 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
11 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/printing/print_job_worker.h" | 16 #include "chrome/browser/printing/print_job_worker.h" |
14 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
16 #include "printing/printed_document.h" | 19 #include "printing/printed_document.h" |
17 #include "printing/printed_page.h" | 20 #include "printing/printed_page.h" |
18 | 21 |
19 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 content::Source<PrintJob>(this), | 190 content::Source<PrintJob>(this), |
188 content::Details<JobEventDetails>(details.get())); | 191 content::Details<JobEventDetails>(details.get())); |
189 Stop(); | 192 Stop(); |
190 is_canceling_ = false; | 193 is_canceling_ = false; |
191 } | 194 } |
192 | 195 |
193 bool PrintJob::FlushJob(base::TimeDelta timeout) { | 196 bool PrintJob::FlushJob(base::TimeDelta timeout) { |
194 // Make sure the object outlive this message loop. | 197 // Make sure the object outlive this message loop. |
195 scoped_refptr<PrintJob> handle(this); | 198 scoped_refptr<PrintJob> handle(this); |
196 | 199 |
197 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 200 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
198 base::Bind(&PrintJob::Quit, quit_factory_.GetWeakPtr()), timeout); | 201 FROM_HERE, base::Bind(&PrintJob::Quit, quit_factory_.GetWeakPtr()), |
| 202 timeout); |
199 | 203 |
200 base::MessageLoop::ScopedNestableTaskAllower allow( | 204 base::MessageLoop::ScopedNestableTaskAllower allow( |
201 base::MessageLoop::current()); | 205 base::MessageLoop::current()); |
202 base::MessageLoop::current()->Run(); | 206 base::MessageLoop::current()->Run(); |
203 | 207 |
204 return true; | 208 return true; |
205 } | 209 } |
206 | 210 |
207 void PrintJob::DisconnectSource() { | 211 void PrintJob::DisconnectSource() { |
208 source_ = NULL; | 212 source_ = NULL; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 357 } |
354 case JobEventDetails::NEW_DOC: | 358 case JobEventDetails::NEW_DOC: |
355 case JobEventDetails::NEW_PAGE: | 359 case JobEventDetails::NEW_PAGE: |
356 case JobEventDetails::JOB_DONE: | 360 case JobEventDetails::JOB_DONE: |
357 case JobEventDetails::ALL_PAGES_REQUESTED: { | 361 case JobEventDetails::ALL_PAGES_REQUESTED: { |
358 // Don't care. | 362 // Don't care. |
359 break; | 363 break; |
360 } | 364 } |
361 case JobEventDetails::DOC_DONE: { | 365 case JobEventDetails::DOC_DONE: { |
362 // This will call Stop() and broadcast a JOB_DONE message. | 366 // This will call Stop() and broadcast a JOB_DONE message. |
363 base::MessageLoop::current()->PostTask( | 367 base::ThreadTaskRunnerHandle::Get()->PostTask( |
364 FROM_HERE, base::Bind(&PrintJob::OnDocumentDone, this)); | 368 FROM_HERE, base::Bind(&PrintJob::OnDocumentDone, this)); |
365 break; | 369 break; |
366 } | 370 } |
367 case JobEventDetails::PAGE_DONE: | 371 case JobEventDetails::PAGE_DONE: |
368 #if defined(OS_WIN) | 372 #if defined(OS_WIN) |
369 ptd_to_emf_state_->OnPageProcessed( | 373 ptd_to_emf_state_->OnPageProcessed( |
370 base::Bind(&PrintJob::OnPdfToEmfPageConverted, this)); | 374 base::Bind(&PrintJob::OnPdfToEmfPageConverted, this)); |
371 #endif // OS_WIN | 375 #endif // OS_WIN |
372 break; | 376 break; |
373 default: { | 377 default: { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 } | 456 } |
453 | 457 |
454 JobEventDetails::~JobEventDetails() { | 458 JobEventDetails::~JobEventDetails() { |
455 } | 459 } |
456 | 460 |
457 PrintedDocument* JobEventDetails::document() const { return document_.get(); } | 461 PrintedDocument* JobEventDetails::document() const { return document_.get(); } |
458 | 462 |
459 PrintedPage* JobEventDetails::page() const { return page_.get(); } | 463 PrintedPage* JobEventDetails::page() const { return page_.get(); } |
460 | 464 |
461 } // namespace printing | 465 } // namespace printing |
OLD | NEW |