summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc41
-rw-r--r--chrome/browser/printing/print_dialog_cloud_uitest.cc11
-rw-r--r--chrome/browser/printing/print_dialog_cloud_unittest.cc28
-rw-r--r--chrome/browser/printing/print_dialog_gtk.cc6
-rw-r--r--chrome/browser/printing/print_job.cc34
-rw-r--r--chrome/browser/printing/print_job.h22
-rw-r--r--chrome/browser/printing/print_job_worker.cc92
-rw-r--r--chrome/browser/printing/print_job_worker.h15
-rw-r--r--chrome/browser/printing/printer_manager_dialog_linux.cc3
-rw-r--r--chrome/browser/printing/printer_query.cc25
-rw-r--r--chrome/browser/printing/printer_query.h13
11 files changed, 148 insertions, 142 deletions
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index e0c7447..beb85a1 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -209,10 +209,9 @@ void CloudPrintDataSender::ReadPrintDataFile(const FilePath& path_to_file) {
base64_data.insert(0, header);
scoped_ptr<StringValue> new_data(new StringValue(base64_data));
print_data_.swap(new_data);
- BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- NewRunnableMethod(
- this,
- &CloudPrintDataSender::SendPrintDataFile));
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&CloudPrintDataSender::SendPrintDataFile, this));
}
}
}
@@ -374,11 +373,10 @@ void CloudPrintFlowHandler::HandleSendPrintData(const ListValue* args) {
CancelAnyRunningTask();
if (web_ui_) {
print_data_sender_ = CreateCloudPrintDataSender();
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- print_data_sender_.get(),
- &CloudPrintDataSender::ReadPrintDataFile,
- path_to_file_));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&CloudPrintDataSender::ReadPrintDataFile,
+ print_data_sender_.get(), path_to_file_));
}
}
@@ -534,9 +532,9 @@ void CloudPrintHtmlDialogDelegate::OnDialogClosed(
flow_handler_->StoreDialogClientSize();
if (delete_on_close_) {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&internal_cloud_print_helpers::Delete,
- path_to_file_));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&internal_cloud_print_helpers::Delete, path_to_file_));
}
// If we're modal we can show the dialog with no browser.
@@ -664,13 +662,9 @@ void CreatePrintDialogForFile(const FilePath& path_to_file,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&internal_cloud_print_helpers::CreateDialogImpl,
- path_to_file,
- print_job_title,
- print_ticket,
- file_type,
- modal,
- delete_on_close));
+ base::Bind(&internal_cloud_print_helpers::CreateDialogImpl, path_to_file,
+ print_job_title, print_ticket, file_type, modal,
+ delete_on_close));
}
void CreatePrintDialogForBytes(scoped_refptr<RefCountedBytes> data,
@@ -684,13 +678,8 @@ void CreatePrintDialogForBytes(scoped_refptr<RefCountedBytes> data,
scoped_refptr<RefCountedBytes> cloned_data(new RefCountedBytes(data->data()));
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(
- &internal_cloud_print_helpers::CreatePrintDialogForBytesImpl,
- cloned_data,
- print_job_title,
- print_ticket,
- file_type,
- modal));
+ base::Bind(&internal_cloud_print_helpers::CreatePrintDialogForBytesImpl,
+ cloned_data, print_job_title, print_ticket, file_type, modal));
}
bool CreatePrintDialogFromCommandLine(const CommandLine& command_line) {
diff --git a/chrome/browser/printing/print_dialog_cloud_uitest.cc b/chrome/browser/printing/print_dialog_cloud_uitest.cc
index 7982701..fcb02d9 100644
--- a/chrome/browser/printing/print_dialog_cloud_uitest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_uitest.cc
@@ -7,6 +7,7 @@
#include <functional>
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/memory/singleton.h"
@@ -203,13 +204,9 @@ class PrintDialogCloudTest : public InProcessBrowserTest {
test_data_directory_.AppendASCII("printing/cloud_print_uitest.pdf");
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&internal_cloud_print_helpers::CreateDialogImpl,
- path_to_pdf,
- string16(),
- string16(),
- std::string("application/pdf"),
- true,
- false));
+ base::Bind(&internal_cloud_print_helpers::CreateDialogImpl, path_to_pdf,
+ string16(), string16(), std::string("application/pdf"), true,
+ false));
}
bool handler_added_;
diff --git a/chrome/browser/printing/print_dialog_cloud_unittest.cc b/chrome/browser/printing/print_dialog_cloud_unittest.cc
index 3bb0792..150c818 100644
--- a/chrome/browser/printing/print_dialog_cloud_unittest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_unittest.cc
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/memory/weak_ptr.h"
@@ -247,11 +248,10 @@ TEST_F(CloudPrintDataSenderTest, CanSend) {
WillOnce(Return());
FilePath test_data_file_name = GetTestDataFileName();
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- print_data_sender_.get(),
- &CloudPrintDataSender::ReadPrintDataFile,
- test_data_file_name));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&CloudPrintDataSender::ReadPrintDataFile,
+ print_data_sender_.get(), test_data_file_name));
MessageLoop::current()->RunAllPending();
}
@@ -263,11 +263,10 @@ TEST_F(CloudPrintDataSenderTest, BadFile) {
#else
FilePath bad_data_file_name("/some/file/that/isnot/there");
#endif
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- print_data_sender_.get(),
- &CloudPrintDataSender::ReadPrintDataFile,
- bad_data_file_name));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&CloudPrintDataSender::ReadPrintDataFile,
+ print_data_sender_.get(), bad_data_file_name));
MessageLoop::current()->RunAllPending();
}
@@ -275,11 +274,10 @@ TEST_F(CloudPrintDataSenderTest, EmptyFile) {
EXPECT_CALL(*mock_helper_, CallJavascriptFunction(_, _, _)).Times(0);
FilePath empty_data_file_name = GetEmptyDataFileName();
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- print_data_sender_.get(),
- &CloudPrintDataSender::ReadPrintDataFile,
- empty_data_file_name));
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&CloudPrintDataSender::ReadPrintDataFile,
+ print_data_sender_.get(), empty_data_file_name));
MessageLoop::current()->RunAllPending();
}
diff --git a/chrome/browser/printing/print_dialog_gtk.cc b/chrome/browser/printing/print_dialog_gtk.cc
index aaaf6ce..652a205 100644
--- a/chrome/browser/printing/print_dialog_gtk.cc
+++ b/chrome/browser/printing/print_dialog_gtk.cc
@@ -13,6 +13,7 @@
#include <string>
#include <vector>
+#include "base/bind.h"
#include "base/file_util.h"
#include "base/file_util_proxy.h"
#include "base/logging.h"
@@ -288,9 +289,8 @@ void PrintDialogGtk::PrintDocument(const printing::Metafile* metafile,
// No errors, continue printing.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &PrintDialogGtk::SendDocumentToPrinter,
- document_name));
+ base::Bind(&PrintDialogGtk::SendDocumentToPrinter, this,
+ document_name));
}
}
diff --git a/chrome/browser/printing/print_job.cc b/chrome/browser/printing/print_job.cc
index bf5b80d..b374b685 100644
--- a/chrome/browser/printing/print_job.cc
+++ b/chrome/browser/printing/print_job.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/printing/print_job.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/message_loop.h"
#include "base/threading/thread_restrictions.h"
#include "base/timer.h"
@@ -15,6 +17,16 @@
using base::TimeDelta;
+namespace {
+
+// Helper function to ensure |owner| is valid until at least |callback| returns.
+void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner,
+ const base::Closure& callback) {
+ callback.Run();
+}
+
+} // namespace
+
namespace printing {
PrintJob::PrintJob()
@@ -116,8 +128,11 @@ void PrintJob::StartPrinting() {
return;
// Real work is done in PrintJobWorker::StartPrinting().
- worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
- worker_.get(), &PrintJobWorker::StartPrinting, document_));
+ worker_->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&HoldRefCallback, make_scoped_refptr(this),
+ base::Bind(&PrintJobWorker::StartPrinting,
+ base::Unretained(worker_.get()), document_)));
// Set the flag right now.
is_job_pending_ = true;
@@ -223,8 +238,11 @@ void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
if (worker_.get() && worker_->message_loop()) {
DCHECK(!is_job_pending_);
// Sync the document with the worker.
- worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
- worker_.get(), &PrintJobWorker::OnDocumentChanged, document_));
+ worker_->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&HoldRefCallback, make_scoped_refptr(this),
+ base::Bind(&PrintJobWorker::OnDocumentChanged,
+ base::Unretained(worker_.get()), document_)));
}
}
@@ -252,8 +270,8 @@ void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) {
}
case JobEventDetails::DOC_DONE: {
// This will call Stop() and broadcast a JOB_DONE message.
- MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &PrintJob::OnDocumentDone));
+ MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(&PrintJob::OnDocumentDone, this));
break;
}
default: {
@@ -304,7 +322,7 @@ void PrintJob::ControlledWorkerShutdown() {
MSG msg;
HANDLE thread_handle = worker_->thread_handle();
for (; thread_handle;) {
- // Note that we don't do any kind of message priorization since we don't
+ // Note that we don't do any kind of message prioritization since we don't
// execute any pending task or timer.
DWORD result = MsgWaitForMultipleObjects(1, &thread_handle,
FALSE, INFINITE, QS_ALLINPUT);
@@ -318,7 +336,7 @@ void PrintJob::ControlledWorkerShutdown() {
// The thread quit.
break;
} else {
- // An error occured. Assume the thread quit.
+ // An error occurred. Assume the thread quit.
NOTREACHED();
break;
}
diff --git a/chrome/browser/printing/print_job.h b/chrome/browser/printing/print_job.h
index 265ed687..17f3857 100644
--- a/chrome/browser/printing/print_job.h
+++ b/chrome/browser/printing/print_job.h
@@ -46,21 +46,21 @@ class PrintJob : public PrintJobWorkerOwner,
void Initialize(PrintJobWorkerOwner* job, PrintedPagesSource* source,
int page_count);
- // content::NotificationObserver
+ // content::NotificationObserver implementation.
virtual void Observe(int type,
const content::NotificationSource& source,
- const content::NotificationDetails& details);
+ const content::NotificationDetails& details) OVERRIDE;
- // PrintJobWorkerOwner
+ // PrintJobWorkerOwner implementation.
virtual void GetSettingsDone(const PrintSettings& new_settings,
- PrintingContext::Result result);
- virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner);
- virtual MessageLoop* message_loop();
- virtual const PrintSettings& settings() const;
- virtual int cookie() const;
-
- // DestructionObserver
- virtual void WillDestroyCurrentMessageLoop();
+ PrintingContext::Result result) OVERRIDE;
+ virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) OVERRIDE;
+ virtual MessageLoop* message_loop() OVERRIDE;
+ virtual const PrintSettings& settings() const OVERRIDE;
+ virtual int cookie() const OVERRIDE;
+
+ // DestructionObserver implementation.
+ virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
// Starts the actual printing. Signals the worker that it should begin to
// spool as soon as data is available.
diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc
index 1072fb5..db642cf 100644
--- a/chrome/browser/printing/print_job_worker.cc
+++ b/chrome/browser/printing/print_job_worker.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/printing/print_job_worker.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/callback.h"
+#include "base/compiler_specific.h"
#include "base/message_loop.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
@@ -17,14 +21,22 @@
using content::BrowserThread;
+namespace {
+
+// Helper function to ensure |owner| is valid until at least |callback| returns.
+void HoldRefCallback(const scoped_refptr<printing::PrintJobWorkerOwner>& owner,
+ const base::Closure& callback) {
+ callback.Run();
+}
+
+} // namespace
+
namespace printing {
class PrintJobWorker::NotificationTask : public Task {
public:
- NotificationTask() : print_job_(NULL), details_(NULL) {
- }
- ~NotificationTask() {
- }
+ NotificationTask() : print_job_(NULL), details_(NULL) {}
+ ~NotificationTask() {}
// Initializes the object. This object can't be initialized in the constructor
// since it is not created directly.
@@ -52,10 +64,10 @@ class PrintJobWorker::NotificationTask : public Task {
scoped_refptr<JobEventDetails> details_;
};
-
PrintJobWorker::PrintJobWorker(PrintJobWorkerOwner* owner)
: Thread("Printing_Worker"),
- owner_(owner) {
+ owner_(owner),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
// The object is created in the IO thread.
DCHECK_EQ(owner_->message_loop(), MessageLoop::current());
@@ -86,7 +98,7 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
// Recursive task processing is needed for the dialog in case it needs to be
// destroyed by a task.
- // TODO(thestig): this code is wrong, SetNestableTasksAllowed(true) is needed
+ // TODO(thestig): This code is wrong. SetNestableTasksAllowed(true) is needed
// on the thread where the PrintDlgEx is called, and definitely both calls
// should happen on the same thread. See http://crbug.com/73466
// MessageLoop::current()->SetNestableTasksAllowed(true);
@@ -95,21 +107,27 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
if (ask_user_for_settings) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &PrintJobWorker::GetSettingsWithUI,
- parent_view, document_page_count,
- has_selection));
+ base::Bind(&HoldRefCallback, make_scoped_refptr(owner_),
+ base::Bind(&PrintJobWorker::GetSettingsWithUI,
+ base::Unretained(this), parent_view,
+ document_page_count, has_selection)));
} else {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &PrintJobWorker::UseDefaultSettings));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&HoldRefCallback, make_scoped_refptr(owner_),
+ base::Bind(&PrintJobWorker::UseDefaultSettings,
+ base::Unretained(this))));
}
}
void PrintJobWorker::SetSettings(const DictionaryValue* const new_settings) {
DCHECK_EQ(message_loop(), MessageLoop::current());
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this, &PrintJobWorker::UpdatePrintSettings,
- new_settings));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&HoldRefCallback, make_scoped_refptr(owner_),
+ base::Bind(&PrintJobWorker::UpdatePrintSettings,
+ base::Unretained(this), new_settings)));
}
void PrintJobWorker::UpdatePrintSettings(
@@ -145,7 +163,7 @@ void PrintJobWorker::UpdatePrintSettings(
void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) {
// Most PrintingContext functions may start a message loop and process
// message recursively, so disable recursive task processing.
- // TODO(thestig): see above comment. SetNestableTasksAllowed(false) needs to
+ // TODO(thestig): See above comment. SetNestableTasksAllowed(false) needs to
// be called on the same thread as the previous call. See
// http://crbug.com/73466
// MessageLoop::current()->SetNestableTasksAllowed(false);
@@ -153,11 +171,11 @@ void PrintJobWorker::GetSettingsDone(PrintingContext::Result result) {
// We can't use OnFailure() here since owner_ may not support notifications.
// PrintJob will create the new PrintedDocument.
- owner_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
- owner_,
- &PrintJobWorkerOwner::GetSettingsDone,
- printing_context_->settings(),
- result));
+ owner_->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&PrintJobWorkerOwner::GetSettingsDone,
+ make_scoped_refptr(owner_), printing_context_->settings(),
+ result));
}
void PrintJobWorker::GetSettingsWithUI(gfx::NativeView parent_view,
@@ -166,15 +184,16 @@ void PrintJobWorker::GetSettingsWithUI(gfx::NativeView parent_view,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
printing_context_->AskUserForSettings(
- parent_view,
- document_page_count,
- has_selection,
+ parent_view, document_page_count, has_selection,
NewCallback(this, &PrintJobWorker::GetSettingsWithUIDone));
}
void PrintJobWorker::GetSettingsWithUIDone(PrintingContext::Result result) {
- message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
- this, &PrintJobWorker::GetSettingsDone, result));
+ message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&HoldRefCallback, make_scoped_refptr(owner_),
+ base::Bind(&PrintJobWorker::GetSettingsDone,
+ base::Unretained(this), result)));
}
void PrintJobWorker::UseDefaultSettings() {
@@ -223,10 +242,9 @@ void PrintJobWorker::OnDocumentChanged(PrintedDocument* new_document) {
}
void PrintJobWorker::OnNewPage() {
- if (!document_.get()) {
- // Spurious message.
+ if (!document_.get()) // Spurious message.
return;
- }
+
// message_loop() could return NULL when the print job is cancelled.
DCHECK_EQ(message_loop(), MessageLoop::current());
@@ -244,14 +262,14 @@ void PrintJobWorker::OnNewPage() {
}
DCHECK_NE(page_number_, PageNumber::npos());
- for (;;) {
+ while (true) {
// Is the page available?
scoped_refptr<PrintedPage> page;
if (!document_->GetPage(page_number_.ToInt(), &page)) {
// We need to wait for the page to be available.
MessageLoop::current()->PostDelayedTask(
FROM_HERE,
- NewRunnableMethod(this, &PrintJobWorker::OnNewPage),
+ base::Bind(&PrintJobWorker::OnNewPage, weak_factory_.GetWeakPtr()),
500);
break;
}
@@ -355,15 +373,3 @@ void PrintJobWorker::OnFailure() {
}
} // namespace printing
-
-void RunnableMethodTraits<printing::PrintJobWorker>::RetainCallee(
- printing::PrintJobWorker* obj) {
- DCHECK(!owner_.get());
- owner_ = obj->owner_;
-}
-
-void RunnableMethodTraits<printing::PrintJobWorker>::ReleaseCallee(
- printing::PrintJobWorker* obj) {
- DCHECK_EQ(owner_, obj->owner_);
- owner_ = NULL;
-}
diff --git a/chrome/browser/printing/print_job_worker.h b/chrome/browser/printing/print_job_worker.h
index 4c11629..67bff08 100644
--- a/chrome/browser/printing/print_job_worker.h
+++ b/chrome/browser/printing/print_job_worker.h
@@ -8,6 +8,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/task.h"
#include "base/threading/thread.h"
#include "printing/page_number.h"
@@ -58,7 +59,7 @@ class PrintJobWorker : public base::Thread {
// Updates the printed document.
void OnDocumentChanged(PrintedDocument* new_document);
- // Unqueues waiting pages. Called when PrintJob receives a
+ // Dequeues waiting pages. Called when PrintJob receives a
// NOTIFY_PRINTED_DOCUMENT_UPDATED notification. It's time to look again if
// the next page can be printed.
void OnNewPage();
@@ -77,7 +78,6 @@ class PrintJobWorker : public base::Thread {
// notifications are sent this way, except USER_INIT_DONE, USER_INIT_CANCELED
// and DEFAULT_INIT_DONE. These three are sent through PrintJob::InitDone().
class NotificationTask;
- friend struct RunnableMethodTraits<PrintJobWorker>;
// Renders a page in the printer.
void SpoolPage(PrintedPage& page);
@@ -126,17 +126,12 @@ class PrintJobWorker : public base::Thread {
// Current page number to print.
PageNumber page_number_;
+ // Used to generate a WeakPtr for callbacks.
+ base::WeakPtrFactory<PrintJobWorker> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PrintJobWorker);
};
} // namespace printing
-template <>
-struct RunnableMethodTraits<printing::PrintJobWorker> {
- void RetainCallee(printing::PrintJobWorker* obj);
- void ReleaseCallee(printing::PrintJobWorker* obj);
- private:
- scoped_refptr<printing::PrintJobWorkerOwner> owner_;
-};
-
#endif // CHROME_BROWSER_PRINTING_PRINT_JOB_WORKER_H__
diff --git a/chrome/browser/printing/printer_manager_dialog_linux.cc b/chrome/browser/printing/printer_manager_dialog_linux.cc
index 6ef3f60..967f30e 100644
--- a/chrome/browser/printing/printer_manager_dialog_linux.cc
+++ b/chrome/browser/printing/printer_manager_dialog_linux.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/printing/printer_manager_dialog.h"
+#include "base/bind.h"
#include "base/environment.h"
#include "base/nix/xdg_util.h"
#include "base/process_util.h"
@@ -62,7 +63,7 @@ namespace printing {
void PrinterManagerDialog::ShowPrinterManagerDialog() {
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&DetectAndOpenPrinterConfigDialog));
+ base::Bind(&DetectAndOpenPrinterConfigDialog));
}
} // namespace printing
diff --git a/chrome/browser/printing/printer_query.cc b/chrome/browser/printing/printer_query.cc
index 2614607..b70228a 100644
--- a/chrome/browser/printing/printer_query.cc
+++ b/chrome/browser/printing/printer_query.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/printing/printer_query.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/message_loop.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
@@ -84,14 +86,12 @@ void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings,
// Real work is done in PrintJobWorker::Init().
is_print_dialog_box_shown_ = ask_user_for_settings == ASK_USER;
- worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
- worker_.get(),
- &PrintJobWorker::GetSettings,
- is_print_dialog_box_shown_,
- parent_view,
- expected_page_count,
- has_selection,
- margin_type));
+ worker_->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&PrintJobWorker::GetSettings,
+ base::Unretained(worker_.get()),
+ is_print_dialog_box_shown_, parent_view,
+ expected_page_count, has_selection, margin_type));
}
void PrinterQuery::SetSettings(const DictionaryValue& new_settings,
@@ -99,10 +99,11 @@ void PrinterQuery::SetSettings(const DictionaryValue& new_settings,
if (!StartWorker(callback))
return;
- worker_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
- worker_.get(),
- &PrintJobWorker::SetSettings,
- new_settings.DeepCopy()));
+ worker_->message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&PrintJobWorker::SetSettings,
+ base::Unretained(worker_.get()),
+ new_settings.DeepCopy()));
}
bool PrinterQuery::StartWorker(CancelableTask* callback) {
diff --git a/chrome/browser/printing/printer_query.h b/chrome/browser/printing/printer_query.h
index 911b14d..e04557d 100644
--- a/chrome/browser/printing/printer_query.h
+++ b/chrome/browser/printing/printer_query.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_PRINTING_PRINTER_QUERY_H_
#pragma once
+#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/printing/print_job_worker_owner.h"
#include "printing/print_job_constants.h"
@@ -34,13 +35,13 @@ class PrinterQuery : public PrintJobWorkerOwner {
PrinterQuery();
- // PrintJobWorkerOwner
+ // PrintJobWorkerOwner implementation.
virtual void GetSettingsDone(const PrintSettings& new_settings,
- PrintingContext::Result result);
- virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner);
- virtual MessageLoop* message_loop();
- virtual const PrintSettings& settings() const;
- virtual int cookie() const;
+ PrintingContext::Result result) OVERRIDE;
+ virtual PrintJobWorker* DetachWorker(PrintJobWorkerOwner* new_owner) OVERRIDE;
+ virtual MessageLoop* message_loop() OVERRIDE;
+ virtual const PrintSettings& settings() const OVERRIDE;
+ virtual int cookie() const OVERRIDE;
// Initializes the printing context. It is fine to call this function multiple
// times to reinitialize the settings. |parent_view| parameter's window will