Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: chrome/browser/printing/print_job.h

Issue 11534: Add superficial unit test for PrintJob. That's a start.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/thread_unittest.cc ('k') | chrome/browser/printing/print_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop.h"
8 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
9 #include "chrome/browser/printing/print_job_worker_owner.h" 10 #include "chrome/browser/printing/print_job_worker_owner.h"
10 #include "chrome/common/notification_service.h" 11 #include "chrome/common/notification_service.h"
11 12
12 class ChromeFont; 13 class ChromeFont;
13 class GURL; 14 class GURL;
14 class Thread; 15 class Thread;
15 16
16 namespace printing { 17 namespace printing {
17 18
18 // See definition below. 19 // See definition below.
19 class JobEventDetails; 20 class JobEventDetails;
20 21
21 class PrintedDocument; 22 class PrintedDocument;
22 class PrintedPage; 23 class PrintedPage;
23 class PrintedPagesSource; 24 class PrintedPagesSource;
24 class PrintJobWorker; 25 class PrintJobWorker;
25 class PrinterQuery; 26 class PrinterQuery;
26 27
27 // Manages the print work for a specific document. Talks to the printer through 28 // Manages the print work for a specific document. Talks to the printer through
28 // PrintingContext though PrintJob::Worker. Hides access to PrintingContext in a 29 // PrintingContext though PrintJob::Worker. Hides access to PrintingContext in a
29 // worker thread so the caller never blocks. PrintJob will send notifications on 30 // worker thread so the caller never blocks. PrintJob will send notifications on
30 // any state change. While printing, the PrintJobManager instance keeps a 31 // any state change. While printing, the PrintJobManager instance keeps a
31 // reference to the job to be sure it is kept alive. All the code in this class 32 // reference to the job to be sure it is kept alive. All the code in this class
32 // runs in the UI thread. 33 // runs in the UI thread.
33 class PrintJob : public base::RefCountedThreadSafe<PrintJob>, 34 class PrintJob : public base::RefCountedThreadSafe<PrintJob>,
34 public NotificationObserver, 35 public NotificationObserver,
35 public PrintJobWorkerOwner { 36 public PrintJobWorkerOwner,
37 public MessageLoop::DestructionObserver {
36 public: 38 public:
37 // GetSettings() UI parameter. 39 // GetSettings() UI parameter.
38 enum GetSettingsAskParam { 40 enum GetSettingsAskParam {
39 DEFAULTS, 41 DEFAULTS,
40 ASK_USER, 42 ASK_USER,
41 }; 43 };
42 44
43 // Create a standalone PrintJob. When initializing with this constructor, 45 // Create a standalone PrintJob. When initializing with this constructor,
44 // Initialize() must not be called. 46 // Initialize() must not be called.
45 PrintJob(PrintedPagesSource* source); 47 PrintJob(PrintedPagesSource* source);
46 // Create a empty PrintJob. When initializing with this constructor, 48 // Create a empty PrintJob. When initializing with this constructor,
47 // post-constructor initialization must be done with Initialize(). 49 // post-constructor initialization must be done with Initialize().
48 PrintJob(); 50 PrintJob();
49 virtual ~PrintJob(); 51 virtual ~PrintJob();
50 52
53 // Grabs the ownership of the PrintJobWorker from another job, which is
54 // usually a PrinterQuery.
51 void Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source); 55 void Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source);
52 56
53 // NotificationObserver 57 // NotificationObserver
54 virtual void Observe(NotificationType type, 58 virtual void Observe(NotificationType type,
55 const NotificationSource& source, 59 const NotificationSource& source,
56 const NotificationDetails& details); 60 const NotificationDetails& details);
57 61
58 // PrintJobWorkerOwner 62 // PrintJobWorkerOwner
59 virtual void AddRef() { 63 virtual void AddRef() {
60 return base::RefCountedThreadSafe<PrintJob>::AddRef(); 64 return base::RefCountedThreadSafe<PrintJob>::AddRef();
61 } 65 }
62 virtual void Release() { 66 virtual void Release() {
63 return base::RefCountedThreadSafe<PrintJob>::Release(); 67 return base::RefCountedThreadSafe<PrintJob>::Release();
64 } 68 }
65 virtual void GetSettingsDone(const PrintSettings& new_settings, 69 virtual void GetSettingsDone(const PrintSettings& new_settings,
66 PrintingContext::Result result); 70 PrintingContext::Result result);
67 virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner); 71 virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner);
68 virtual MessageLoop* message_loop() { return ui_message_loop_; } 72 virtual MessageLoop* message_loop() { return ui_message_loop_; }
69 virtual const PrintSettings& settings() const { return settings_; } 73 virtual const PrintSettings& settings() const { return settings_; }
70 virtual int cookie() const; 74 virtual int cookie() const;
71 75
76 // DestructionObserver
77 virtual void WillDestroyCurrentMessageLoop();
78
72 // Initializes the printing context. This can be done synchronously or not. It 79 // Initializes the printing context. This can be done synchronously or not. It
73 // is fine to call this function multiple times to reinitialize the settings. 80 // is fine to call this function multiple times to reinitialize the settings.
74 // |parent_window| parameter will be the owner of the print setting dialog 81 // |parent_window| parameter will be the owner of the print setting dialog
75 // box. It is unused when |ask_for_user_settings| is DEFAULTS. No-op if a 82 // box. It is unused when |ask_for_user_settings| is DEFAULTS. No-op if a
76 // print job is active. 83 // print job is active.
77 void GetSettings(GetSettingsAskParam ask_user_for_settings, 84 void GetSettings(GetSettingsAskParam ask_user_for_settings,
78 HWND parent_window); 85 HWND parent_window);
79 86
80 // Starts the actual printing. Signals the worker that it should begin to 87 // Starts the actual printing. Signals the worker that it should begin to
81 // spool as soon as data is available. 88 // spool as soon as data is available.
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 scoped_refptr<PrintedPage> page_; 224 scoped_refptr<PrintedPage> page_;
218 const Type type_; 225 const Type type_;
219 226
220 DISALLOW_COPY_AND_ASSIGN(JobEventDetails); 227 DISALLOW_COPY_AND_ASSIGN(JobEventDetails);
221 }; 228 };
222 229
223 } // namespace printing 230 } // namespace printing
224 231
225 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_ 232 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_
226 233
OLDNEW
« no previous file with comments | « base/thread_unittest.cc ('k') | chrome/browser/printing/print_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698