| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 | 12 |
| 13 template<typename T> struct DefaultSingletonTraits; | |
| 14 | |
| 15 class PrintPreviewDataStore; | 13 class PrintPreviewDataStore; |
| 16 | 14 |
| 17 namespace base { | 15 namespace base { |
| 16 template <typename T> |
| 17 struct DefaultSingletonTraits; |
| 18 class RefCountedBytes; | 18 class RefCountedBytes; |
| 19 } | 19 } |
| 20 | 20 |
| 21 // PrintPreviewDataService manages data stores for chrome://print requests. | 21 // PrintPreviewDataService manages data stores for chrome://print requests. |
| 22 // It owns the data store object and is responsible for freeing it. | 22 // It owns the data store object and is responsible for freeing it. |
| 23 class PrintPreviewDataService { | 23 class PrintPreviewDataService { |
| 24 public: | 24 public: |
| 25 static PrintPreviewDataService* GetInstance(); | 25 static PrintPreviewDataService* GetInstance(); |
| 26 | 26 |
| 27 // Get the data entry from PrintPreviewDataStore. |index| is zero-based or | 27 // Get the data entry from PrintPreviewDataStore. |index| is zero-based or |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 void SetDataEntry(int32_t preview_ui_id, int index, | 39 void SetDataEntry(int32_t preview_ui_id, int index, |
| 40 const base::RefCountedBytes* data); | 40 const base::RefCountedBytes* data); |
| 41 | 41 |
| 42 // Remove the corresponding PrintPreviewUI entry from the map. | 42 // Remove the corresponding PrintPreviewUI entry from the map. |
| 43 void RemoveEntry(int32_t preview_ui_id); | 43 void RemoveEntry(int32_t preview_ui_id); |
| 44 | 44 |
| 45 // Returns the available draft page count. | 45 // Returns the available draft page count. |
| 46 int GetAvailableDraftPageCount(int32_t preview_ui_id); | 46 int GetAvailableDraftPageCount(int32_t preview_ui_id); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 friend struct DefaultSingletonTraits<PrintPreviewDataService>; | 49 friend struct base::DefaultSingletonTraits<PrintPreviewDataService>; |
| 50 | 50 |
| 51 // 1:1 relationship between PrintPreviewUI and data store object. | 51 // 1:1 relationship between PrintPreviewUI and data store object. |
| 52 // Key: PrintPreviewUI ID. | 52 // Key: PrintPreviewUI ID. |
| 53 // Value: Print preview data store object. | 53 // Value: Print preview data store object. |
| 54 using PreviewDataStoreMap = | 54 using PreviewDataStoreMap = |
| 55 std::map<int32_t, scoped_refptr<PrintPreviewDataStore>>; | 55 std::map<int32_t, scoped_refptr<PrintPreviewDataStore>>; |
| 56 | 56 |
| 57 PrintPreviewDataService(); | 57 PrintPreviewDataService(); |
| 58 virtual ~PrintPreviewDataService(); | 58 virtual ~PrintPreviewDataService(); |
| 59 | 59 |
| 60 PreviewDataStoreMap data_store_map_; | 60 PreviewDataStoreMap data_store_map_; |
| 61 | 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService); | 62 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ | 65 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ |
| OLD | NEW |