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

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

Issue 276004: Wire up printing on the Mac (Closed)
Patch Set: Created 11 years, 2 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
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/printer_query.h" 5 #include "chrome/browser/printing/printer_query.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "chrome/browser/printing/print_job_worker.h" 8 #include "chrome/browser/printing/print_job_worker.h"
9 9
10 #ifdef _MSC_VER 10 #ifdef _MSC_VER
11 #pragma warning(disable:4355) // 'this' : used in base member initializer list 11 #pragma warning(disable:4355) // 'this' : used in base member initializer list
12 #endif 12 #endif
13 13
14 namespace printing { 14 namespace printing {
15 15
16 PrinterQuery::PrinterQuery() 16 PrinterQuery::PrinterQuery()
17 : ui_message_loop_(MessageLoop::current()), 17 : ui_message_loop_(MessageLoop::current()),
18 worker_(new PrintJobWorker(this)), 18 worker_(new PrintJobWorker(this)),
19 is_print_dialog_box_shown_(false), 19 is_print_dialog_box_shown_(false),
20 last_status_(PrintingContext::FAILED), 20 cookie_(PrintSettings::NewCookie()),
21 cookie_(PrintSettings::NewCookie()) { 21 last_status_(PrintingContext::FAILED) {
22 } 22 }
23 23
24 PrinterQuery::~PrinterQuery() { 24 PrinterQuery::~PrinterQuery() {
25 // The job should be finished (or at least canceled) when it is destroyed. 25 // The job should be finished (or at least canceled) when it is destroyed.
26 DCHECK(!is_print_dialog_box_shown_); 26 DCHECK(!is_print_dialog_box_shown_);
27 // If this fires, it is that this pending printer context has leaked. 27 // If this fires, it is that this pending printer context has leaked.
28 DCHECK(!worker_.get()); 28 DCHECK(!worker_.get());
29 if (callback_.get()) { 29 if (callback_.get()) {
30 // Be sure to cancel it. 30 // Be sure to cancel it.
31 callback_->Cancel(); 31 callback_->Cancel();
(...skipping 23 matching lines...) Expand all
55 PrintJobWorker* PrinterQuery::DetachWorker(PrintJobWorkerOwner* new_owner) { 55 PrintJobWorker* PrinterQuery::DetachWorker(PrintJobWorkerOwner* new_owner) {
56 DCHECK(!callback_.get()); 56 DCHECK(!callback_.get());
57 DCHECK(worker_.get()); 57 DCHECK(worker_.get());
58 if (!worker_.get()) 58 if (!worker_.get())
59 return NULL; 59 return NULL;
60 worker_->SetNewOwner(new_owner); 60 worker_->SetNewOwner(new_owner);
61 return worker_.release(); 61 return worker_.release();
62 } 62 }
63 63
64 void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings, 64 void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings,
65 HWND parent_window, 65 gfx::NativeWindow parent_window,
66 int expected_page_count, 66 int expected_page_count,
67 bool has_selection, 67 bool has_selection,
68 CancelableTask* callback) { 68 CancelableTask* callback) {
69 DCHECK_EQ(ui_message_loop_, MessageLoop::current()); 69 DCHECK_EQ(ui_message_loop_, MessageLoop::current());
70 DCHECK(!is_print_dialog_box_shown_); 70 DCHECK(!is_print_dialog_box_shown_);
71 DCHECK(!callback_.get()); 71 DCHECK(!callback_.get());
72 DCHECK(worker_.get()); 72 DCHECK(worker_.get());
73 if (!worker_.get()) 73 if (!worker_.get())
74 return; 74 return;
75 // Lazy create the worker thread. There is one worker thread per print job. 75 // Lazy create the worker thread. There is one worker thread per print job.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 bool PrinterQuery::is_callback_pending() const { 110 bool PrinterQuery::is_callback_pending() const {
111 return callback_.get() != NULL; 111 return callback_.get() != NULL;
112 } 112 }
113 113
114 bool PrinterQuery::is_valid() const { 114 bool PrinterQuery::is_valid() const {
115 return worker_.get() != NULL; 115 return worker_.get() != NULL;
116 } 116 }
117 117
118 } // namespace printing 118 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698