Adapt to changes of Chrome 51 API changes (Part 2)

This commit is contained in:
Cheng Zhao 2016-05-23 12:28:59 +09:00
parent 7ba391da7c
commit a2bd55dd3c
48 changed files with 131 additions and 131 deletions

View file

@ -48,7 +48,7 @@ class RefCountedTempDir
DISALLOW_COPY_AND_ASSIGN(RefCountedTempDir);
};
typedef scoped_ptr<base::File, BrowserThread::DeleteOnFileThread>
typedef std::unique_ptr<base::File, BrowserThread::DeleteOnFileThread>
ScopedTempFile;
// Wrapper for Emf to keep only file handle in memory, and load actual data only
@ -389,7 +389,7 @@ void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success,
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (get_page_callbacks_.empty())
return OnFailed();
scoped_ptr<MetafilePlayer> emf;
std::unique_ptr<MetafilePlayer> emf;
GetPageCallbackData& data = get_page_callbacks_.front();
if (success)
emf.reset(new LazyEmf(temp_dir_, data.emf().Pass()));
@ -487,8 +487,8 @@ PdfToEmfConverter::~PdfToEmfConverter() {
}
// static
scoped_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() {
return scoped_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl());
std::unique_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() {
return std::unique_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl());
}
} // namespace printing

View file

@ -23,11 +23,11 @@ class PdfToEmfConverter {
typedef base::Callback<void(int page_count)> StartCallback;
typedef base::Callback<void(int page_number,
float scale_factor,
scoped_ptr<MetafilePlayer> emf)> GetPageCallback;
std::unique_ptr<MetafilePlayer> emf)> GetPageCallback;
virtual ~PdfToEmfConverter();
static scoped_ptr<PdfToEmfConverter> CreateDefault();
static std::unique_ptr<PdfToEmfConverter> CreateDefault();
// Starts conversion of PDF provided as |data|. Calls |start_callback|
// with positive |page_count|. |page_count| is 0 if initialization failed.

View file

@ -133,7 +133,7 @@ void PrintJob::StartPrinting() {
make_scoped_refptr(this),
base::Bind(&PrintJobWorker::StartPrinting,
base::Unretained(worker_.get()),
document_)));
base::RetainedRef(document_))));
// Set the flag right now.
is_job_pending_ = true;
@ -267,7 +267,7 @@ class PrintJob::PdfToEmfState {
int pages_in_progress_;
gfx::Size page_size_;
gfx::Rect content_area_;
scoped_ptr<PdfToEmfConverter> converter_;
std::unique_ptr<PdfToEmfConverter> converter_;
};
void PrintJob::StartPdfToEmfConversion(
@ -296,7 +296,7 @@ void PrintJob::OnPdfToEmfStarted(int page_count) {
void PrintJob::OnPdfToEmfPageConverted(int page_number,
float scale_factor,
scoped_ptr<MetafilePlayer> emf) {
std::unique_ptr<MetafilePlayer> emf) {
DCHECK(ptd_to_emf_state_);
if (!document_.get() || !emf) {
ptd_to_emf_state_.reset();
@ -335,7 +335,7 @@ void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
make_scoped_refptr(this),
base::Bind(&PrintJobWorker::OnDocumentChanged,
base::Unretained(worker_.get()),
document_)));
base::RetainedRef(document_))));
}
}

View file

@ -98,7 +98,7 @@ class PrintJob : public PrintJobWorkerOwner,
void OnPdfToEmfStarted(int page_count);
void OnPdfToEmfPageConverted(int page_number,
float scale_factor,
scoped_ptr<MetafilePlayer> emf);
std::unique_ptr<MetafilePlayer> emf);
#endif // OS_WIN
@ -134,7 +134,7 @@ class PrintJob : public PrintJobWorkerOwner,
// All the UI is done in a worker thread because many Win32 print functions
// are blocking and enters a message loop without your consent. There is one
// worker thread per print job.
scoped_ptr<PrintJobWorker> worker_;
std::unique_ptr<PrintJobWorker> worker_;
// Cache of the print context settings for access in the UI thread.
PrintSettings settings_;
@ -151,7 +151,7 @@ class PrintJob : public PrintJobWorkerOwner,
#if defined(OS_WIN)
class PdfToEmfState;
scoped_ptr<PdfToEmfState> ptd_to_emf_state_;
std::unique_ptr<PdfToEmfState> ptd_to_emf_state_;
#endif // OS_WIN
// Used at shutdown so that we can quit a nested message loop.

View file

@ -146,7 +146,7 @@ void PrintJobWorker::GetSettings(
}
void PrintJobWorker::SetSettings(
scoped_ptr<base::DictionaryValue> new_settings) {
std::unique_ptr<base::DictionaryValue> new_settings) {
DCHECK(task_runner_->RunsTasksOnCurrentThread());
BrowserThread::PostTask(
@ -160,7 +160,7 @@ void PrintJobWorker::SetSettings(
}
void PrintJobWorker::UpdatePrintSettings(
scoped_ptr<base::DictionaryValue> new_settings) {
std::unique_ptr<base::DictionaryValue> new_settings) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
PrintingContext::Result result =
printing_context_->UpdatePrintSettings(*new_settings);
@ -338,11 +338,9 @@ void PrintJobWorker::OnDocumentDone() {
}
owner_->PostTask(FROM_HERE,
base::Bind(&NotificationCallback,
make_scoped_refptr(owner_),
base::Bind(&NotificationCallback, base::RetainedRef(owner_),
JobEventDetails::DOC_DONE,
document_,
scoped_refptr<PrintedPage>()));
base::RetainedRef(document_), nullptr));
// Makes sure the variables are reinitialized.
document_ = NULL;
@ -354,11 +352,9 @@ void PrintJobWorker::SpoolPage(PrintedPage* page) {
// Signal everyone that the page is about to be printed.
owner_->PostTask(FROM_HERE,
base::Bind(&NotificationCallback,
make_scoped_refptr(owner_),
JobEventDetails::NEW_PAGE,
document_,
make_scoped_refptr(page)));
base::Bind(&NotificationCallback, base::RetainedRef(owner_),
JobEventDetails::NEW_PAGE, base::RetainedRef(document_),
base::RetainedRef(page)));
// Preprocess.
if (printing_context_->NewPage() != PrintingContext::OK) {
@ -380,12 +376,11 @@ void PrintJobWorker::SpoolPage(PrintedPage* page) {
}
// Signal everyone that the page is printed.
owner_->PostTask(FROM_HERE,
base::Bind(&NotificationCallback,
make_scoped_refptr(owner_),
JobEventDetails::PAGE_DONE,
document_,
make_scoped_refptr(page)));
owner_->PostTask(
FROM_HERE,
base::Bind(&NotificationCallback, base::RetainedRef(owner_),
JobEventDetails::PAGE_DONE, base::RetainedRef(document_),
base::RetainedRef(page)));
}
void PrintJobWorker::OnFailure() {
@ -394,12 +389,11 @@ void PrintJobWorker::OnFailure() {
// We may loose our last reference by broadcasting the FAILED event.
scoped_refptr<PrintJobWorkerOwner> handle(owner_);
owner_->PostTask(FROM_HERE,
base::Bind(&NotificationCallback,
make_scoped_refptr(owner_),
JobEventDetails::FAILED,
document_,
scoped_refptr<PrintedPage>()));
owner_->PostTask(
FROM_HERE,
base::Bind(&NotificationCallback, base::RetainedRef(owner_),
JobEventDetails::FAILED,
base::RetainedRef(document_), nullptr));
Cancel();
// Makes sure the variables are reinitialized.

View file

@ -48,7 +48,7 @@ class PrintJobWorker {
MarginType margin_type);
// Set the new print settings.
void SetSettings(scoped_ptr<base::DictionaryValue> new_settings);
void SetSettings(std::unique_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.
@ -116,7 +116,7 @@ class PrintJobWorker {
void GetSettingsWithUIDone(PrintingContext::Result result);
// Called on the UI thread to update the print settings.
void UpdatePrintSettings(scoped_ptr<base::DictionaryValue> new_settings);
void UpdatePrintSettings(std::unique_ptr<base::DictionaryValue> new_settings);
// Reports settings back to owner_.
void GetSettingsDone(PrintingContext::Result result);
@ -127,10 +127,10 @@ class PrintJobWorker {
void UseDefaultSettings();
// Printing context delegate.
scoped_ptr<PrintingContext::Delegate> printing_context_delegate_;
std::unique_ptr<PrintingContext::Delegate> printing_context_delegate_;
// Information about the printer setting.
scoped_ptr<PrintingContext> printing_context_;
std::unique_ptr<PrintingContext> printing_context_;
// The printed document. Only has read-only access.
scoped_refptr<PrintedDocument> document_;

View file

@ -43,7 +43,7 @@ void StopWorker(int document_cookie) {
char* CopyPDFDataOnIOThread(
const PrintHostMsg_DidPreviewDocument_Params& params) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
scoped_ptr<base::SharedMemory> shared_buf(
std::unique_ptr<base::SharedMemory> shared_buf(
new base::SharedMemory(params.metafile_data_handle, true));
if (!shared_buf->Map(params.data_size))
return nullptr;

View file

@ -132,7 +132,7 @@ void PrintViewManagerBase::OnDidPrintPage(
}
}
scoped_ptr<PdfMetafileSkia> metafile(new PdfMetafileSkia);
std::unique_ptr<PdfMetafileSkia> metafile(new PdfMetafileSkia);
if (metafile_must_be_valid) {
if (!metafile->InitFromData(shared_buf.memory(), params.data_size)) {
NOTREACHED() << "Invalid metafile header";

View file

@ -85,7 +85,7 @@ void PrinterQuery::GetSettings(
margin_type));
}
void PrinterQuery::SetSettings(scoped_ptr<base::DictionaryValue> new_settings,
void PrinterQuery::SetSettings(std::unique_ptr<base::DictionaryValue> new_settings,
const base::Closure& callback) {
StartWorker(callback);

View file

@ -50,7 +50,7 @@ class PrinterQuery : public PrintJobWorkerOwner {
const base::Closure& callback);
// Updates the current settings with |new_settings| dictionary values.
void SetSettings(scoped_ptr<base::DictionaryValue> new_settings,
void SetSettings(std::unique_ptr<base::DictionaryValue> new_settings,
const base::Closure& callback);
// Stops the worker thread since the client is done with this object.
@ -73,7 +73,7 @@ class PrinterQuery : public PrintJobWorkerOwner {
// All the UI is done in a worker thread because many Win32 print functions
// are blocking and enters a message loop without your consent. There is one
// worker thread per print job.
scoped_ptr<PrintJobWorker> worker_;
std::unique_ptr<PrintJobWorker> worker_;
// Cache of the print context settings for access in the UI thread.
PrintSettings settings_;

View file

@ -373,7 +373,7 @@ 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());
std::unique_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy());
scoped_refptr<PrinterQuery> printer_query;
printer_query = queue_->PopPrinterQuery(document_cookie);