OLD | NEW |
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 #include "chrome/browser/printing/print_job_worker.h" | 5 #include "chrome/browser/printing/print_job_worker.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/printing/print_job.h" | 15 #include "chrome/browser/printing/print_job.h" |
16 #include "chrome/browser/printing/printing_ui_web_contents_observer.h" | 16 #include "chrome/browser/printing/printing_ui_web_contents_observer.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
20 #include "printing/print_job_constants.h" | 20 #include "printing/print_job_constants.h" |
21 #include "printing/printed_document.h" | 21 #include "printing/printed_document.h" |
22 #include "printing/printed_page.h" | 22 #include "printing/printed_page.h" |
23 #include "printing/printing_utils.h" | 23 #include "printing/printing_utils.h" |
24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
25 | 25 |
26 using content::BrowserThread; | 26 using content::BrowserThread; |
27 | 27 |
| 28 namespace printing { |
| 29 |
28 namespace { | 30 namespace { |
29 | 31 |
30 // Helper function to ensure |owner| is valid until at least |callback| returns. | 32 // Helper function to ensure |owner| is valid until at least |callback| returns. |
31 void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner, | 33 void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner, |
32 const base::Closure& callback) { | 34 const base::Closure& callback) { |
33 callback.Run(); | 35 callback.Run(); |
34 } | 36 } |
35 | 37 |
36 } // namespace | 38 } // namespace |
37 | 39 |
38 namespace printing { | |
39 | |
40 void NotificationCallback(PrintJobWorkerOwner* print_job, | 40 void NotificationCallback(PrintJobWorkerOwner* print_job, |
41 JobEventDetails::Type detail_type, | 41 JobEventDetails::Type detail_type, |
42 PrintedDocument* document, | 42 PrintedDocument* document, |
43 PrintedPage* page) { | 43 PrintedPage* page) { |
44 JobEventDetails* details = new JobEventDetails(detail_type, document, page); | 44 JobEventDetails* details = new JobEventDetails(detail_type, document, page); |
45 content::NotificationService::current()->Notify( | 45 content::NotificationService::current()->Notify( |
46 chrome::NOTIFICATION_PRINT_JOB_EVENT, | 46 chrome::NOTIFICATION_PRINT_JOB_EVENT, |
47 // We know that is is a PrintJob object in this circumstance. | 47 // We know that is is a PrintJob object in this circumstance. |
48 content::Source<PrintJob>(static_cast<PrintJob*>(print_job)), | 48 content::Source<PrintJob>(static_cast<PrintJob*>(print_job)), |
49 content::Details<JobEventDetails>(details)); | 49 content::Details<JobEventDetails>(details)); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 document_, | 391 document_, |
392 scoped_refptr<PrintedPage>())); | 392 scoped_refptr<PrintedPage>())); |
393 Cancel(); | 393 Cancel(); |
394 | 394 |
395 // Makes sure the variables are reinitialized. | 395 // Makes sure the variables are reinitialized. |
396 document_ = NULL; | 396 document_ = NULL; |
397 page_number_ = PageNumber::npos(); | 397 page_number_ = PageNumber::npos(); |
398 } | 398 } |
399 | 399 |
400 } // namespace printing | 400 } // namespace printing |
OLD | NEW |