OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ |
6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 21 matching lines...) Expand all Loading... |
32 // data. Use |index| to retrieve a specific preview page data. |data| is set | 32 // data. Use |index| to retrieve a specific preview page data. |data| is set |
33 // to NULL if the requested page is not yet available. | 33 // to NULL if the requested page is not yet available. |
34 void GetDataEntry(int32_t preview_ui_id, int index, | 34 void GetDataEntry(int32_t preview_ui_id, int index, |
35 scoped_refptr<base::RefCountedBytes>* data); | 35 scoped_refptr<base::RefCountedBytes>* data); |
36 | 36 |
37 // Set/Update the data entry in PrintPreviewDataStore. |index| is zero-based | 37 // Set/Update the data entry in PrintPreviewDataStore. |index| is zero-based |
38 // or |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete | 38 // or |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete |
39 // preview data. Use |index| to set/update a specific preview page data. | 39 // preview data. Use |index| to set/update a specific preview page data. |
40 // NOTE: PrintPreviewDataStore owns the data. Do not refcount |data| before | 40 // NOTE: PrintPreviewDataStore owns the data. Do not refcount |data| before |
41 // calling this function. It will be refcounted in PrintPreviewDataStore. | 41 // calling this function. It will be refcounted in PrintPreviewDataStore. |
42 void SetDataEntry(int32_t preview_ui_id, int index, | 42 void SetDataEntry(int32_t preview_ui_id, |
43 const base::RefCountedBytes* data); | 43 int index, |
| 44 scoped_refptr<base::RefCountedBytes> data); |
44 | 45 |
45 // Remove the corresponding PrintPreviewUI entry from the map. | 46 // Remove the corresponding PrintPreviewUI entry from the map. |
46 void RemoveEntry(int32_t preview_ui_id); | 47 void RemoveEntry(int32_t preview_ui_id); |
47 | 48 |
48 // Returns the available draft page count. | 49 // Returns the available draft page count. |
49 int GetAvailableDraftPageCount(int32_t preview_ui_id); | 50 int GetAvailableDraftPageCount(int32_t preview_ui_id); |
50 | 51 |
51 private: | 52 private: |
52 friend struct base::DefaultSingletonTraits<PrintPreviewDataService>; | 53 friend struct base::DefaultSingletonTraits<PrintPreviewDataService>; |
53 | 54 |
54 // 1:1 relationship between PrintPreviewUI and data store object. | 55 // 1:1 relationship between PrintPreviewUI and data store object. |
55 // Key: PrintPreviewUI ID. | 56 // Key: PrintPreviewUI ID. |
56 // Value: Print preview data store object. | 57 // Value: Print preview data store object. |
57 using PreviewDataStoreMap = | 58 using PreviewDataStoreMap = |
58 std::map<int32_t, scoped_refptr<PrintPreviewDataStore>>; | 59 std::map<int32_t, scoped_refptr<PrintPreviewDataStore>>; |
59 | 60 |
60 PrintPreviewDataService(); | 61 PrintPreviewDataService(); |
61 virtual ~PrintPreviewDataService(); | 62 virtual ~PrintPreviewDataService(); |
62 | 63 |
63 PreviewDataStoreMap data_store_map_; | 64 PreviewDataStoreMap data_store_map_; |
64 | 65 |
65 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService); | 66 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService); |
66 }; | 67 }; |
67 | 68 |
68 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ | 69 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ |
OLD | NEW |