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/printer_query.h" | 5 #include "chrome/browser/printing/printer_query.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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
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 } | 29 } |
30 | 30 |
31 void PrinterQuery::GetSettingsDone(const PrintSettings& new_settings, | 31 void PrinterQuery::GetSettingsDone(const PrintSettings& new_settings, |
32 PrintingContext::Result result) { | 32 PrintingContext::Result result) { |
33 is_print_dialog_box_shown_ = false; | 33 is_print_dialog_box_shown_ = false; |
34 is_initiated_from_android_scripted_print_ = false; | |
34 last_status_ = result; | 35 last_status_ = result; |
35 if (result != PrintingContext::FAILED) { | 36 if (result != PrintingContext::FAILED) { |
36 settings_ = new_settings; | 37 settings_ = new_settings; |
37 cookie_ = PrintSettings::NewCookie(); | 38 cookie_ = PrintSettings::NewCookie(); |
38 } else { | 39 } else { |
39 // Failure. | 40 // Failure. |
40 cookie_ = 0; | 41 cookie_ = 0; |
41 } | 42 } |
42 | 43 |
43 if (!callback_.is_null()) { | 44 if (!callback_.is_null()) { |
44 // This may cause reentrancy like to call StopWorker(). | 45 // This may cause reentrancy like to call StopWorker(). |
46 LOG(INFO) << "DGN - GetSettingsDone - Calling PrinterQuery(" | |
47 << cookie_ <<")'s stored callback"; | |
48 | |
49 if (is_initiated_from_android_scripted_print_) { | |
50 LOG(INFO) << " DGN - THAT'S MY PQ!"; | |
dgn
2014/11/20 12:26:16
I never get there. That's the place where I expect
| |
51 is_initiated_from_android_scripted_print_ = false; | |
52 } | |
45 callback_.Run(); | 53 callback_.Run(); |
46 callback_.Reset(); | 54 callback_.Reset(); |
47 } | 55 } |
48 } | 56 } |
49 | 57 |
58 void PrinterQuery::SetInitiatedFromAndroidScript() { | |
59 is_initiated_from_android_scripted_print_ = true; | |
60 } | |
61 | |
50 PrintJobWorker* PrinterQuery::DetachWorker(PrintJobWorkerOwner* new_owner) { | 62 PrintJobWorker* PrinterQuery::DetachWorker(PrintJobWorkerOwner* new_owner) { |
51 DCHECK(callback_.is_null()); | 63 DCHECK(callback_.is_null()); |
52 DCHECK(worker_.get()); | 64 DCHECK(worker_.get()); |
53 | 65 |
54 worker_->SetNewOwner(new_owner); | 66 worker_->SetNewOwner(new_owner); |
55 return worker_.release(); | 67 return worker_.release(); |
56 } | 68 } |
57 | 69 |
58 const PrintSettings& PrinterQuery::settings() const { | 70 const PrintSettings& PrinterQuery::settings() const { |
59 return settings_; | 71 return settings_; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 | 131 |
120 bool PrinterQuery::is_callback_pending() const { | 132 bool PrinterQuery::is_callback_pending() const { |
121 return !callback_.is_null(); | 133 return !callback_.is_null(); |
122 } | 134 } |
123 | 135 |
124 bool PrinterQuery::is_valid() const { | 136 bool PrinterQuery::is_valid() const { |
125 return worker_.get() != NULL; | 137 return worker_.get() != NULL; |
126 } | 138 } |
127 | 139 |
128 } // namespace printing | 140 } // namespace printing |
OLD | NEW |