| 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_WORKER_H__ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ |
| 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ | 6 #define CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ |
| 7 | 7 |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "base/thread.h" | 9 #include "base/thread.h" |
| 10 #include "chrome/browser/printing/page_number.h" | 10 #include "chrome/browser/printing/page_number.h" |
| 11 #include "chrome/browser/printing/win_printing_context.h" | 11 #include "chrome/browser/printing/win_printing_context.h" |
| 12 | 12 |
| 13 namespace printing { | 13 namespace printing { |
| 14 | 14 |
| 15 class PrintedDocument; | 15 class PrintedDocument; |
| 16 class PrintedPage; | 16 class PrintedPage; |
| 17 class PrintJob; | 17 class PrintJob; |
| 18 class PrintJobWorkerOwner; | 18 class PrintJobWorkerOwner; |
| 19 | 19 |
| 20 // Worker thread code. All this code, except for the constructor, is executed in | 20 // Worker thread code. All this code, except for the constructor, is executed in |
| 21 // the worker thread. It manages the PrintingContext, which can be blocking | 21 // the worker thread. It manages the PrintingContext, which can be blocking |
| 22 // and/or run a message loop. This is the object that generates most | 22 // and/or run a message loop. This is the object that generates most |
| 23 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a | 23 // NOTIFY_PRINT_JOB_EVENT notifications, but they are generated through a |
| 24 // NotificationTask task to be executed from the right thread, the UI thread. | 24 // NotificationTask task to be executed from the right thread, the UI thread. |
| 25 // PrintJob always outlives its worker instance. | 25 // PrintJob always outlives its worker instance. |
| 26 class PrintJobWorker : public base::Thread { | 26 class PrintJobWorker : public base::Thread { |
| 27 public: | 27 public: |
| 28 PrintJobWorker(PrintJobWorkerOwner* owner); | 28 explicit PrintJobWorker(PrintJobWorkerOwner* owner); |
| 29 ~PrintJobWorker(); | 29 ~PrintJobWorker(); |
| 30 | 30 |
| 31 void SetNewOwner(PrintJobWorkerOwner* new_owner); | 31 void SetNewOwner(PrintJobWorkerOwner* new_owner); |
| 32 | 32 |
| 33 // Initializes the print settings. If |ask_user_for_settings| is true, a | 33 // Initializes the print settings. If |ask_user_for_settings| is true, a |
| 34 // Print... dialog box will be shown to ask the user his preference. | 34 // Print... dialog box will be shown to ask the user his preference. |
| 35 void GetSettings(bool ask_user_for_settings, | 35 void GetSettings(bool ask_user_for_settings, |
| 36 HWND parent_window, | 36 HWND parent_window, |
| 37 int document_page_count); | 37 int document_page_count); |
| 38 | 38 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 51 // This is the only function that can be called in a thread. | 51 // This is the only function that can be called in a thread. |
| 52 void Cancel(); | 52 void Cancel(); |
| 53 | 53 |
| 54 // Cancels the Print... dialog box if shown, noop otherwise. | 54 // Cancels the Print... dialog box if shown, noop otherwise. |
| 55 void DismissDialog(); | 55 void DismissDialog(); |
| 56 | 56 |
| 57 // Requests the missing pages in rendered_document_. Sends back a | 57 // Requests the missing pages in rendered_document_. Sends back a |
| 58 // ALL_PAGES_REQUESTED notification once done. | 58 // ALL_PAGES_REQUESTED notification once done. |
| 59 void RequestMissingPages(); | 59 void RequestMissingPages(); |
| 60 | 60 |
| 61 protected: |
| 62 // Retrieves the context for testing only. |
| 63 PrintingContext& printing_context() { return printing_context_; } |
| 64 |
| 61 private: | 65 private: |
| 62 // The shared NotificationService service can only be accessed from the UI | 66 // The shared NotificationService service can only be accessed from the UI |
| 63 // thread, so this class encloses the necessary information to send the | 67 // thread, so this class encloses the necessary information to send the |
| 64 // notification from the right thread. Most NOTIFY_PRINT_JOB_EVENT | 68 // notification from the right thread. Most NOTIFY_PRINT_JOB_EVENT |
| 65 // notifications are sent this way, except USER_INIT_DONE, USER_INIT_CANCELED | 69 // notifications are sent this way, except USER_INIT_DONE, USER_INIT_CANCELED |
| 66 // and DEFAULT_INIT_DONE. These three are sent through PrintJob::InitDone(). | 70 // and DEFAULT_INIT_DONE. These three are sent through PrintJob::InitDone(). |
| 67 class NotificationTask; | 71 class NotificationTask; |
| 68 friend struct RunnableMethodTraits<PrintJobWorker>; | 72 friend struct RunnableMethodTraits<PrintJobWorker>; |
| 69 | 73 |
| 70 // Renders a page in the printer. | 74 // Renders a page in the printer. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 99 struct RunnableMethodTraits<printing::PrintJobWorker> { | 103 struct RunnableMethodTraits<printing::PrintJobWorker> { |
| 100 RunnableMethodTraits(); | 104 RunnableMethodTraits(); |
| 101 void RetainCallee(printing::PrintJobWorker* obj); | 105 void RetainCallee(printing::PrintJobWorker* obj); |
| 102 void ReleaseCallee(printing::PrintJobWorker* obj); | 106 void ReleaseCallee(printing::PrintJobWorker* obj); |
| 103 private: | 107 private: |
| 104 scoped_refptr<printing::PrintJobWorkerOwner> owner_; | 108 scoped_refptr<printing::PrintJobWorkerOwner> owner_; |
| 105 }; | 109 }; |
| 106 | 110 |
| 107 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ | 111 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__ |
| 108 | 112 |
| OLD | NEW |