| 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_view_manager.h" | 5 #include "chrome/browser/printing/print_view_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 } | 483 } |
| 484 | 484 |
| 485 void PrintViewManager::ShouldQuitFromInnerMessageLoop() { | 485 void PrintViewManager::ShouldQuitFromInnerMessageLoop() { |
| 486 // Look at the reason. | 486 // Look at the reason. |
| 487 DCHECK(print_job_->document()); | 487 DCHECK(print_job_->document()); |
| 488 if (print_job_->document() && | 488 if (print_job_->document() && |
| 489 print_job_->document()->IsComplete() && | 489 print_job_->document()->IsComplete() && |
| 490 inside_inner_message_loop_) { | 490 inside_inner_message_loop_) { |
| 491 // We are in a message loop created by RenderAllMissingPagesNow. Quit from | 491 // We are in a message loop created by RenderAllMissingPagesNow. Quit from |
| 492 // it. | 492 // it. |
| 493 MessageLoop::current()->Quit(); | 493 base::MessageLoop::current()->Quit(); |
| 494 inside_inner_message_loop_ = false; | 494 inside_inner_message_loop_ = false; |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 | 497 |
| 498 bool PrintViewManager::CreateNewPrintJob(PrintJobWorkerOwner* job) { | 498 bool PrintViewManager::CreateNewPrintJob(PrintJobWorkerOwner* job) { |
| 499 DCHECK(!inside_inner_message_loop_); | 499 DCHECK(!inside_inner_message_loop_); |
| 500 | 500 |
| 501 // Disconnect the current print_job_. | 501 // Disconnect the current print_job_. |
| 502 DisconnectFromCurrentPrintJob(); | 502 DisconnectFromCurrentPrintJob(); |
| 503 | 503 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 // - If we're looping because of printer settings initialization, the premise | 588 // - If we're looping because of printer settings initialization, the premise |
| 589 // here is that some poor users have their print server away on a VPN over a | 589 // here is that some poor users have their print server away on a VPN over a |
| 590 // slow connection. In this situation, the simple fact of opening the printer | 590 // slow connection. In this situation, the simple fact of opening the printer |
| 591 // can be dead slow. On the other side, we don't want to die infinitely for a | 591 // can be dead slow. On the other side, we don't want to die infinitely for a |
| 592 // real network error. Give the printer 60 seconds to comply. | 592 // real network error. Give the printer 60 seconds to comply. |
| 593 // | 593 // |
| 594 // - If we're looping because of renderer page generation, the renderer could | 594 // - If we're looping because of renderer page generation, the renderer could |
| 595 // be CPU bound, the page overly complex/large or the system just | 595 // be CPU bound, the page overly complex/large or the system just |
| 596 // memory-bound. | 596 // memory-bound. |
| 597 static const int kPrinterSettingsTimeout = 60000; | 597 static const int kPrinterSettingsTimeout = 60000; |
| 598 base::OneShotTimer<MessageLoop> quit_timer; | 598 base::OneShotTimer<base::MessageLoop> quit_timer; |
| 599 quit_timer.Start(FROM_HERE, | 599 quit_timer.Start(FROM_HERE, |
| 600 TimeDelta::FromMilliseconds(kPrinterSettingsTimeout), | 600 TimeDelta::FromMilliseconds(kPrinterSettingsTimeout), |
| 601 MessageLoop::current(), &MessageLoop::Quit); | 601 base::MessageLoop::current(), &base::MessageLoop::Quit); |
| 602 | 602 |
| 603 inside_inner_message_loop_ = true; | 603 inside_inner_message_loop_ = true; |
| 604 | 604 |
| 605 // Need to enable recursive task. | 605 // Need to enable recursive task. |
| 606 { | 606 { |
| 607 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 607 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 608 MessageLoop::current()->Run(); | 608 base::MessageLoop::current()); |
| 609 base::MessageLoop::current()->Run(); |
| 609 } | 610 } |
| 610 | 611 |
| 611 bool success = true; | 612 bool success = true; |
| 612 if (inside_inner_message_loop_) { | 613 if (inside_inner_message_loop_) { |
| 613 // Ok we timed out. That's sad. | 614 // Ok we timed out. That's sad. |
| 614 inside_inner_message_loop_ = false; | 615 inside_inner_message_loop_ = false; |
| 615 success = false; | 616 success = false; |
| 616 } | 617 } |
| 617 | 618 |
| 618 return success; | 619 return success; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 scoped_refptr<printing::PrinterQuery> printer_query; | 676 scoped_refptr<printing::PrinterQuery> printer_query; |
| 676 print_job_manager->PopPrinterQuery(cookie, &printer_query); | 677 print_job_manager->PopPrinterQuery(cookie, &printer_query); |
| 677 if (!printer_query.get()) | 678 if (!printer_query.get()) |
| 678 return; | 679 return; |
| 679 BrowserThread::PostTask( | 680 BrowserThread::PostTask( |
| 680 BrowserThread::IO, FROM_HERE, | 681 BrowserThread::IO, FROM_HERE, |
| 681 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); | 682 base::Bind(&PrinterQuery::StopWorker, printer_query.get())); |
| 682 } | 683 } |
| 683 | 684 |
| 684 } // namespace printing | 685 } // namespace printing |
| OLD | NEW |