OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ |
| 6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 #include <string> |
| 11 |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/ref_counted_memory.h" |
| 14 |
| 15 template<typename T> struct DefaultSingletonTraits; |
| 16 |
| 17 class PrintPreviewUI; |
| 18 |
| 19 // PrintPreviewDataService manages data for chrome://print requests. |
| 20 // |
| 21 // PrintPreviewDataService owns the data and is responsible for freeing it when |
| 22 // either: |
| 23 // a) There is a new data. |
| 24 // b) When PrintPreviewDataService is destroyed. |
| 25 // |
| 26 class PrintPreviewDataService { |
| 27 public: |
| 28 static PrintPreviewDataService* GetInstance(); |
| 29 |
| 30 // Get the data entry from PreviewDataSourceMap. |
| 31 void GetDataEntry(PrintPreviewUI* preview_ui, |
| 32 scoped_refptr<RefCountedBytes>* data); |
| 33 |
| 34 // Set/Update the data entry in PreviewDataSourceMap. |
| 35 void SetDataEntry(PrintPreviewUI* preview_ui, |
| 36 const RefCountedBytes* data); |
| 37 |
| 38 // Remove the corresponding PrintPreviewUI entry from the map. |
| 39 void RemoveEntry(PrintPreviewUI* preview_ui); |
| 40 |
| 41 private: |
| 42 friend struct DefaultSingletonTraits<PrintPreviewDataService>; |
| 43 |
| 44 // 1:1 relationship between PrintPreviewUI* and preview data. |
| 45 // Key: Print preview UI address. |
| 46 // Value: Preview data. |
| 47 typedef std::map<PrintPreviewUI*, scoped_refptr<RefCountedBytes> > |
| 48 PreviewDataSourceMap; |
| 49 |
| 50 PrintPreviewDataService(); |
| 51 virtual ~PrintPreviewDataService(); |
| 52 |
| 53 PreviewDataSourceMap data_src_map_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService); |
| 56 }; |
| 57 |
| 58 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ |
OLD | NEW |