base::Time multiplicative operator overloading
[chromium-blink-merge.git] / chrome / browser / printing / print_preview_data_service.h
blobca2fe83e2a7fd2bfbadafbc6ad6d3bf70bca2316
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
8 #include <map>
9 #include <string>
11 #include "base/memory/ref_counted.h"
13 template<typename T> struct DefaultSingletonTraits;
15 class PrintPreviewDataStore;
17 namespace base {
18 class RefCountedBytes;
21 // PrintPreviewDataService manages data stores for chrome://print requests.
22 // It owns the data store object and is responsible for freeing it.
23 class PrintPreviewDataService {
24 public:
25 static PrintPreviewDataService* GetInstance();
27 // Get the data entry from PrintPreviewDataStore. |index| is zero-based or
28 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete preview
29 // data. Use |index| to retrieve a specific preview page data. |data| is set
30 // to NULL if the requested page is not yet available.
31 void GetDataEntry(int32 preview_ui_id, int index,
32 scoped_refptr<base::RefCountedBytes>* data);
34 // Set/Update the data entry in PrintPreviewDataStore. |index| is zero-based
35 // or |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete
36 // preview data. Use |index| to set/update a specific preview page data.
37 // NOTE: PrintPreviewDataStore owns the data. Do not refcount |data| before
38 // calling this function. It will be refcounted in PrintPreviewDataStore.
39 void SetDataEntry(int32 preview_ui_id, int index,
40 const base::RefCountedBytes* data);
42 // Remove the corresponding PrintPreviewUI entry from the map.
43 void RemoveEntry(int32 preview_ui_id);
45 // Returns the available draft page count.
46 int GetAvailableDraftPageCount(int32 preview_ui_id);
48 private:
49 friend struct DefaultSingletonTraits<PrintPreviewDataService>;
51 // 1:1 relationship between PrintPreviewUI and data store object.
52 // Key: PrintPreviewUI ID.
53 // Value: Print preview data store object.
54 typedef std::map<int32, scoped_refptr<PrintPreviewDataStore> >
55 PreviewDataStoreMap;
57 PrintPreviewDataService();
58 virtual ~PrintPreviewDataService();
60 PreviewDataStoreMap data_store_map_;
62 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService);
65 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_