Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Unified Diff: chrome/browser/printing/print_preview_message_handler.cc

Issue 1803263002: base: Make RefCountedBytes::TakeVector return ref ptr instead of raw ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/printing/print_preview_data_service.cc ('k') | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/print_preview_message_handler.cc
diff --git a/chrome/browser/printing/print_preview_message_handler.cc b/chrome/browser/printing/print_preview_message_handler.cc
index 5b6c457132e0ade14e23b67badfd1c32d67f945a..14181965204dc8f357b54b8ec169776209769072 100644
--- a/chrome/browser/printing/print_preview_message_handler.cc
+++ b/chrome/browser/printing/print_preview_message_handler.cc
@@ -49,8 +49,9 @@ void StopWorker(int document_cookie) {
}
}
-base::RefCountedBytes* GetDataFromHandle(base::SharedMemoryHandle handle,
- uint32_t data_size) {
+scoped_refptr<base::RefCountedBytes> GetDataFromHandle(
+ base::SharedMemoryHandle handle,
+ uint32_t data_size) {
scoped_ptr<base::SharedMemory> shared_buf(
new base::SharedMemory(handle, true));
if (!shared_buf->Map(data_size)) {
@@ -124,11 +125,12 @@ void PrintPreviewMessageHandler::OnDidPreviewPage(
if (!print_preview_ui)
return;
- base::RefCountedBytes* data_bytes =
+ scoped_refptr<base::RefCountedBytes> data_bytes =
GetDataFromHandle(params.metafile_data_handle, params.data_size);
DCHECK(data_bytes);
- print_preview_ui->SetPrintPreviewDataForIndex(page_number, data_bytes);
+ print_preview_ui->SetPrintPreviewDataForIndex(page_number,
+ std::move(data_bytes));
print_preview_ui->OnDidPreviewPage(page_number, params.preview_request_id);
}
@@ -149,13 +151,13 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
// TODO(joth): This seems like a good match for using RefCountedStaticMemory
// to avoid the memory copy, but the SetPrintPreviewData call chain below
// needs updating to accept the RefCountedMemory* base class.
- base::RefCountedBytes* data_bytes =
+ scoped_refptr<base::RefCountedBytes> data_bytes =
GetDataFromHandle(params.metafile_data_handle, params.data_size);
if (!data_bytes || !data_bytes->size())
return;
print_preview_ui->SetPrintPreviewDataForIndex(COMPLETE_PREVIEW_DOCUMENT_INDEX,
- data_bytes);
+ std::move(data_bytes));
print_preview_ui->OnPreviewDataIsAvailable(
params.expected_pages_count, params.preview_request_id);
}
« no previous file with comments | « chrome/browser/printing/print_preview_data_service.cc ('k') | chrome/browser/themes/browser_theme_pack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698