OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/lock.h" | 10 #include "base/lock.h" |
11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/string16.h" |
13 #include "gfx/native_widget_types.h" | 14 #include "gfx/native_widget_types.h" |
14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
15 #include "printing/print_settings.h" | 16 #include "printing/print_settings.h" |
16 #include "printing/native_metafile.h" | 17 #include "printing/native_metafile.h" |
17 | 18 |
| 19 class FilePath; |
18 class MessageLoop; | 20 class MessageLoop; |
19 | 21 |
20 namespace gfx { | 22 namespace gfx { |
21 class Font; | 23 class Font; |
22 } | 24 } |
23 | 25 |
24 namespace printing { | 26 namespace printing { |
25 | 27 |
26 class PrintedPage; | 28 class PrintedPage; |
27 class PrintedPagesSource; | 29 class PrintedPagesSource; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 int page_count() const; | 87 int page_count() const; |
86 | 88 |
87 // Returns the number of expected pages to be rendered. It is a non-linear | 89 // Returns the number of expected pages to be rendered. It is a non-linear |
88 // series if settings().ranges is not empty. It is the same value as | 90 // series if settings().ranges is not empty. It is the same value as |
89 // document_page_count() otherwise. | 91 // document_page_count() otherwise. |
90 // Note: locks for a short amount of time. | 92 // Note: locks for a short amount of time. |
91 int expected_page_count() const; | 93 int expected_page_count() const; |
92 | 94 |
93 // Getters. All these items are immutable hence thread-safe. | 95 // Getters. All these items are immutable hence thread-safe. |
94 const PrintSettings& settings() const { return immutable_.settings_; } | 96 const PrintSettings& settings() const { return immutable_.settings_; } |
95 const std::wstring& name() const { | 97 const string16& name() const { |
96 return immutable_.name_; | 98 return immutable_.name_; |
97 } | 99 } |
98 const GURL& url() const { return immutable_.url_; } | 100 const GURL& url() const { return immutable_.url_; } |
99 const std::wstring& date() const { return immutable_.date_; } | 101 const string16& date() const { return immutable_.date_; } |
100 const std::wstring& time() const { return immutable_.time_; } | 102 const string16& time() const { return immutable_.time_; } |
101 int cookie() const { return immutable_.cookie_; } | 103 int cookie() const { return immutable_.cookie_; } |
102 | 104 |
103 // Sets a path where to dump printing output files for debugging. If never set | 105 // Sets a path where to dump printing output files for debugging. If never set |
104 // no files are generated. | 106 // no files are generated. |
105 static void set_debug_dump_path(const std::wstring& debug_dump_path); | 107 static void set_debug_dump_path(const FilePath& debug_dump_path); |
106 | 108 |
107 static const std::wstring& debug_dump_path(); | 109 static const FilePath& debug_dump_path(); |
108 | 110 |
109 private: | 111 private: |
110 friend class base::RefCountedThreadSafe<PrintedDocument>; | 112 friend class base::RefCountedThreadSafe<PrintedDocument>; |
111 | 113 |
112 ~PrintedDocument(); | 114 ~PrintedDocument(); |
113 | 115 |
114 // Array of data for each print previewed page. | 116 // Array of data for each print previewed page. |
115 typedef std::map<int, scoped_refptr<PrintedPage> > PrintedPages; | 117 typedef std::map<int, scoped_refptr<PrintedPage> > PrintedPages; |
116 | 118 |
117 // Contains all the mutable stuff. All this stuff MUST be accessed with the | 119 // Contains all the mutable stuff. All this stuff MUST be accessed with the |
(...skipping 27 matching lines...) Expand all Loading... |
145 Immutable(const PrintSettings& settings, PrintedPagesSource* source, | 147 Immutable(const PrintSettings& settings, PrintedPagesSource* source, |
146 int cookie); | 148 int cookie); |
147 | 149 |
148 // Print settings used to generate this document. Immutable. | 150 // Print settings used to generate this document. Immutable. |
149 PrintSettings settings_; | 151 PrintSettings settings_; |
150 | 152 |
151 // Native thread for the render source. | 153 // Native thread for the render source. |
152 MessageLoop* source_message_loop_; | 154 MessageLoop* source_message_loop_; |
153 | 155 |
154 // Document name. Immutable. | 156 // Document name. Immutable. |
155 std::wstring name_; | 157 string16 name_; |
156 | 158 |
157 // URL that generated this document. Immutable. | 159 // URL that generated this document. Immutable. |
158 GURL url_; | 160 GURL url_; |
159 | 161 |
160 // The date on which this job started. Immutable. | 162 // The date on which this job started. Immutable. |
161 std::wstring date_; | 163 string16 date_; |
162 | 164 |
163 // The time at which this job started. Immutable. | 165 // The time at which this job started. Immutable. |
164 std::wstring time_; | 166 string16 time_; |
165 | 167 |
166 // Cookie to uniquely identify this document. It is used to make sure that a | 168 // Cookie to uniquely identify this document. It is used to make sure that a |
167 // PrintedPage is correctly belonging to the PrintedDocument. Since | 169 // PrintedPage is correctly belonging to the PrintedDocument. Since |
168 // PrintedPage generation is completely asynchronous, it could be easy to | 170 // PrintedPage generation is completely asynchronous, it could be easy to |
169 // mess up and send the page to the wrong document. It can be viewed as a | 171 // mess up and send the page to the wrong document. It can be viewed as a |
170 // simpler hash of PrintSettings since a new document is made each time the | 172 // simpler hash of PrintSettings since a new document is made each time the |
171 // print settings change. | 173 // print settings change. |
172 int cookie_; | 174 int cookie_; |
173 }; | 175 }; |
174 | 176 |
(...skipping 16 matching lines...) Expand all Loading... |
191 | 193 |
192 // All the immutable members. | 194 // All the immutable members. |
193 const Immutable immutable_; | 195 const Immutable immutable_; |
194 | 196 |
195 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); | 197 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); |
196 }; | 198 }; |
197 | 199 |
198 } // namespace printing | 200 } // namespace printing |
199 | 201 |
200 #endif // PRINTING_PRINTED_DOCUMENT_H_ | 202 #endif // PRINTING_PRINTED_DOCUMENT_H_ |
OLD | NEW |