| OLD | NEW |
| 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_worker.h" | 5 #include "chrome/browser/printing/print_job_worker.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "chrome/browser/chrome_thread.h" | 8 #include "chrome/browser/chrome_thread.h" |
| 9 #include "chrome/browser/printing/print_job.h" | 9 #include "chrome/browser/printing/print_job.h" |
| 10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 bool has_selection) { | 70 bool has_selection) { |
| 71 DCHECK_EQ(message_loop(), MessageLoop::current()); | 71 DCHECK_EQ(message_loop(), MessageLoop::current()); |
| 72 DCHECK_EQ(page_number_, PageNumber::npos()); | 72 DCHECK_EQ(page_number_, PageNumber::npos()); |
| 73 | 73 |
| 74 // Recursive task processing is needed for the dialog in case it needs to be | 74 // Recursive task processing is needed for the dialog in case it needs to be |
| 75 // destroyed by a task. | 75 // destroyed by a task. |
| 76 MessageLoop::current()->SetNestableTasksAllowed(true); | 76 MessageLoop::current()->SetNestableTasksAllowed(true); |
| 77 | 77 |
| 78 if (ask_user_for_settings) { | 78 if (ask_user_for_settings) { |
| 79 #if defined(OS_MACOSX) | 79 #if defined(OS_MACOSX) |
| 80 ChromeThread::GetMessageLoop(ChromeThread::UI)->PostTask( | 80 ChromeThread::PostTask( |
| 81 FROM_HERE, NewRunnableMethod(this, &PrintJobWorker::GetSettingsWithUI, | 81 ChromeThread::UI, FROM_HERE, |
| 82 parent_window, document_page_count, | 82 NewRunnableMethod(this, &PrintJobWorker::GetSettingsWithUI, |
| 83 has_selection)); | 83 parent_window, document_page_count, |
| 84 has_selection)); |
| 84 #else | 85 #else |
| 85 PrintingContext::Result result = printing_context_.AskUserForSettings( | 86 PrintingContext::Result result = printing_context_.AskUserForSettings( |
| 86 parent_window, document_page_count, has_selection); | 87 parent_window, document_page_count, has_selection); |
| 87 GetSettingsDone(result); | 88 GetSettingsDone(result); |
| 88 #endif | 89 #endif |
| 89 } else { | 90 } else { |
| 90 PrintingContext::Result result = printing_context_.UseDefaultSettings(); | 91 PrintingContext::Result result = printing_context_.UseDefaultSettings(); |
| 91 GetSettingsDone(result); | 92 GetSettingsDone(result); |
| 92 } | 93 } |
| 93 } | 94 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 104 owner_, | 105 owner_, |
| 105 &PrintJobWorkerOwner::GetSettingsDone, | 106 &PrintJobWorkerOwner::GetSettingsDone, |
| 106 printing_context_.settings(), | 107 printing_context_.settings(), |
| 107 result)); | 108 result)); |
| 108 } | 109 } |
| 109 | 110 |
| 110 #if defined(OS_MACOSX) | 111 #if defined(OS_MACOSX) |
| 111 void PrintJobWorker::GetSettingsWithUI(gfx::NativeWindow parent_window, | 112 void PrintJobWorker::GetSettingsWithUI(gfx::NativeWindow parent_window, |
| 112 int document_page_count, | 113 int document_page_count, |
| 113 bool has_selection) { | 114 bool has_selection) { |
| 114 DCHECK_EQ(ChromeThread::GetMessageLoop(ChromeThread::UI), | 115 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 115 MessageLoop::current()); | |
| 116 | 116 |
| 117 PrintingContext::Result result = printing_context_.AskUserForSettings( | 117 PrintingContext::Result result = printing_context_.AskUserForSettings( |
| 118 parent_window, document_page_count, has_selection); | 118 parent_window, document_page_count, has_selection); |
| 119 message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 119 message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 120 this, &PrintJobWorker::GetSettingsDone, result)); | 120 this, &PrintJobWorker::GetSettingsDone, result)); |
| 121 } | 121 } |
| 122 #endif | 122 #endif |
| 123 | 123 |
| 124 void PrintJobWorker::StartPrinting(PrintedDocument* new_document) { | 124 void PrintJobWorker::StartPrinting(PrintedDocument* new_document) { |
| 125 DCHECK_EQ(message_loop(), MessageLoop::current()); | 125 DCHECK_EQ(message_loop(), MessageLoop::current()); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 printing::PrintJobWorker* obj) { | 317 printing::PrintJobWorker* obj) { |
| 318 DCHECK(!owner_.get()); | 318 DCHECK(!owner_.get()); |
| 319 owner_ = obj->owner_; | 319 owner_ = obj->owner_; |
| 320 } | 320 } |
| 321 | 321 |
| 322 void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee( | 322 void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee( |
| 323 printing::PrintJobWorker* obj) { | 323 printing::PrintJobWorker* obj) { |
| 324 DCHECK_EQ(owner_, obj->owner_); | 324 DCHECK_EQ(owner_, obj->owner_); |
| 325 owner_ = NULL; | 325 owner_ = NULL; |
| 326 } | 326 } |
| OLD | NEW |