| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 int page_count() const; | 83 int page_count() const; |
| 84 | 84 |
| 85 // Returns the number of expected pages to be rendered. It is a non-linear | 85 // Returns the number of expected pages to be rendered. It is a non-linear |
| 86 // series if settings().ranges is not empty. It is the same value as | 86 // series if settings().ranges is not empty. It is the same value as |
| 87 // document_page_count() otherwise. | 87 // document_page_count() otherwise. |
| 88 // Note: locks for a short amount of time. | 88 // Note: locks for a short amount of time. |
| 89 int expected_page_count() const; | 89 int expected_page_count() const; |
| 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 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 static const base::FilePath& debug_dump_path(); |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 friend class base::RefCountedThreadSafe<PrintedDocument>; | 103 friend class base::RefCountedThreadSafe<PrintedDocument>; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 int cookie); | 142 int cookie); |
| 143 ~Immutable(); | 143 ~Immutable(); |
| 144 | 144 |
| 145 // Print settings used to generate this document. Immutable. | 145 // Print settings used to generate this document. Immutable. |
| 146 PrintSettings settings_; | 146 PrintSettings settings_; |
| 147 | 147 |
| 148 // Native thread for the render source. | 148 // Native thread for the render source. |
| 149 base::MessageLoop* source_message_loop_; | 149 base::MessageLoop* source_message_loop_; |
| 150 | 150 |
| 151 // Document name. Immutable. | 151 // Document name. Immutable. |
| 152 string16 name_; | 152 base::string16 name_; |
| 153 | 153 |
| 154 // Cookie to uniquely identify this document. It is used to make sure that a | 154 // Cookie to uniquely identify this document. It is used to make sure that a |
| 155 // PrintedPage is correctly belonging to the PrintedDocument. Since | 155 // PrintedPage is correctly belonging to the PrintedDocument. Since |
| 156 // PrintedPage generation is completely asynchronous, it could be easy to | 156 // 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 | 157 // 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 | 158 // simpler hash of PrintSettings since a new document is made each time the |
| 159 // print settings change. | 159 // print settings change. |
| 160 int cookie_; | 160 int cookie_; |
| 161 }; | 161 }; |
| 162 | 162 |
| 163 void DebugDump(const PrintedPage& page); | 163 void DebugDump(const PrintedPage& page); |
| 164 | 164 |
| 165 // All writable data member access must be guarded by this lock. Needs to be | 165 // 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. | 166 // mutable since it can be acquired from const member functions. |
| 167 mutable base::Lock lock_; | 167 mutable base::Lock lock_; |
| 168 | 168 |
| 169 // All the mutable members. | 169 // All the mutable members. |
| 170 Mutable mutable_; | 170 Mutable mutable_; |
| 171 | 171 |
| 172 // All the immutable members. | 172 // All the immutable members. |
| 173 const Immutable immutable_; | 173 const Immutable immutable_; |
| 174 | 174 |
| 175 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); | 175 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); |
| 176 }; | 176 }; |
| 177 | 177 |
| 178 } // namespace printing | 178 } // namespace printing |
| 179 | 179 |
| 180 #endif // PRINTING_PRINTED_DOCUMENT_H_ | 180 #endif // PRINTING_PRINTED_DOCUMENT_H_ |
| OLD | NEW |