Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1789)

Unified Diff: chrome/browser/ui/webui/print_preview_data_manager.h

Issue 7063030: PrintPreview: Print Preview is not staying associated with initiator renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698