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

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

Issue 11534: Add superficial unit test for PrintJob. That's a start.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/printing/print_job.h ('k') | chrome/browser/printing/print_job_unittest.cc » ('j') | 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) 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/print_job.h" 5 #include "chrome/browser/printing/print_job.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 #include "chrome/browser/printing/printed_document.h" 9 #include "chrome/browser/printing/printed_document.h"
10 #include "chrome/browser/printing/printed_page.h" 10 #include "chrome/browser/printing/printed_page.h"
11 11
12 #ifdef _MSC_VER 12 #ifdef _MSC_VER
13 #pragma warning(disable:4355) // 'this' : used in base member initializer list 13 #pragma warning(disable:4355) // 'this' : used in base member initializer list
14 #endif 14 #endif
15 15
16 using base::TimeDelta; 16 using base::TimeDelta;
17 17
18 namespace printing { 18 namespace printing {
19 19
20 PrintJob::PrintJob(PrintedPagesSource* source) 20 PrintJob::PrintJob(PrintedPagesSource* source)
21 : ui_message_loop_(MessageLoop::current()), 21 : ui_message_loop_(MessageLoop::current()),
22 worker_(new PrintJobWorker(this)), 22 worker_(new PrintJobWorker(this)),
23 source_(source), 23 source_(source),
24 is_job_pending_(false), 24 is_job_pending_(false),
25 is_print_dialog_box_shown_(false), 25 is_print_dialog_box_shown_(false),
26 is_canceling_(false) { 26 is_canceling_(false) {
27 DCHECK(ui_message_loop_);
28 ui_message_loop_->AddDestructionObserver(this);
27 } 29 }
28 30
29 PrintJob::PrintJob() 31 PrintJob::PrintJob()
30 : ui_message_loop_(MessageLoop::current()), 32 : ui_message_loop_(MessageLoop::current()),
31 worker_(), 33 worker_(),
32 source_(NULL), 34 source_(NULL),
33 settings_(), 35 settings_(),
34 is_job_pending_(false), 36 is_job_pending_(false),
35 is_print_dialog_box_shown_(false), 37 is_print_dialog_box_shown_(false),
36 is_canceling_(false) { 38 is_canceling_(false) {
39 DCHECK(ui_message_loop_);
40 ui_message_loop_->AddDestructionObserver(this);
37 } 41 }
38 42
39 PrintJob::~PrintJob() { 43 PrintJob::~PrintJob() {
44 ui_message_loop_->RemoveDestructionObserver(this);
40 // The job should be finished (or at least canceled) when it is destroyed. 45 // The job should be finished (or at least canceled) when it is destroyed.
41 DCHECK(!is_job_pending_); 46 DCHECK(!is_job_pending_);
42 DCHECK(!is_print_dialog_box_shown_); 47 DCHECK(!is_print_dialog_box_shown_);
43 DCHECK(!is_canceling_); 48 DCHECK(!is_canceling_);
44 DCHECK(worker_->message_loop() == NULL); 49 if (worker_.get())
50 DCHECK(worker_->message_loop() == NULL);
45 DCHECK_EQ(ui_message_loop_, MessageLoop::current()); 51 DCHECK_EQ(ui_message_loop_, MessageLoop::current());
46 } 52 }
47 53
48 void PrintJob::Initialize(PrintJobWorkerOwner* job, 54 void PrintJob::Initialize(PrintJobWorkerOwner* job,
49 PrintedPagesSource* source) { 55 PrintedPagesSource* source) {
50 DCHECK(!source_); 56 DCHECK(!source_);
51 DCHECK(!worker_.get()); 57 DCHECK(!worker_.get());
52 DCHECK(!is_job_pending_); 58 DCHECK(!is_job_pending_);
53 DCHECK(!is_print_dialog_box_shown_); 59 DCHECK(!is_print_dialog_box_shown_);
54 DCHECK(!is_canceling_); 60 DCHECK(!is_canceling_);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return NULL; 141 return NULL;
136 } 142 }
137 143
138 int PrintJob::cookie() const { 144 int PrintJob::cookie() const {
139 if (!document_.get()) 145 if (!document_.get())
140 // Always use an invalid cookie in this case. 146 // Always use an invalid cookie in this case.
141 return 0; 147 return 0;
142 return document_->cookie(); 148 return document_->cookie();
143 } 149 }
144 150
151 void PrintJob::WillDestroyCurrentMessageLoop() {
152 NOTREACHED();
153 }
154
145 void PrintJob::GetSettings(GetSettingsAskParam ask_user_for_settings, 155 void PrintJob::GetSettings(GetSettingsAskParam ask_user_for_settings,
146 HWND parent_window) { 156 HWND parent_window) {
147 DCHECK_EQ(ui_message_loop_, MessageLoop::current()); 157 DCHECK_EQ(ui_message_loop_, MessageLoop::current());
148 DCHECK(!is_job_pending_); 158 DCHECK(!is_job_pending_);
149 DCHECK(!is_print_dialog_box_shown_); 159 DCHECK(!is_print_dialog_box_shown_);
150 // Is not reentrant. 160 // Is not reentrant.
151 if (is_job_pending_) 161 if (is_job_pending_)
152 return; 162 return;
153 163
154 // Lazy create the worker thread. There is one worker thread per print job. 164 // Lazy create the worker thread. There is one worker thread per print job.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 PrintedDocument* JobEventDetails::document() const { 458 PrintedDocument* JobEventDetails::document() const {
449 return document_; 459 return document_;
450 } 460 }
451 461
452 PrintedPage* JobEventDetails::page() const { 462 PrintedPage* JobEventDetails::page() const {
453 return page_; 463 return page_;
454 } 464 }
455 465
456 } // namespace printing 466 } // namespace printing
457 467
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_job.h ('k') | chrome/browser/printing/print_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698