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

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

Issue 2828693006: Use unique_ptrs in PrintPreviewDataService. (Closed)
Patch Set: Created 3 years, 8 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.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1dd26be780b6aaba64edefefc667ebd860e7e826..0b40be8c036d088d2505d62323a44a41329fca2d 100644
--- a/chrome/browser/printing/print_preview_data_service.cc
+++ b/chrome/browser/printing/print_preview_data_service.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/printing/print_preview_data_service.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/singleton.h"
#include "base/stl_util.h"
@@ -25,9 +26,10 @@
// a) There is a new data.
// b) When PrintPreviewDataStore is destroyed.
//
-class PrintPreviewDataStore : public base::RefCounted<PrintPreviewDataStore> {
+class PrintPreviewDataStore {
public:
PrintPreviewDataStore() {}
+ ~PrintPreviewDataStore() {}
// Get the preview page for the specified |index|.
void GetPreviewDataForIndex(
@@ -60,8 +62,6 @@ class PrintPreviewDataStore : public base::RefCounted<PrintPreviewDataStore> {
}
private:
- friend class base::RefCounted<PrintPreviewDataStore>;
-
// 1:1 relationship between page index and its associated preview data.
// Key: Page index is zero-based and can be
// |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete preview
@@ -70,8 +70,6 @@ class PrintPreviewDataStore : public base::RefCounted<PrintPreviewDataStore> {
using PreviewPageDataMap =
std::map<int, scoped_refptr<base::RefCountedBytes>>;
- ~PrintPreviewDataStore() {}
-
static bool IsInvalidIndex(int index) {
return (index != printing::COMPLETE_PREVIEW_DOCUMENT_INDEX &&
index < printing::FIRST_PAGE_INDEX);
@@ -107,11 +105,8 @@ void PrintPreviewDataService::SetDataEntry(
int32_t preview_ui_id,
int index,
scoped_refptr<base::RefCountedBytes> data_bytes) {
- if (!base::ContainsKey(data_store_map_, preview_ui_id)) {
- data_store_map_[preview_ui_id] =
- make_scoped_refptr(new PrintPreviewDataStore());
- }
-
+ if (!base::ContainsKey(data_store_map_, preview_ui_id))
+ data_store_map_[preview_ui_id] = base::MakeUnique<PrintPreviewDataStore>();
data_store_map_[preview_ui_id]->SetPreviewDataForIndex(index,
std::move(data_bytes));
}
« no previous file with comments | « chrome/browser/printing/print_preview_data_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698