| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_H_ |
| 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/gfx/native_widget_types.h" | 9 #include "base/gfx/native_widget_types.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/ref_counted.h" |
| 11 #include "chrome/browser/printing/print_job_worker_owner.h" | 12 #include "chrome/browser/printing/print_job_worker_owner.h" |
| 12 #include "chrome/common/notification_registrar.h" | 13 #include "chrome/common/notification_registrar.h" |
| 13 | 14 |
| 14 class GURL; | 15 class GURL; |
| 15 class Thread; | 16 class Thread; |
| 16 | 17 |
| 17 namespace printing { | 18 namespace printing { |
| 18 | 19 |
| 19 // See definition below. | 20 // See definition below. |
| 20 class JobEventDetails; | 21 class JobEventDetails; |
| 21 | 22 |
| 22 class PrintedDocument; | 23 class PrintedDocument; |
| 23 class PrintedPage; | 24 class PrintedPage; |
| 24 class PrintedPagesSource; | 25 class PrintedPagesSource; |
| 25 class PrintJobWorker; | 26 class PrintJobWorker; |
| 26 class PrinterQuery; | 27 class PrinterQuery; |
| 27 | 28 |
| 28 // Manages the print work for a specific document. Talks to the printer through | 29 // Manages the print work for a specific document. Talks to the printer through |
| 29 // PrintingContext though PrintJob::Worker. Hides access to PrintingContext in a | 30 // PrintingContext though PrintJob::Worker. Hides access to PrintingContext in a |
| 30 // worker thread so the caller never blocks. PrintJob will send notifications on | 31 // worker thread so the caller never blocks. PrintJob will send notifications on |
| 31 // any state change. While printing, the PrintJobManager instance keeps a | 32 // any state change. While printing, the PrintJobManager instance keeps a |
| 32 // reference to the job to be sure it is kept alive. All the code in this class | 33 // reference to the job to be sure it is kept alive. All the code in this class |
| 33 // runs in the UI thread. | 34 // runs in the UI thread. |
| 34 class PrintJob : public PrintJobWorkerOwner, | 35 class PrintJob : public base::RefCountedThreadSafe<PrintJob>, |
| 35 public NotificationObserver, | 36 public NotificationObserver, |
| 37 public PrintJobWorkerOwner, |
| 36 public MessageLoop::DestructionObserver { | 38 public MessageLoop::DestructionObserver { |
| 37 public: | 39 public: |
| 38 // Create a empty PrintJob. When initializing with this constructor, | 40 // Create a empty PrintJob. When initializing with this constructor, |
| 39 // post-constructor initialization must be done with Initialize(). | 41 // post-constructor initialization must be done with Initialize(). |
| 40 PrintJob(); | 42 PrintJob(); |
| 41 virtual ~PrintJob(); | 43 virtual ~PrintJob(); |
| 42 | 44 |
| 43 // Grabs the ownership of the PrintJobWorker from another job, which is | 45 // Grabs the ownership of the PrintJobWorker from another job, which is |
| 44 // usually a PrinterQuery. | 46 // usually a PrinterQuery. |
| 45 void Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source); | 47 void Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source); |
| 46 | 48 |
| 47 // NotificationObserver | 49 // NotificationObserver |
| 48 virtual void Observe(NotificationType type, | 50 virtual void Observe(NotificationType type, |
| 49 const NotificationSource& source, | 51 const NotificationSource& source, |
| 50 const NotificationDetails& details); | 52 const NotificationDetails& details); |
| 51 | 53 |
| 52 // PrintJobWorkerOwner | 54 // PrintJobWorkerOwner |
| 55 virtual void AddRef() { |
| 56 return base::RefCountedThreadSafe<PrintJob>::AddRef(); |
| 57 } |
| 58 virtual void Release() { |
| 59 return base::RefCountedThreadSafe<PrintJob>::Release(); |
| 60 } |
| 61 |
| 53 virtual void GetSettingsDone(const PrintSettings& new_settings, | 62 virtual void GetSettingsDone(const PrintSettings& new_settings, |
| 54 PrintingContext::Result result); | 63 PrintingContext::Result result); |
| 55 virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner); | 64 virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner); |
| 56 virtual MessageLoop* message_loop() { return ui_message_loop_; } | 65 virtual MessageLoop* message_loop() { return ui_message_loop_; } |
| 57 virtual const PrintSettings& settings() const { return settings_; } | 66 virtual const PrintSettings& settings() const { return settings_; } |
| 58 virtual int cookie() const; | 67 virtual int cookie() const; |
| 59 | 68 |
| 60 // DestructionObserver | 69 // DestructionObserver |
| 61 virtual void WillDestroyCurrentMessageLoop(); | 70 virtual void WillDestroyCurrentMessageLoop(); |
| 62 | 71 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 scoped_refptr<PrintedDocument> document_; | 203 scoped_refptr<PrintedDocument> document_; |
| 195 scoped_refptr<PrintedPage> page_; | 204 scoped_refptr<PrintedPage> page_; |
| 196 const Type type_; | 205 const Type type_; |
| 197 | 206 |
| 198 DISALLOW_COPY_AND_ASSIGN(JobEventDetails); | 207 DISALLOW_COPY_AND_ASSIGN(JobEventDetails); |
| 199 }; | 208 }; |
| 200 | 209 |
| 201 } // namespace printing | 210 } // namespace printing |
| 202 | 211 |
| 203 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_ | 212 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_ |
| OLD | NEW |