Use scoped_ptr to pass settings in PrintJobWorker and PrinterQuery.

BUG=374321
TBR=noamsml

Review URL: https://codereview.chromium.org/488913002

Cr-Commit-Position: refs/heads/master@{#290799}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290799 0039d316-1c4b-4281-b951-d872f2087c98
parent 791d0e37
......@@ -116,7 +116,7 @@ void PrintJobWorker::GetSettings(
}
void PrintJobWorker::SetSettings(
const base::DictionaryValue* const new_settings) {
scoped_ptr<base::DictionaryValue> new_settings) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
BrowserThread::PostTask(
......@@ -126,11 +126,11 @@ void PrintJobWorker::SetSettings(
make_scoped_refptr(owner_),
base::Bind(&PrintJobWorker::UpdatePrintSettings,
base::Unretained(this),
base::Owned(new_settings))));
base::Passed(&new_settings))));
}
void PrintJobWorker::UpdatePrintSettings(
const base::DictionaryValue* const new_settings) {
scoped_ptr<base::DictionaryValue> new_settings) {
PrintingContext::Result result =
printing_context_->UpdatePrintSettings(*new_settings);
GetSettingsDone(result);
......
......@@ -52,9 +52,9 @@ class PrintJobWorker {
bool has_selection,
MarginType margin_type);
// Set the new print settings. This function takes ownership of
// |new_settings|.
void SetSettings(const base::DictionaryValue* const new_settings);
// Set the new print settings.
void SetSettings(
scoped_ptr<base::DictionaryValue> new_settings);
// Starts the printing loop. Every pages are printed as soon as the data is
// available. Makes sure the new_document is the right one.
......@@ -122,9 +122,8 @@ class PrintJobWorker {
// back into the IO thread for GetSettingsDone().
void GetSettingsWithUIDone(PrintingContext::Result result);
// Called on the UI thread to update the print settings. This function takes
// the ownership of |new_settings|.
void UpdatePrintSettings(const base::DictionaryValue* const new_settings);
// Called on the UI thread to update the print settings.
void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings);
// Reports settings back to owner_.
void GetSettingsDone(PrintingContext::Result result);
......
......@@ -88,14 +88,14 @@ void PrinterQuery::GetSettings(
margin_type));
}
void PrinterQuery::SetSettings(const base::DictionaryValue& new_settings,
void PrinterQuery::SetSettings(scoped_ptr<base::DictionaryValue> new_settings,
const base::Closure& callback) {
StartWorker(callback);
worker_->PostTask(FROM_HERE,
base::Bind(&PrintJobWorker::SetSettings,
base::Unretained(worker_.get()),
new_settings.DeepCopy()));
base::Passed(&new_settings)));
}
void PrinterQuery::SetWorkerDestination(
......
......@@ -53,7 +53,7 @@ class PrinterQuery : public PrintJobWorkerOwner {
const base::Closure& callback);
// Updates the current settings with |new_settings| dictionary values.
void SetSettings(const base::DictionaryValue& new_settings,
void SetSettings(scoped_ptr<base::DictionaryValue> new_settings,
const base::Closure& callback);
// Set a destination for the worker.
......
......@@ -427,6 +427,8 @@ void PrintingMessageFilter::UpdateFileDescriptor(int render_view_id, int fd) {
void PrintingMessageFilter::OnUpdatePrintSettings(
int document_cookie, const base::DictionaryValue& job_settings,
IPC::Message* reply_msg) {
scoped_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy());
scoped_refptr<printing::PrinterQuery> printer_query;
if (!profile_io_data_->printing_enabled()->GetValue()) {
// Reply with NULL query.
......@@ -437,7 +439,7 @@ void PrintingMessageFilter::OnUpdatePrintSettings(
if (!printer_query)
printer_query = queue_->CreatePrinterQuery();
printer_query->SetSettings(
job_settings,
new_settings.Pass(),
base::Bind(&PrintingMessageFilter::OnUpdatePrintSettingsReply, this,
printer_query, reply_msg));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment