| 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.h" | 5 #include "chrome/browser/printing/print_job.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.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 // manner by the mere fact that the thread will terminate. So the potential | 324 // manner by the mere fact that the thread will terminate. So the potential |
| 325 // deadlock is eliminated. | 325 // deadlock is eliminated. |
| 326 worker_->StopSoon(); | 326 worker_->StopSoon(); |
| 327 | 327 |
| 328 // Run a tight message loop until the worker terminates. It may seems like a | 328 // Run a tight message loop until the worker terminates. It may seems like a |
| 329 // hack but I see no other way to get it to work flawlessly. The issues here | 329 // hack but I see no other way to get it to work flawlessly. The issues here |
| 330 // are: | 330 // are: |
| 331 // - We don't want to run tasks while the thread is quitting. | 331 // - We don't want to run tasks while the thread is quitting. |
| 332 // - We want this code path to wait on the thread to quit before continuing. | 332 // - We want this code path to wait on the thread to quit before continuing. |
| 333 MSG msg; | 333 MSG msg; |
| 334 HANDLE thread_handle = worker_->thread_handle(); | 334 HANDLE thread_handle = worker_->thread_handle().platform_handle(); |
| 335 for (; thread_handle;) { | 335 for (; thread_handle;) { |
| 336 // Note that we don't do any kind of message prioritization since we don't | 336 // Note that we don't do any kind of message prioritization since we don't |
| 337 // execute any pending task or timer. | 337 // execute any pending task or timer. |
| 338 DWORD result = MsgWaitForMultipleObjects(1, &thread_handle, | 338 DWORD result = MsgWaitForMultipleObjects(1, &thread_handle, |
| 339 FALSE, INFINITE, QS_ALLINPUT); | 339 FALSE, INFINITE, QS_ALLINPUT); |
| 340 if (result == WAIT_OBJECT_0 + 1) { | 340 if (result == WAIT_OBJECT_0 + 1) { |
| 341 while (PeekMessage(&msg, NULL, 0, 0, TRUE) > 0) { | 341 while (PeekMessage(&msg, NULL, 0, 0, TRUE) > 0) { |
| 342 TranslateMessage(&msg); | 342 TranslateMessage(&msg); |
| 343 DispatchMessage(&msg); | 343 DispatchMessage(&msg); |
| 344 } | 344 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 PrintedDocument* JobEventDetails::document() const { | 393 PrintedDocument* JobEventDetails::document() const { |
| 394 return document_; | 394 return document_; |
| 395 } | 395 } |
| 396 | 396 |
| 397 PrintedPage* JobEventDetails::page() const { | 397 PrintedPage* JobEventDetails::page() const { |
| 398 return page_; | 398 return page_; |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace printing | 401 } // namespace printing |
| OLD | NEW |