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

Side by Side Diff: chrome/browser/ui/webui/print_preview_data_source.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: Fix win compile error 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_DATA_SOURCE_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11 #include <utility>
12
13 #include "base/compiler_specific.h"
14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
15
16 template<typename T> struct LeakySingletonTraits;
17
18 class PrintPreviewUI;
19
20 namespace base {
21 class SharedMemory;
22 }
23
24 // PrintPreviewDataSource serves data for chrome://print requests.
25 //
26 // PrintPreviewDataSource owns the data and is responsible for freeing it when
27 // either:
28 // a) there is a new data.
29 // b) When PrintPreviewDataSource is destroyed.
30 //
31 // The format for requesting data is as follows:
32 // chrome://print/print.pdf/<PrintPreviewUIAddrStr>
33 //
34 // Parameters (< > required):
35 // <PrintPreviewUIAddrStr> = Print preview UI identifier.
36 //
37 // Example:
38 // chrome://print/print.pdf/0x7f5470fbe510
Lei Zhang 2011/05/26 01:48:31 That's a weird looking URL. Can we do chrome://pri
kmadhusu 2011/05/26 15:51:22 Done.
39
40 class PrintPreviewDataSource : public ChromeURLDataManager::DataSource {
41 public:
42 // A SharedMemory that contains the data for print preview,
43 // and the size of the print preview data in bytes.
44 typedef std::pair<base::SharedMemory*, uint32> PrintPreviewData;
45
46 typedef std::string PreviewUIAddrStr;
Lei Zhang 2011/05/26 01:48:31 can we not have this typedef and just use std::str
kmadhusu 2011/05/26 15:51:22 Done.
47
48 // 1:1 relationship between PrintPreviewUI and preview data.
49 // Key: Print preview UI address string.
50 // Value: Preview data.
51 typedef std::map<PreviewUIAddrStr, PrintPreviewData> PreviewDataSrcMap;
52
53 PrintPreviewDataSource();
54 virtual ~PrintPreviewDataSource();
55
56 // Getter for the singleton.
57 static PrintPreviewDataSource* GetInstance();
58
59 // Remove the corresponding PrintPreviewUI entry from the map.
60 void RemoveEntry(const PreviewUIAddrStr& preview_ui_addr_str);
Lei Zhang 2011/05/26 01:48:31 nit: Can you put them in a more logical order? Get
kmadhusu 2011/05/26 15:51:22 Done.
61
62 // Set/Update the data entry in PreviewDataSrcMap.
63 void SetDataEntry(const PreviewUIAddrStr& preview_ui_addr_str,
64 const PrintPreviewData& data);
65
66 // Get the data entry from PreviewDataSrcMap.
67 void GetDataEntry(const PreviewUIAddrStr& preview_ui_addr_str,
68 PrintPreviewData* data);
69
70 // ChromeURLDataManager::DataSource implementation.
71 virtual void StartDataRequest(const std::string& path,
72 bool is_incognito,
73 int request_id) OVERRIDE;
74 virtual std::string GetMimeType(const std::string& path) const OVERRIDE;
75
76 private:
77 friend struct LeakySingletonTraits<PrintPreviewDataSource>;
Lei Zhang 2011/05/26 01:48:31 Use DefaultSingletonTraits here. Then you can make
kmadhusu 2011/05/26 15:51:22 Removed the singleton traits.
78
79 PreviewDataSrcMap data_source_map_;
80
81 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataSource);
82 };
83
84 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_DATA_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698