10
10
#include " base/threading/thread_restrictions.h"
11
11
#include " base/threading/worker_pool.h"
12
12
#include " base/timer/timer.h"
13
+ #include " chrome/browser/chrome_notification_types.h"
14
+ #include " chrome/browser/printing/print_job_worker.h"
13
15
#include " content/public/browser/browser_thread.h"
14
- #include " content/nw/src/browser/printing/print_job_worker.h"
15
- #include " content/public/browser/notification_types.h"
16
16
#include " content/public/browser/notification_service.h"
17
17
#include " printing/printed_document.h"
18
18
#include " printing/printed_page.h"
19
19
20
20
using base::TimeDelta;
21
- using base::MessageLoop;
22
21
23
22
namespace {
24
23
@@ -33,7 +32,7 @@ void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner,
33
32
namespace printing {
34
33
35
34
PrintJob::PrintJob ()
36
- : ui_message_loop_(MessageLoop::current()),
35
+ : ui_message_loop_(base:: MessageLoop::current()),
37
36
source_ (NULL ),
38
37
worker_(),
39
38
settings_(),
@@ -43,8 +42,8 @@ PrintJob::PrintJob()
43
42
DCHECK (ui_message_loop_);
44
43
// This is normally a UI message loop, but in unit tests, the message loop is
45
44
// of the 'default' type.
46
- DCHECK (ui_message_loop_-> type () == MessageLoop::TYPE_UI ||
47
- ui_message_loop_->type () == MessageLoop::TYPE_DEFAULT);
45
+ DCHECK (base::MessageLoopForUI::IsCurrent () ||
46
+ ui_message_loop_->type () == base:: MessageLoop::TYPE_DEFAULT);
48
47
ui_message_loop_->AddDestructionObserver (this );
49
48
}
50
49
@@ -55,7 +54,7 @@ PrintJob::~PrintJob() {
55
54
DCHECK (!is_canceling_);
56
55
if (worker_.get ())
57
56
DCHECK (worker_->message_loop () == NULL );
58
- DCHECK_EQ (ui_message_loop_, MessageLoop::current ());
57
+ DCHECK_EQ (ui_message_loop_, base:: MessageLoop::current ());
59
58
}
60
59
61
60
void PrintJob::Initialize (PrintJobWorkerOwner* job,
@@ -71,22 +70,24 @@ void PrintJob::Initialize(PrintJobWorkerOwner* job,
71
70
settings_ = job->settings ();
72
71
73
72
PrintedDocument* new_doc =
74
- new PrintedDocument (settings_, source_, job->cookie (),
75
- content::BrowserThread::GetBlockingPool ());
73
+ new PrintedDocument (settings_,
74
+ source_,
75
+ job->cookie (),
76
+ content::BrowserThread::GetBlockingPool ());
76
77
new_doc->set_page_count (page_count);
77
78
UpdatePrintedDocument (new_doc);
78
79
79
80
// Don't forget to register to our own messages.
80
- registrar_.Add (this , content ::NOTIFICATION_PRINT_JOB_EVENT,
81
+ registrar_.Add (this , chrome ::NOTIFICATION_PRINT_JOB_EVENT,
81
82
content::Source<PrintJob>(this ));
82
83
}
83
84
84
85
void PrintJob::Observe (int type,
85
86
const content::NotificationSource& source,
86
87
const content::NotificationDetails& details) {
87
- DCHECK_EQ (ui_message_loop_, MessageLoop::current ());
88
+ DCHECK_EQ (ui_message_loop_, base:: MessageLoop::current ());
88
89
switch (type) {
89
- case content ::NOTIFICATION_PRINT_JOB_EVENT: {
90
+ case chrome ::NOTIFICATION_PRINT_JOB_EVENT: {
90
91
OnNotifyPrintJobEvent (*content::Details<JobEventDetails>(details).ptr ());
91
92
break ;
92
93
}
@@ -106,7 +107,7 @@ PrintJobWorker* PrintJob::DetachWorker(PrintJobWorkerOwner* new_owner) {
106
107
return NULL ;
107
108
}
108
109
109
- MessageLoop* PrintJob::message_loop () {
110
+ base:: MessageLoop* PrintJob::message_loop () {
110
111
return ui_message_loop_;
111
112
}
112
113
@@ -126,7 +127,7 @@ void PrintJob::WillDestroyCurrentMessageLoop() {
126
127
}
127
128
128
129
void PrintJob::StartPrinting () {
129
- DCHECK_EQ (ui_message_loop_, MessageLoop::current ());
130
+ DCHECK_EQ (ui_message_loop_, base:: MessageLoop::current ());
130
131
DCHECK (worker_->message_loop ());
131
132
DCHECK (!is_job_pending_);
132
133
if (!worker_->message_loop () || is_job_pending_)
@@ -145,13 +146,13 @@ void PrintJob::StartPrinting() {
145
146
scoped_refptr<JobEventDetails> details (
146
147
new JobEventDetails (JobEventDetails::NEW_DOC, document_.get (), NULL ));
147
148
content::NotificationService::current ()->Notify (
148
- content ::NOTIFICATION_PRINT_JOB_EVENT,
149
+ chrome ::NOTIFICATION_PRINT_JOB_EVENT,
149
150
content::Source<PrintJob>(this ),
150
151
content::Details<JobEventDetails>(details.get ()));
151
152
}
152
153
153
154
void PrintJob::Stop () {
154
- DCHECK_EQ (ui_message_loop_, MessageLoop::current ());
155
+ DCHECK_EQ (ui_message_loop_, base:: MessageLoop::current ());
155
156
156
157
if (quit_factory_.HasWeakPtrs ()) {
157
158
// In case we're running a nested message loop to wait for a job to finish,
@@ -179,8 +180,9 @@ void PrintJob::Cancel() {
179
180
// Be sure to live long enough.
180
181
scoped_refptr<PrintJob> handle (this );
181
182
182
- DCHECK_EQ (ui_message_loop_, MessageLoop::current ());
183
- MessageLoop* worker_loop = worker_.get () ? worker_->message_loop () : NULL ;
183
+ DCHECK_EQ (ui_message_loop_, base::MessageLoop::current ());
184
+ base::MessageLoop* worker_loop =
185
+ worker_.get () ? worker_->message_loop () : NULL ;
184
186
if (worker_loop) {
185
187
// Call this right now so it renders the context invalid. Do not use
186
188
// InvokeLater since it would take too much time.
@@ -190,7 +192,7 @@ void PrintJob::Cancel() {
190
192
scoped_refptr<JobEventDetails> details (
191
193
new JobEventDetails (JobEventDetails::FAILED, NULL , NULL ));
192
194
content::NotificationService::current ()->Notify (
193
- content ::NOTIFICATION_PRINT_JOB_EVENT,
195
+ chrome ::NOTIFICATION_PRINT_JOB_EVENT,
194
196
content::Source<PrintJob>(this ),
195
197
content::Details<JobEventDetails>(details.get ()));
196
198
Stop ();
@@ -201,11 +203,12 @@ bool PrintJob::FlushJob(base::TimeDelta timeout) {
201
203
// Make sure the object outlive this message loop.
202
204
scoped_refptr<PrintJob> handle (this );
203
205
204
- MessageLoop::current ()->PostDelayedTask (FROM_HERE,
206
+ base:: MessageLoop::current ()->PostDelayedTask (FROM_HERE,
205
207
base::Bind (&PrintJob::Quit, quit_factory_.GetWeakPtr ()), timeout);
206
208
207
- MessageLoop::ScopedNestableTaskAllower allow (MessageLoop::current ());
208
- MessageLoop::current ()->Run ();
209
+ base::MessageLoop::ScopedNestableTaskAllower allow (
210
+ base::MessageLoop::current ());
211
+ base::MessageLoop::current ()->Run ();
209
212
210
213
return true ;
211
214
}
@@ -269,7 +272,7 @@ void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) {
269
272
}
270
273
case JobEventDetails::DOC_DONE: {
271
274
// This will call Stop() and broadcast a JOB_DONE message.
272
- MessageLoop::current ()->PostTask (
275
+ base:: MessageLoop::current ()->PostTask (
273
276
FROM_HERE, base::Bind (&PrintJob::OnDocumentDone, this ));
274
277
break ;
275
278
}
@@ -291,13 +294,13 @@ void PrintJob::OnDocumentDone() {
291
294
scoped_refptr<JobEventDetails> details (
292
295
new JobEventDetails (JobEventDetails::JOB_DONE, document_.get (), NULL ));
293
296
content::NotificationService::current ()->Notify (
294
- content ::NOTIFICATION_PRINT_JOB_EVENT,
297
+ chrome ::NOTIFICATION_PRINT_JOB_EVENT,
295
298
content::Source<PrintJob>(this ),
296
299
content::Details<JobEventDetails>(details.get ()));
297
300
}
298
301
299
302
void PrintJob::ControlledWorkerShutdown () {
300
- DCHECK_EQ (ui_message_loop_, MessageLoop::current ());
303
+ DCHECK_EQ (ui_message_loop_, base:: MessageLoop::current ());
301
304
302
305
// The deadlock this code works around is specific to window messaging on
303
306
// Windows, so we aren't likely to need it on any other platforms.
@@ -342,7 +345,7 @@ void PrintJob::HoldUntilStopIsCalled() {
342
345
}
343
346
344
347
void PrintJob::Quit () {
345
- MessageLoop::current ()->Quit ();
348
+ base:: MessageLoop::current ()->Quit ();
346
349
}
347
350
348
351
// Takes settings_ ownership and will be deleted in the receiving thread.
0 commit comments