| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "googleurl/src/gurl.h" | |
| 15 #include "printing/print_settings.h" | 14 #include "printing/print_settings.h" |
| 16 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
| 17 | 16 |
| 18 class FilePath; | 17 class FilePath; |
| 19 class MessageLoop; | 18 class MessageLoop; |
| 20 | 19 |
| 21 namespace gfx { | 20 namespace gfx { |
| 22 class Font; | 21 class Font; |
| 23 } | 22 } |
| 24 | 23 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 int page_count() const; | 86 int page_count() const; |
| 88 | 87 |
| 89 // Returns the number of expected pages to be rendered. It is a non-linear | 88 // Returns the number of expected pages to be rendered. It is a non-linear |
| 90 // series if settings().ranges is not empty. It is the same value as | 89 // series if settings().ranges is not empty. It is the same value as |
| 91 // document_page_count() otherwise. | 90 // document_page_count() otherwise. |
| 92 // Note: locks for a short amount of time. | 91 // Note: locks for a short amount of time. |
| 93 int expected_page_count() const; | 92 int expected_page_count() const; |
| 94 | 93 |
| 95 // Getters. All these items are immutable hence thread-safe. | 94 // Getters. All these items are immutable hence thread-safe. |
| 96 const PrintSettings& settings() const { return immutable_.settings_; } | 95 const PrintSettings& settings() const { return immutable_.settings_; } |
| 97 const string16& name() const { | 96 const string16& name() const { return immutable_.name_; } |
| 98 return immutable_.name_; | |
| 99 } | |
| 100 const GURL& url() const { return immutable_.url_; } | |
| 101 int cookie() const { return immutable_.cookie_; } | 97 int cookie() const { return immutable_.cookie_; } |
| 102 | 98 |
| 103 // Sets a path where to dump printing output files for debugging. If never set | 99 // Sets a path where to dump printing output files for debugging. If never set |
| 104 // no files are generated. | 100 // no files are generated. |
| 105 static void set_debug_dump_path(const FilePath& debug_dump_path); | 101 static void set_debug_dump_path(const FilePath& debug_dump_path); |
| 106 | 102 |
| 107 static const FilePath& debug_dump_path(); | 103 static const FilePath& debug_dump_path(); |
| 108 | 104 |
| 109 private: | 105 private: |
| 110 friend class base::RefCountedThreadSafe<PrintedDocument>; | 106 friend class base::RefCountedThreadSafe<PrintedDocument>; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 150 |
| 155 // Print settings used to generate this document. Immutable. | 151 // Print settings used to generate this document. Immutable. |
| 156 PrintSettings settings_; | 152 PrintSettings settings_; |
| 157 | 153 |
| 158 // Native thread for the render source. | 154 // Native thread for the render source. |
| 159 MessageLoop* source_message_loop_; | 155 MessageLoop* source_message_loop_; |
| 160 | 156 |
| 161 // Document name. Immutable. | 157 // Document name. Immutable. |
| 162 string16 name_; | 158 string16 name_; |
| 163 | 159 |
| 164 // URL that generated this document. Immutable. | |
| 165 GURL url_; | |
| 166 | |
| 167 // Cookie to uniquely identify this document. It is used to make sure that a | 160 // Cookie to uniquely identify this document. It is used to make sure that a |
| 168 // PrintedPage is correctly belonging to the PrintedDocument. Since | 161 // PrintedPage is correctly belonging to the PrintedDocument. Since |
| 169 // PrintedPage generation is completely asynchronous, it could be easy to | 162 // PrintedPage generation is completely asynchronous, it could be easy to |
| 170 // mess up and send the page to the wrong document. It can be viewed as a | 163 // mess up and send the page to the wrong document. It can be viewed as a |
| 171 // simpler hash of PrintSettings since a new document is made each time the | 164 // simpler hash of PrintSettings since a new document is made each time the |
| 172 // print settings change. | 165 // print settings change. |
| 173 int cookie_; | 166 int cookie_; |
| 174 }; | 167 }; |
| 175 | 168 |
| 176 void DebugDump(const PrintedPage& page); | 169 void DebugDump(const PrintedPage& page); |
| 177 | 170 |
| 178 // All writable data member access must be guarded by this lock. Needs to be | 171 // All writable data member access must be guarded by this lock. Needs to be |
| 179 // mutable since it can be acquired from const member functions. | 172 // mutable since it can be acquired from const member functions. |
| 180 mutable base::Lock lock_; | 173 mutable base::Lock lock_; |
| 181 | 174 |
| 182 // All the mutable members. | 175 // All the mutable members. |
| 183 Mutable mutable_; | 176 Mutable mutable_; |
| 184 | 177 |
| 185 // All the immutable members. | 178 // All the immutable members. |
| 186 const Immutable immutable_; | 179 const Immutable immutable_; |
| 187 | 180 |
| 188 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); | 181 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); |
| 189 }; | 182 }; |
| 190 | 183 |
| 191 } // namespace printing | 184 } // namespace printing |
| 192 | 185 |
| 193 #endif // PRINTING_PRINTED_DOCUMENT_H_ | 186 #endif // PRINTING_PRINTED_DOCUMENT_H_ |
| OLD | NEW |