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/print_job_worker.h" | 5 #include "chrome/browser/printing/print_job_worker.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/printing/print_job.h" | 10 #include "chrome/browser/printing/print_job.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 scoped_refptr<JobEventDetails> details_; | 50 scoped_refptr<JobEventDetails> details_; |
51 }; | 51 }; |
52 | 52 |
53 | 53 |
54 PrintJobWorker::PrintJobWorker(PrintJobWorkerOwner* owner) | 54 PrintJobWorker::PrintJobWorker(PrintJobWorkerOwner* owner) |
55 : Thread("Printing_Worker"), | 55 : Thread("Printing_Worker"), |
56 owner_(owner) { | 56 owner_(owner) { |
57 // The object is created in the IO thread. | 57 // The object is created in the IO thread. |
58 DCHECK_EQ(owner_->message_loop(), MessageLoop::current()); | 58 DCHECK_EQ(owner_->message_loop(), MessageLoop::current()); |
59 | 59 |
60 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | |
61 // TODO(saintlou): Our goal is to have Aura for ChromeOS. So the | |
62 // printing USE_AURA && !OS_CHROMEOS is not a use case for shipping. | |
63 NOTIMPLEMENTED(); | |
kmadhusu
2011/10/05 22:44:52
Is there any specific reason for adding this check
| |
64 #else | |
60 printing_context_.reset(PrintingContext::Create( | 65 printing_context_.reset(PrintingContext::Create( |
61 g_browser_process->GetApplicationLocale())); | 66 g_browser_process->GetApplicationLocale())); |
67 #endif | |
62 } | 68 } |
63 | 69 |
64 PrintJobWorker::~PrintJobWorker() { | 70 PrintJobWorker::~PrintJobWorker() { |
65 // The object is normally deleted in the UI thread, but when the user | 71 // The object is normally deleted in the UI thread, but when the user |
66 // cancels printing or in the case of print preview, the worker is destroyed | 72 // cancels printing or in the case of print preview, the worker is destroyed |
67 // on the I/O thread. | 73 // on the I/O thread. |
68 DCHECK_EQ(owner_->message_loop(), MessageLoop::current()); | 74 DCHECK_EQ(owner_->message_loop(), MessageLoop::current()); |
69 } | 75 } |
70 | 76 |
71 void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) { | 77 void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 &page); | 310 &page); |
305 owner_->message_loop()->PostTask(FROM_HERE, task); | 311 owner_->message_loop()->PostTask(FROM_HERE, task); |
306 | 312 |
307 // Preprocess. | 313 // Preprocess. |
308 if (printing_context_->NewPage() != PrintingContext::OK) { | 314 if (printing_context_->NewPage() != PrintingContext::OK) { |
309 OnFailure(); | 315 OnFailure(); |
310 return; | 316 return; |
311 } | 317 } |
312 | 318 |
313 // Actual printing. | 319 // Actual printing. |
314 #if defined(OS_WIN) || defined(OS_MACOSX) | 320 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
321 // TODO(saintlou): Our goal is to have Aura for ChromeOS. So the | |
322 // printing USE_AURA && !OS_CHROMEOS is not a use case for shipping. | |
323 NOTIMPLEMENTED(); | |
324 #elif defined(OS_WIN) || defined(OS_MACOSX) | |
315 document_->RenderPrintedPage(page, printing_context_->context()); | 325 document_->RenderPrintedPage(page, printing_context_->context()); |
316 #elif defined(OS_POSIX) | 326 #elif defined(OS_POSIX) |
317 document_->RenderPrintedPage(page, printing_context_.get()); | 327 document_->RenderPrintedPage(page, printing_context_.get()); |
318 #endif | 328 #endif |
319 | 329 |
320 // Postprocess. | 330 // Postprocess. |
321 if (printing_context_->PageDone() != PrintingContext::OK) { | 331 if (printing_context_->PageDone() != PrintingContext::OK) { |
322 OnFailure(); | 332 OnFailure(); |
323 return; | 333 return; |
324 } | 334 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 printing::PrintJobWorker* obj) { | 367 printing::PrintJobWorker* obj) { |
358 DCHECK(!owner_.get()); | 368 DCHECK(!owner_.get()); |
359 owner_ = obj->owner_; | 369 owner_ = obj->owner_; |
360 } | 370 } |
361 | 371 |
362 void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee( | 372 void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee( |
363 printing::PrintJobWorker* obj) { | 373 printing::PrintJobWorker* obj) { |
364 DCHECK_EQ(owner_, obj->owner_); | 374 DCHECK_EQ(owner_, obj->owner_); |
365 owner_ = NULL; | 375 owner_ = NULL; |
366 } | 376 } |
OLD | NEW |