summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/printing/print_preview_data_service.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-01-25 11:39:07 +0100
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-01-25 15:20:42 +0000
commit6c91641271e536ffaa88a1dff5127e42ee99a91e (patch)
tree703d9dd49602377ddc90cbf886aad37913f2496b /chromium/chrome/browser/printing/print_preview_data_service.h
parentb145b7fafd36f0c260d6a768c81fc14e32578099 (diff)
BASELINE: Update Chromium to 49.0.2623.23
Also adds missing printing sources. Change-Id: I3726b8f0c7d6751c9fc846096c571fadca7108cd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'chromium/chrome/browser/printing/print_preview_data_service.h')
-rw-r--r--chromium/chrome/browser/printing/print_preview_data_service.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/chromium/chrome/browser/printing/print_preview_data_service.h b/chromium/chrome/browser/printing/print_preview_data_service.h
new file mode 100644
index 00000000000..c5535811d48
--- /dev/null
+++ b/chromium/chrome/browser/printing/print_preview_data_service.h
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
+#define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
+
+#include <stdint.h>
+
+#include <map>
+#include <string>
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+
+class PrintPreviewDataStore;
+
+namespace base {
+template <typename T>
+struct DefaultSingletonTraits;
+class RefCountedBytes;
+}
+
+// PrintPreviewDataService manages data stores for chrome://print requests.
+// It owns the data store object and is responsible for freeing it.
+class PrintPreviewDataService {
+ public:
+ static PrintPreviewDataService* GetInstance();
+
+ // Get the data entry from PrintPreviewDataStore. |index| is zero-based or
+ // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete preview
+ // data. Use |index| to retrieve a specific preview page data. |data| is set
+ // to NULL if the requested page is not yet available.
+ void GetDataEntry(int32_t preview_ui_id, int index,
+ scoped_refptr<base::RefCountedBytes>* data);
+
+ // Set/Update the data entry in PrintPreviewDataStore. |index| is zero-based
+ // or |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete
+ // preview data. Use |index| to set/update a specific preview page data.
+ // NOTE: PrintPreviewDataStore owns the data. Do not refcount |data| before
+ // calling this function. It will be refcounted in PrintPreviewDataStore.
+ void SetDataEntry(int32_t preview_ui_id, int index,
+ const base::RefCountedBytes* data);
+
+ // Remove the corresponding PrintPreviewUI entry from the map.
+ void RemoveEntry(int32_t preview_ui_id);
+
+ // Returns the available draft page count.
+ int GetAvailableDraftPageCount(int32_t preview_ui_id);
+
+ private:
+ friend struct base::DefaultSingletonTraits<PrintPreviewDataService>;
+
+ // 1:1 relationship between PrintPreviewUI and data store object.
+ // Key: PrintPreviewUI ID.
+ // Value: Print preview data store object.
+ using PreviewDataStoreMap =
+ std::map<int32_t, scoped_refptr<PrintPreviewDataStore>>;
+
+ PrintPreviewDataService();
+ virtual ~PrintPreviewDataService();
+
+ PreviewDataStoreMap data_store_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService);
+};
+
+#endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_