Chromium Code Reviews| 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 // PrintPreviewDataService manages data for chrome://print requests. | |
| 18 // | |
| 19 // PrintPreviewDataService owns the data and is responsible for freeing it when | |
| 20 // either: | |
| 21 // a) there is a new data. | |
|
Lei Zhang
2011/05/29 00:24:23
nit: There is new data.
kmadhusu
2011/05/29 00:45:40
Done.
| |
| 22 // b) When PrintPreviewDataService is destroyed. | |
| 23 // | |
| 24 class PrintPreviewDataService { | |
| 25 public: | |
| 26 static PrintPreviewDataService* GetInstance(); | |
| 27 | |
| 28 // Get the data entry from PreviewDataSourceMap. | |
| 29 void GetDataEntry(const std::string& preview_ui_addr_str, | |
| 30 scoped_refptr<RefCountedBytes>* data); | |
| 31 | |
| 32 // Set/Update the data entry in PreviewDataSourceMap. | |
| 33 void SetDataEntry(const std::string& preview_ui_addr_str, | |
| 34 const RefCountedBytes* data); | |
| 35 | |
| 36 // Remove the corresponding PrintPreviewUI entry from the map. | |
| 37 void RemoveEntry(const std::string& preview_ui_addr_str); | |
| 38 | |
| 39 private: | |
| 40 friend struct DefaultSingletonTraits<PrintPreviewDataService>; | |
| 41 | |
| 42 // 1:1 relationship between PrintPreviewUI and preview data. | |
| 43 // Key: Print preview UI address string. | |
| 44 // Value: Preview data. | |
| 45 typedef std::map<std::string, scoped_refptr<RefCountedBytes> > | |
| 46 PreviewDataSourceMap; | |
| 47 | |
| 48 PrintPreviewDataService(); | |
| 49 virtual ~PrintPreviewDataService(); | |
| 50 | |
| 51 PreviewDataSourceMap data_src_map_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService); | |
| 54 }; | |
| 55 | |
| 56 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ | |
| OLD | NEW |