Chromium Code Reviews| Index: chrome/browser/ui/webui/print_preview_data_manager.h |
| diff --git a/chrome/browser/ui/webui/print_preview_data_manager.h b/chrome/browser/ui/webui/print_preview_data_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d9a78bf47d3f7baa2188a54b5d84f201e524595a |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/print_preview_data_manager.h |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_DATA_MANAGER_H_ |
| +#define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_DATA_MANAGER_H_ |
| +#pragma once |
| + |
| +#include <map> |
| +#include <string> |
| + |
| +#include "base/memory/ref_counted.h" |
| + |
| +class PrintPreviewUI; |
| + |
| +namespace base { |
| +class SharedMemory; |
| +} |
| + |
| +// PrintPreviewDataManager manages data for chrome://print requests. |
| +// |
| +// PrintPreviewDataManager owns the data and is responsible for freeing it when |
| +// either: |
| +// a) there is a new data. |
| +// b) When PrintPreviewDataManager is destroyed. |
| +// |
| + |
| +class PrintPreviewDataManager |
| + : 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.
|
| + public: |
| + // A SharedMemory that contains the data for print preview, |
| + // and the size of the print preview data in bytes. |
| + typedef std::pair<base::SharedMemory*, uint32> PrintPreviewData; |
| + |
| + // 1:1 relationship between PrintPreviewUI and preview data. |
| + // Key: Print preview UI address string. |
| + // Value: Preview data. |
| + typedef std::map<std::string, PrintPreviewData> PreviewDataSrcMap; |
| + |
| + PrintPreviewDataManager(); |
| + |
| + // Get the data entry from PreviewDataSrcMap. |
| + void GetDataEntry(const std::string& preview_ui_addr_str, |
| + PrintPreviewData* data); |
| + |
| + // Set/Update the data entry in PreviewDataSrcMap. |
| + void SetDataEntry(const std::string& preview_ui_addr_str, |
| + const PrintPreviewData& data); |
| + |
| + // Remove the corresponding PrintPreviewUI entry from the map. |
| + void RemoveEntry(const std::string& preview_ui_addr_str); |
| + |
| + private: |
| + friend class base::RefCounted<PrintPreviewDataManager>; |
| + |
| + virtual ~PrintPreviewDataManager(); |
| + |
| + PreviewDataSrcMap data_source_map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataManager); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_DATA_MANAGER_H_ |