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

Unified Diff: chrome/browser/printing/print_preview_data_service.h

Issue 7082032: Preview tab data source. (Sample CL) (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
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_data_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/print_preview_data_service.h
diff --git a/chrome/browser/printing/print_preview_data_service.h b/chrome/browser/printing/print_preview_data_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..e2e0ff7f1e86f54086cfbdfb57ac76cb28e6d346
--- /dev/null
+++ b/chrome/browser/printing/print_preview_data_service.h
@@ -0,0 +1,58 @@
+// 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_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
+#define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
+#pragma once
+
+#include <map>
+#include <string>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/ref_counted_memory.h"
+
+template<typename T> struct DefaultSingletonTraits;
+
+class PrintPreviewUI;
+
+// PrintPreviewDataService manages data for chrome://print requests.
+//
+// PrintPreviewDataService owns the data and is responsible for freeing it when
+// either:
+// a) There is a new data.
+// b) When PrintPreviewDataService is destroyed.
+//
+class PrintPreviewDataService {
+ public:
+ static PrintPreviewDataService* GetInstance();
+
+ // Get the data entry from PreviewDataSourceMap.
+ void GetDataEntry(PrintPreviewUI* preview_ui,
+ scoped_refptr<RefCountedBytes>* data);
+
+ // Set/Update the data entry in PreviewDataSourceMap.
+ void SetDataEntry(PrintPreviewUI* preview_ui,
+ const RefCountedBytes* data);
+
+ // Remove the corresponding PrintPreviewUI entry from the map.
+ void RemoveEntry(PrintPreviewUI* preview_ui);
+
+ private:
+ friend struct DefaultSingletonTraits<PrintPreviewDataService>;
+
+ // 1:1 relationship between PrintPreviewUI* and preview data.
+ // Key: Print preview UI address.
+ // Value: Preview data.
+ typedef std::map<PrintPreviewUI*, scoped_refptr<RefCountedBytes> >
+ PreviewDataSourceMap;
+
+ PrintPreviewDataService();
+ virtual ~PrintPreviewDataService();
+
+ PreviewDataSourceMap data_src_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService);
+};
+
+#endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_data_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698