OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/printing/print_job_worker.h" | 5 #include "chrome/browser/printing/print_job_worker.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/printing/print_job.h" | 10 #include "chrome/browser/printing/print_job.h" |
11 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
12 #include "content/browser/browser_thread.h" | 12 #include "content/browser/browser_thread.h" |
13 #include "content/common/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
14 #include "printing/print_job_constants.h" | 14 #include "printing/print_job_constants.h" |
15 #include "printing/printed_document.h" | 15 #include "printing/printed_document.h" |
16 #include "printing/printed_page.h" | 16 #include "printing/printed_page.h" |
17 | 17 |
18 namespace printing { | 18 namespace printing { |
19 | 19 |
20 class PrintJobWorker::NotificationTask : public Task { | 20 class PrintJobWorker::NotificationTask : public Task { |
21 public: | 21 public: |
22 NotificationTask() : print_job_(NULL), details_(NULL) { | 22 NotificationTask() : print_job_(NULL), details_(NULL) { |
23 } | 23 } |
24 ~NotificationTask() { | 24 ~NotificationTask() { |
25 } | 25 } |
26 | 26 |
27 // Initializes the object. This object can't be initialized in the constructor | 27 // Initializes the object. This object can't be initialized in the constructor |
28 // since it is not created directly. | 28 // since it is not created directly. |
29 void Init(PrintJobWorkerOwner* print_job, | 29 void Init(PrintJobWorkerOwner* print_job, |
30 JobEventDetails::Type detail_type, | 30 JobEventDetails::Type detail_type, |
31 PrintedDocument* document, | 31 PrintedDocument* document, |
32 PrintedPage* page) { | 32 PrintedPage* page) { |
33 DCHECK(!print_job_); | 33 DCHECK(!print_job_); |
34 DCHECK(!details_); | 34 DCHECK(!details_); |
35 print_job_ = print_job; | 35 print_job_ = print_job; |
36 details_ = new JobEventDetails(detail_type, document, page); | 36 details_ = new JobEventDetails(detail_type, document, page); |
37 } | 37 } |
38 | 38 |
39 virtual void Run() { | 39 virtual void Run() { |
40 // Send the notification in the right thread. | 40 // Send the notification in the right thread. |
41 NotificationService::current()->Notify( | 41 content::NotificationService::current()->Notify( |
42 chrome::NOTIFICATION_PRINT_JOB_EVENT, | 42 chrome::NOTIFICATION_PRINT_JOB_EVENT, |
43 // We know that is is a PrintJob object in this circumstance. | 43 // We know that is is a PrintJob object in this circumstance. |
44 content::Source<PrintJob>(static_cast<PrintJob*>(print_job_.get())), | 44 content::Source<PrintJob>(static_cast<PrintJob*>(print_job_.get())), |
45 content::Details<JobEventDetails>(details_)); | 45 content::Details<JobEventDetails>(details_)); |
46 } | 46 } |
47 | 47 |
48 // The job which originates this notification. | 48 // The job which originates this notification. |
49 scoped_refptr<PrintJobWorkerOwner> print_job_; | 49 scoped_refptr<PrintJobWorkerOwner> print_job_; |
50 scoped_refptr<JobEventDetails> details_; | 50 scoped_refptr<JobEventDetails> details_; |
51 }; | 51 }; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 printing::PrintJobWorker* obj) { | 357 printing::PrintJobWorker* obj) { |
358 DCHECK(!owner_.get()); | 358 DCHECK(!owner_.get()); |
359 owner_ = obj->owner_; | 359 owner_ = obj->owner_; |
360 } | 360 } |
361 | 361 |
362 void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee( | 362 void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee( |
363 printing::PrintJobWorker* obj) { | 363 printing::PrintJobWorker* obj) { |
364 DCHECK_EQ(owner_, obj->owner_); | 364 DCHECK_EQ(owner_, obj->owner_); |
365 owner_ = NULL; | 365 owner_ = NULL; |
366 } | 366 } |
OLD | NEW |