Chromium Code Reviews| 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..487ac9c3c77f2770bdfb74d94a95cd3e9c650597 |
| --- /dev/null |
| +++ b/chrome/browser/printing/print_preview_data_service.h |
| @@ -0,0 +1,54 @@ |
| +// 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" |
| +#include "chrome/browser/profiles/profile_keyed_service.h" |
| + |
| +// 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 ProfileKeyedService { |
| + public: |
| + // Get the data entry from PreviewDataSrcMap. |
|
Lei Zhang
2011/05/28 00:12:38
nit: s/Src/Source/ here and below.
kmadhusu
2011/05/29 00:04:26
Done.
|
| + void GetDataEntry(const std::string& preview_ui_addr_str, |
| + scoped_refptr<RefCountedBytes>* data); |
| + |
| + // Set/Update the data entry in PreviewDataSrcMap. |
| + void SetDataEntry(const std::string& preview_ui_addr_str, |
| + const RefCountedBytes* data); |
| + |
| + // Remove the corresponding PrintPreviewUI entry from the map. |
| + void RemoveEntry(const std::string& preview_ui_addr_str); |
| + |
| + private: |
| + // 1:1 relationship between PrintPreviewUI and preview data. |
| + // Key: Print preview UI address string. |
| + // Value: Preview data. |
| + typedef std::map<std::string, scoped_refptr<RefCountedBytes> > |
| + PreviewDataSourceMap; |
| + |
| + friend class PrintPreviewDataServiceFactory; |
| + friend class TestingProfile; |
| + |
| + PrintPreviewDataService(); |
| + virtual ~PrintPreviewDataService(); |
| + |
| + PreviewDataSourceMap data_src_map_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ |