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

Unified Diff: chrome/browser/printing/print_preview_data_service.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
Index: chrome/browser/printing/print_preview_data_service.cc
diff --git a/chrome/browser/printing/print_preview_data_service.cc b/chrome/browser/printing/print_preview_data_service.cc
index 53b068cc89f85debec1724b5f5ddbcb5e6103e69..ab8169504eaa5233a207a4ec1cca8b47646d67ad 100644
--- a/chrome/browser/printing/print_preview_data_service.cc
+++ b/chrome/browser/printing/print_preview_data_service.cc
@@ -41,11 +41,12 @@ class PrintPreviewDataStore : public base::RefCounted<PrintPreviewDataStore> {
}
// Set/Update the preview data entry for the specified |index|.
- void SetPreviewDataForIndex(int index, const base::RefCountedBytes* data) {
+ void SetPreviewDataForIndex(int index,
+ scoped_refptr<base::RefCountedBytes> data) {
if (IsInvalidIndex(index))
return;
- page_data_map_[index] = const_cast<base::RefCountedBytes*>(data);
+ page_data_map_[index] = std::move(data);
}
// Returns the available draft page count.
@@ -103,11 +104,14 @@ void PrintPreviewDataService::GetDataEntry(
void PrintPreviewDataService::SetDataEntry(
int32_t preview_ui_id,
int index,
- const base::RefCountedBytes* data_bytes) {
- if (!ContainsKey(data_store_map_, preview_ui_id))
- data_store_map_[preview_ui_id] = new PrintPreviewDataStore();
+ scoped_refptr<base::RefCountedBytes> data_bytes) {
+ if (!ContainsKey(data_store_map_, preview_ui_id)) {
+ data_store_map_[preview_ui_id] =
+ make_scoped_refptr(new PrintPreviewDataStore());
+ }
- data_store_map_[preview_ui_id]->SetPreviewDataForIndex(index, data_bytes);
+ data_store_map_[preview_ui_id]->SetPreviewDataForIndex(index,
+ std::move(data_bytes));
}
void PrintPreviewDataService::RemoveEntry(int32_t preview_ui_id) {
« no previous file with comments | « chrome/browser/printing/print_preview_data_service.h ('k') | chrome/browser/printing/print_preview_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698