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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 months 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
OLDNEW
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 #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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 16 matching lines...) Expand all
27 class PrinterQuery; 27 class PrinterQuery;
28 28
29 // 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
30 // PrintingContext though PrintJob::Worker. Hides access to PrintingContext in a 30 // PrintingContext though PrintJob::Worker. Hides access to PrintingContext in a
31 // 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
32 // any state change. While printing, the PrintJobManager instance keeps a 32 // any state change. While printing, the PrintJobManager instance keeps a
33 // 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
34 // runs in the UI thread. 34 // runs in the UI thread.
35 class PrintJob : public PrintJobWorkerOwner, 35 class PrintJob : public PrintJobWorkerOwner,
36 public content::NotificationObserver, 36 public content::NotificationObserver,
37 public MessageLoop::DestructionObserver { 37 public base::MessageLoop::DestructionObserver {
38 public: 38 public:
39 // Create a empty PrintJob. When initializing with this constructor, 39 // Create a empty PrintJob. When initializing with this constructor,
40 // post-constructor initialization must be done with Initialize(). 40 // post-constructor initialization must be done with Initialize().
41 PrintJob(); 41 PrintJob();
42 42
43 // Grabs the ownership of the PrintJobWorker from another job, which is 43 // Grabs the ownership of the PrintJobWorker from another job, which is
44 // usually a PrinterQuery. Set the expected page count of the print job. 44 // usually a PrinterQuery. Set the expected page count of the print job.
45 void Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source, 45 void Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source,
46 int page_count); 46 int page_count);
47 47
48 // content::NotificationObserver implementation. 48 // content::NotificationObserver implementation.
49 virtual void Observe(int type, 49 virtual void Observe(int type,
50 const content::NotificationSource& source, 50 const content::NotificationSource& source,
51 const content::NotificationDetails& details) OVERRIDE; 51 const content::NotificationDetails& details) OVERRIDE;
52 52
53 // PrintJobWorkerOwner implementation. 53 // PrintJobWorkerOwner implementation.
54 virtual void GetSettingsDone(const PrintSettings& new_settings, 54 virtual void GetSettingsDone(const PrintSettings& new_settings,
55 PrintingContext::Result result) OVERRIDE; 55 PrintingContext::Result result) OVERRIDE;
56 virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) OVERRIDE; 56 virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) OVERRIDE;
57 virtual MessageLoop* message_loop() OVERRIDE; 57 virtual base::MessageLoop* message_loop() OVERRIDE;
58 virtual const PrintSettings& settings() const OVERRIDE; 58 virtual const PrintSettings& settings() const OVERRIDE;
59 virtual int cookie() const OVERRIDE; 59 virtual int cookie() const OVERRIDE;
60 60
61 // DestructionObserver implementation. 61 // DestructionObserver implementation.
62 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; 62 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
63 63
64 // Starts the actual printing. Signals the worker that it should begin to 64 // Starts the actual printing. Signals the worker that it should begin to
65 // spool as soon as data is available. 65 // spool as soon as data is available.
66 void StartPrinting(); 66 void StartPrinting();
67 67
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 // Called at shutdown when running a nested message loop. 118 // Called at shutdown when running a nested message loop.
119 void Quit(); 119 void Quit();
120 120
121 void HoldUntilStopIsCalled(const scoped_refptr<PrintJob>& job); 121 void HoldUntilStopIsCalled(const scoped_refptr<PrintJob>& job);
122 122
123 content::NotificationRegistrar registrar_; 123 content::NotificationRegistrar registrar_;
124 124
125 // Main message loop reference. Used to send notifications in the right 125 // Main message loop reference. Used to send notifications in the right
126 // thread. 126 // thread.
127 MessageLoop* const ui_message_loop_; 127 base::MessageLoop* const ui_message_loop_;
128 128
129 // Source that generates the PrintedPage's (i.e. a WebContents). It will be 129 // Source that generates the PrintedPage's (i.e. a WebContents). It will be
130 // set back to NULL if the source is deleted before this object. 130 // set back to NULL if the source is deleted before this object.
131 PrintedPagesSource* source_; 131 PrintedPagesSource* source_;
132 132
133 // All the UI is done in a worker thread because many Win32 print functions 133 // All the UI is done in a worker thread because many Win32 print functions
134 // are blocking and enters a message loop without your consent. There is one 134 // are blocking and enters a message loop without your consent. There is one
135 // worker thread per print job. 135 // worker thread per print job.
136 scoped_ptr<PrintJobWorker> worker_; 136 scoped_ptr<PrintJobWorker> worker_;
137 137
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 scoped_refptr<PrintedDocument> document_; 217 scoped_refptr<PrintedDocument> document_;
218 scoped_refptr<PrintedPage> page_; 218 scoped_refptr<PrintedPage> page_;
219 const Type type_; 219 const Type type_;
220 220
221 DISALLOW_COPY_AND_ASSIGN(JobEventDetails); 221 DISALLOW_COPY_AND_ASSIGN(JobEventDetails);
222 }; 222 };
223 223
224 } // namespace printing 224 } // namespace printing
225 225
226 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_ 226 #endif // CHROME_BROWSER_PRINTING_PRINT_JOB_H_
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_dialog_cloud_unittest.cc ('k') | chrome/browser/printing/print_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698