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_UI_WEBUI_PRINT_PREVIEW_DATA_MANAGER_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_DATA_MANAGER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <map> | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 | |
| 14 class PrintPreviewUI; | |
| 15 | |
| 16 namespace base { | |
| 17 class SharedMemory; | |
| 18 } | |
| 19 | |
| 20 // PrintPreviewDataManager manages data for chrome://print requests. | |
| 21 // | |
| 22 // PrintPreviewDataManager owns the data and is responsible for freeing it when | |
| 23 // either: | |
| 24 // a) there is a new data. | |
| 25 // b) When PrintPreviewDataManager is destroyed. | |
| 26 // | |
| 27 | |
| 28 class PrintPreviewDataManager | |
| 29 : public base::RefCounted<PrintPreviewDataManager> { | |
|
sky
2011/05/26 17:40:41
Does this class really need to be refcounted?
kmadhusu
2011/05/27 16:49:22
No. Fixed the code.
| |
| 30 public: | |
| 31 // A SharedMemory that contains the data for print preview, | |
| 32 // and the size of the print preview data in bytes. | |
| 33 typedef std::pair<base::SharedMemory*, uint32> PrintPreviewData; | |
| 34 | |
| 35 // 1:1 relationship between PrintPreviewUI and preview data. | |
| 36 // Key: Print preview UI address string. | |
| 37 // Value: Preview data. | |
| 38 typedef std::map<std::string, PrintPreviewData> PreviewDataSrcMap; | |
| 39 | |
| 40 PrintPreviewDataManager(); | |
| 41 | |
| 42 // Get the data entry from PreviewDataSrcMap. | |
| 43 void GetDataEntry(const std::string& preview_ui_addr_str, | |
| 44 PrintPreviewData* data); | |
| 45 | |
| 46 // Set/Update the data entry in PreviewDataSrcMap. | |
| 47 void SetDataEntry(const std::string& preview_ui_addr_str, | |
| 48 const PrintPreviewData& data); | |
| 49 | |
| 50 // Remove the corresponding PrintPreviewUI entry from the map. | |
| 51 void RemoveEntry(const std::string& preview_ui_addr_str); | |
| 52 | |
| 53 private: | |
| 54 friend class base::RefCounted<PrintPreviewDataManager>; | |
| 55 | |
| 56 virtual ~PrintPreviewDataManager(); | |
| 57 | |
| 58 PreviewDataSrcMap data_source_map_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataManager); | |
| 61 }; | |
| 62 | |
| 63 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_DATA_MANAGER_H_ | |
| OLD | NEW |