OLD | NEW |
---|---|
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 PRINTING_PRINTED_DOCUMENT_H_ | 5 #ifndef PRINTING_PRINTED_DOCUMENT_H_ |
6 #define PRINTING_PRINTED_DOCUMENT_H_ | 6 #define PRINTING_PRINTED_DOCUMENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
39 PrintedDocument(const PrintSettings& settings, | 39 PrintedDocument(const PrintSettings& settings, |
40 PrintedPagesSource* source, | 40 PrintedPagesSource* source, |
41 int cookie); | 41 int cookie); |
42 | 42 |
43 // Sets a page's data. 0-based. Takes metafile ownership. | 43 // Sets a page's data. 0-based. Takes metafile ownership. |
44 // Note: locks for a short amount of time. | 44 // Note: locks for a short amount of time. |
45 void SetPage(int page_number, Metafile* metafile, double shrink, | 45 void SetPage(int page_number, Metafile* metafile, double shrink, |
46 const gfx::Size& paper_size, const gfx::Rect& page_rect); | 46 const gfx::Size& paper_size, const gfx::Rect& page_rect); |
47 | 47 |
48 // Retrieves a page. If the page is not available right now, it | 48 // Retrieves a page. If the page is not available right now, it |
49 // requests to have this page be rendered and returns false. | 49 // requests to have this page be rendered and returns false. |
Lei Zhang
2014/06/11 20:03:06
update comment
Vitaly Buka (NO REVIEWS)
2014/06/11 21:32:58
Done.
| |
50 // Note: locks for a short amount of time. | 50 // Note: locks for a short amount of time. |
51 bool GetPage(int page_number, scoped_refptr<PrintedPage>* page); | 51 scoped_refptr<PrintedPage> GetPage(int page_number); |
52 | 52 |
53 // Draws the page in the context. | 53 // Draws the page in the context. |
54 // Note: locks for a short amount of time in debug only. | 54 // Note: locks for a short amount of time in debug only. |
55 #if defined(OS_WIN) || defined(OS_MACOSX) && !defined(USE_AURA) | 55 #if defined(OS_WIN) || defined(OS_MACOSX) && !defined(USE_AURA) |
56 void RenderPrintedPage(const PrintedPage& page, | 56 void RenderPrintedPage(const PrintedPage& page, |
57 gfx::NativeDrawingContext context) const; | 57 gfx::NativeDrawingContext context) const; |
58 #elif defined(OS_POSIX) | 58 #elif defined(OS_POSIX) |
59 void RenderPrintedPage(const PrintedPage& page, | 59 void RenderPrintedPage(const PrintedPage& page, |
60 PrintingContext* context) const; | 60 PrintingContext* context) const; |
61 #endif | 61 #endif |
(...skipping 28 matching lines...) Expand all Loading... | |
90 | 90 |
91 // Getters. All these items are immutable hence thread-safe. | 91 // Getters. All these items are immutable hence thread-safe. |
92 const PrintSettings& settings() const { return immutable_.settings_; } | 92 const PrintSettings& settings() const { return immutable_.settings_; } |
93 const base::string16& name() const { return immutable_.name_; } | 93 const base::string16& name() const { return immutable_.name_; } |
94 int cookie() const { return immutable_.cookie_; } | 94 int cookie() const { return immutable_.cookie_; } |
95 | 95 |
96 // Sets a path where to dump printing output files for debugging. If never set | 96 // Sets a path where to dump printing output files for debugging. If never set |
97 // no files are generated. | 97 // no files are generated. |
98 static void set_debug_dump_path(const base::FilePath& debug_dump_path); | 98 static void set_debug_dump_path(const base::FilePath& debug_dump_path); |
99 | 99 |
100 static const base::FilePath& debug_dump_path(); | 100 // Creates debug file name from given |document_name| and |extension|. |
101 // Returns empty |base::FilePath| if |set_debug_dump_path| was not yet called | |
102 // or called with empty value. | |
103 static base::FilePath CreateDebugDumpPath(const base::string16& document_name, | |
104 const std::string& extension); | |
101 | 105 |
102 private: | 106 private: |
103 friend class base::RefCountedThreadSafe<PrintedDocument>; | 107 friend class base::RefCountedThreadSafe<PrintedDocument>; |
104 | 108 |
105 virtual ~PrintedDocument(); | 109 virtual ~PrintedDocument(); |
106 | 110 |
107 // Array of data for each print previewed page. | 111 // Array of data for each print previewed page. |
108 typedef std::map<int, scoped_refptr<PrintedPage> > PrintedPages; | 112 typedef std::map<int, scoped_refptr<PrintedPage> > PrintedPages; |
109 | 113 |
110 // Contains all the mutable stuff. All this stuff MUST be accessed with the | 114 // Contains all the mutable stuff. All this stuff MUST be accessed with the |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 | 157 |
154 // Cookie to uniquely identify this document. It is used to make sure that a | 158 // Cookie to uniquely identify this document. It is used to make sure that a |
155 // PrintedPage is correctly belonging to the PrintedDocument. Since | 159 // PrintedPage is correctly belonging to the PrintedDocument. Since |
156 // PrintedPage generation is completely asynchronous, it could be easy to | 160 // PrintedPage generation is completely asynchronous, it could be easy to |
157 // mess up and send the page to the wrong document. It can be viewed as a | 161 // mess up and send the page to the wrong document. It can be viewed as a |
158 // simpler hash of PrintSettings since a new document is made each time the | 162 // simpler hash of PrintSettings since a new document is made each time the |
159 // print settings change. | 163 // print settings change. |
160 int cookie_; | 164 int cookie_; |
161 }; | 165 }; |
162 | 166 |
167 void DebugDumpSettings(); | |
163 void DebugDump(const PrintedPage& page); | 168 void DebugDump(const PrintedPage& page); |
164 | 169 |
165 // All writable data member access must be guarded by this lock. Needs to be | 170 // All writable data member access must be guarded by this lock. Needs to be |
166 // mutable since it can be acquired from const member functions. | 171 // mutable since it can be acquired from const member functions. |
167 mutable base::Lock lock_; | 172 mutable base::Lock lock_; |
168 | 173 |
169 // All the mutable members. | 174 // All the mutable members. |
170 Mutable mutable_; | 175 Mutable mutable_; |
171 | 176 |
172 // All the immutable members. | 177 // All the immutable members. |
173 const Immutable immutable_; | 178 const Immutable immutable_; |
174 | 179 |
175 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); | 180 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); |
176 }; | 181 }; |
177 | 182 |
178 } // namespace printing | 183 } // namespace printing |
179 | 184 |
180 #endif // PRINTING_PRINTED_DOCUMENT_H_ | 185 #endif // PRINTING_PRINTED_DOCUMENT_H_ |
OLD | NEW |