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

Side by Side Diff: chrome/browser/printing/print_job_manager.cc

Issue 1104043002: favor DCHECK_CURRENTLY_ON for better logs in chrome/browser/prerender/, prefetch and printing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding files Created 5 years, 8 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
« no previous file with comments | « chrome/browser/prerender/prerender_message_filter.cc ('k') | no next file » | 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) 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_manager.h" 5 #include "chrome/browser/printing/print_job_manager.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/printing/print_job.h" 8 #include "chrome/browser/printing/print_job.h"
9 #include "chrome/browser/printing/printer_query.h" 9 #include "chrome/browser/printing/printer_query.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 PrintJobManager::PrintJobManager() : is_shutdown_(false) { 70 PrintJobManager::PrintJobManager() : is_shutdown_(false) {
71 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, 71 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT,
72 content::NotificationService::AllSources()); 72 content::NotificationService::AllSources());
73 } 73 }
74 74
75 PrintJobManager::~PrintJobManager() { 75 PrintJobManager::~PrintJobManager() {
76 } 76 }
77 77
78 scoped_refptr<PrintQueriesQueue> PrintJobManager::queue() { 78 scoped_refptr<PrintQueriesQueue> PrintJobManager::queue() {
79 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 79 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
80 if (!queue_.get()) 80 if (!queue_.get())
81 queue_ = new PrintQueriesQueue(); 81 queue_ = new PrintQueriesQueue();
82 return queue_; 82 return queue_;
83 } 83 }
84 84
85 void PrintJobManager::Shutdown() { 85 void PrintJobManager::Shutdown() {
86 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 86 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
87 DCHECK(!is_shutdown_); 87 DCHECK(!is_shutdown_);
88 is_shutdown_ = true; 88 is_shutdown_ = true;
89 registrar_.RemoveAll(); 89 registrar_.RemoveAll();
90 StopJobs(true); 90 StopJobs(true);
91 if (queue_.get()) 91 if (queue_.get())
92 queue_->Shutdown(); 92 queue_->Shutdown();
93 queue_ = NULL; 93 queue_ = NULL;
94 } 94 }
95 95
96 void PrintJobManager::StopJobs(bool wait_for_finish) { 96 void PrintJobManager::StopJobs(bool wait_for_finish) {
97 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 97 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
98 // Copy the array since it can be modified in transit. 98 // Copy the array since it can be modified in transit.
99 PrintJobs to_stop; 99 PrintJobs to_stop;
100 to_stop.swap(current_jobs_); 100 to_stop.swap(current_jobs_);
101 101
102 for (PrintJobs::const_iterator job = to_stop.begin(); job != to_stop.end(); 102 for (PrintJobs::const_iterator job = to_stop.begin(); job != to_stop.end();
103 ++job) { 103 ++job) {
104 // Wait for two minutes for the print job to be spooled. 104 // Wait for two minutes for the print job to be spooled.
105 if (wait_for_finish) 105 if (wait_for_finish)
106 (*job)->FlushJob(base::TimeDelta::FromMinutes(2)); 106 (*job)->FlushJob(base::TimeDelta::FromMinutes(2));
107 (*job)->Stop(); 107 (*job)->Stop();
108 } 108 }
109 } 109 }
110 110
111 void PrintJobManager::Observe(int type, 111 void PrintJobManager::Observe(int type,
112 const content::NotificationSource& source, 112 const content::NotificationSource& source,
113 const content::NotificationDetails& details) { 113 const content::NotificationDetails& details) {
114 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 114 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
115 switch (type) { 115 switch (type) {
116 case chrome::NOTIFICATION_PRINT_JOB_EVENT: { 116 case chrome::NOTIFICATION_PRINT_JOB_EVENT: {
117 OnPrintJobEvent(content::Source<PrintJob>(source).ptr(), 117 OnPrintJobEvent(content::Source<PrintJob>(source).ptr(),
118 *content::Details<JobEventDetails>(details).ptr()); 118 *content::Details<JobEventDetails>(details).ptr());
119 break; 119 break;
120 } 120 }
121 default: { 121 default: {
122 NOTREACHED(); 122 NOTREACHED();
123 break; 123 break;
124 } 124 }
(...skipping 30 matching lines...) Expand all
155 break; 155 break;
156 } 156 }
157 default: { 157 default: {
158 NOTREACHED(); 158 NOTREACHED();
159 break; 159 break;
160 } 160 }
161 } 161 }
162 } 162 }
163 163
164 } // namespace printing 164 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_message_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698