| 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" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 BrowserThread::UI, FROM_HERE, web_contents_observer.release()); | 109 BrowserThread::UI, FROM_HERE, web_contents_observer.release()); |
| 110 BrowserThread::PostTask( | 110 BrowserThread::PostTask( |
| 111 BrowserThread::UI, FROM_HERE, | 111 BrowserThread::UI, FROM_HERE, |
| 112 base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), | 112 base::Bind(&HoldRefCallback, make_scoped_refptr(owner_), |
| 113 base::Bind(&PrintJobWorker::UseDefaultSettings, | 113 base::Bind(&PrintJobWorker::UseDefaultSettings, |
| 114 base::Unretained(this)))); | 114 base::Unretained(this)))); |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 void PrintJobWorker::SetSettings( | 118 void PrintJobWorker::SetSettings( |
| 119 const base::DictionaryValue* const new_settings) { | 119 scoped_ptr<base::DictionaryValue> new_settings) { |
| 120 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 120 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 121 | 121 |
| 122 BrowserThread::PostTask( | 122 BrowserThread::PostTask( |
| 123 BrowserThread::UI, | 123 BrowserThread::UI, |
| 124 FROM_HERE, | 124 FROM_HERE, |
| 125 base::Bind(&HoldRefCallback, | 125 base::Bind(&HoldRefCallback, |
| 126 make_scoped_refptr(owner_), | 126 make_scoped_refptr(owner_), |
| 127 base::Bind(&PrintJobWorker::UpdatePrintSettings, | 127 base::Bind(&PrintJobWorker::UpdatePrintSettings, |
| 128 base::Unretained(this), | 128 base::Unretained(this), |
| 129 base::Owned(new_settings)))); | 129 base::Passed(&new_settings)))); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void PrintJobWorker::UpdatePrintSettings( | 132 void PrintJobWorker::UpdatePrintSettings( |
| 133 const base::DictionaryValue* const new_settings) { | 133 scoped_ptr<base::DictionaryValue> new_settings) { |
| 134 PrintingContext::Result result = | 134 PrintingContext::Result result = |
| 135 printing_context_->UpdatePrintSettings(*new_settings); | 135 printing_context_->UpdatePrintSettings(*new_settings); |
| 136 GetSettingsDone(result); | 136 GetSettingsDone(result); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) { | 139 void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) { |
| 140 // Most PrintingContext functions may start a message loop and process | 140 // Most PrintingContext functions may start a message loop and process |
| 141 // message recursively, so disable recursive task processing. | 141 // message recursively, so disable recursive task processing. |
| 142 // TODO(thestig): See above comment. SetNestableTasksAllowed(false) needs to | 142 // TODO(thestig): See above comment. SetNestableTasksAllowed(false) needs to |
| 143 // be called on the same thread as the previous call. See | 143 // be called on the same thread as the previous call. See |
| (...skipping 247 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 |