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

Side by Side Diff: chrome/browser/printing/print_preview_data_service.h

Issue 10873097: Merge 153342 - Print preview: Use an ID instead of memory pointer string in WebUI. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1229/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_data_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ 6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 10 matching lines...) Expand all
21 // PrintPreviewDataService manages data stores for chrome://print requests. 21 // PrintPreviewDataService manages data stores for chrome://print requests.
22 // It owns the data store object and is responsible for freeing it. 22 // It owns the data store object and is responsible for freeing it.
23 class PrintPreviewDataService { 23 class PrintPreviewDataService {
24 public: 24 public:
25 static PrintPreviewDataService* GetInstance(); 25 static PrintPreviewDataService* GetInstance();
26 26
27 // Get the data entry from PrintPreviewDataStore. |index| is zero-based or 27 // Get the data entry from PrintPreviewDataStore. |index| is zero-based or
28 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete preview 28 // |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete preview
29 // data. Use |index| to retrieve a specific preview page data. |data| is set 29 // data. Use |index| to retrieve a specific preview page data. |data| is set
30 // to NULL if the requested page is not yet available. 30 // to NULL if the requested page is not yet available.
31 void GetDataEntry(const std::string& preview_ui_addr_str, int index, 31 void GetDataEntry(int32 preview_ui_id, int index,
32 scoped_refptr<base::RefCountedBytes>* data); 32 scoped_refptr<base::RefCountedBytes>* data);
33 33
34 // Set/Update the data entry in PrintPreviewDataStore. |index| is zero-based 34 // Set/Update the data entry in PrintPreviewDataStore. |index| is zero-based
35 // or |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete 35 // or |printing::COMPLETE_PREVIEW_DOCUMENT_INDEX| to represent complete
36 // preview data. Use |index| to set/update a specific preview page data. 36 // preview data. Use |index| to set/update a specific preview page data.
37 // NOTE: PrintPreviewDataStore owns the data. Do not refcount |data| before 37 // NOTE: PrintPreviewDataStore owns the data. Do not refcount |data| before
38 // calling this function. It will be refcounted in PrintPreviewDataStore. 38 // calling this function. It will be refcounted in PrintPreviewDataStore.
39 void SetDataEntry(const std::string& preview_ui_addr_str, int index, 39 void SetDataEntry(int32 preview_ui_id, int index,
40 const base::RefCountedBytes* data); 40 const base::RefCountedBytes* data);
41 41
42 // Remove the corresponding PrintPreviewUI entry from the map. 42 // Remove the corresponding PrintPreviewUI entry from the map.
43 void RemoveEntry(const std::string& preview_ui_addr_str); 43 void RemoveEntry(int32 preview_ui_id);
44 44
45 // Returns the available draft page count. 45 // Returns the available draft page count.
46 int GetAvailableDraftPageCount(const std::string& preview_ui_addr_str); 46 int GetAvailableDraftPageCount(int32 preview_ui_id);
47 47
48 private: 48 private:
49 friend struct DefaultSingletonTraits<PrintPreviewDataService>; 49 friend struct DefaultSingletonTraits<PrintPreviewDataService>;
50 50
51 // 1:1 relationship between PrintPreviewUI and data store object. 51 // 1:1 relationship between PrintPreviewUI and data store object.
52 // Key: Print preview UI address string. 52 // Key: PrintPreviewUI ID.
53 // Value: Print preview data store object. 53 // Value: Print preview data store object.
54 typedef std::map<std::string, scoped_refptr<PrintPreviewDataStore> > 54 typedef std::map<int32, scoped_refptr<PrintPreviewDataStore> >
55 PreviewDataStoreMap; 55 PreviewDataStoreMap;
56 56
57 PrintPreviewDataService(); 57 PrintPreviewDataService();
58 virtual ~PrintPreviewDataService(); 58 virtual ~PrintPreviewDataService();
59 59
60 PreviewDataStoreMap data_store_map_; 60 PreviewDataStoreMap data_store_map_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService); 62 DISALLOW_COPY_AND_ASSIGN(PrintPreviewDataService);
63 }; 63 };
64 64
65 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_ 65 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DATA_SERVICE_H_
OLDNEW
« 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