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" | 14 #include "googleurl/src/gurl.h" |
15 #include "printing/print_settings.h" | 15 #include "printing/print_settings.h" |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 | 17 |
18 class FilePath; | 18 class FilePath; |
19 class MessageLoop; | 19 class MessageLoop; |
20 | 20 |
21 namespace gfx { | 21 namespace gfx { |
22 class Font; | 22 class Font; |
23 } | 23 } |
24 | 24 |
25 namespace printing { | 25 namespace printing { |
26 | 26 |
27 class NativeMetafile; | 27 class Metafile; |
28 class PrintedPage; | 28 class PrintedPage; |
29 class PrintedPagesSource; | 29 class PrintedPagesSource; |
30 class PrintingContext; | 30 class PrintingContext; |
31 | 31 |
32 // A collection of rendered pages. The settings are immutable. If the print | 32 // A collection of rendered pages. The settings are immutable. If the print |
33 // settings are changed, a new PrintedDocument must be created. | 33 // settings are changed, a new PrintedDocument must be created. |
34 // Warning: May be accessed from many threads at the same time. Only one thread | 34 // Warning: May be accessed from many threads at the same time. Only one thread |
35 // will have write access. Sensible functions are protected by a lock. | 35 // will have write access. Sensible functions are protected by a lock. |
36 // Warning: Once a page is loaded, it cannot be replaced. Pages may be discarded | 36 // Warning: Once a page is loaded, it cannot be replaced. Pages may be discarded |
37 // under low memory conditions. | 37 // under low memory conditions. |
38 class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> { | 38 class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> { |
39 public: | 39 public: |
40 // The cookie shall be unique and has a specific relationship with its | 40 // The cookie shall be unique and has a specific relationship with its |
41 // originating source and settings. | 41 // originating source and settings. |
42 PrintedDocument(const PrintSettings& settings, | 42 PrintedDocument(const PrintSettings& settings, |
43 PrintedPagesSource* source, | 43 PrintedPagesSource* source, |
44 int cookie); | 44 int cookie); |
45 | 45 |
46 // Sets a page's data. 0-based. Takes metafile ownership. | 46 // Sets a page's data. 0-based. Takes metafile ownership. |
47 // Note: locks for a short amount of time. | 47 // Note: locks for a short amount of time. |
48 void SetPage(int page_number, NativeMetafile* metafile, double shrink, | 48 void SetPage(int page_number, Metafile* metafile, double shrink, |
49 const gfx::Size& paper_size, const gfx::Rect& page_rect, | 49 const gfx::Size& paper_size, const gfx::Rect& page_rect, |
50 bool has_visible_overlays); | 50 bool has_visible_overlays); |
51 | 51 |
52 // Retrieves a page. If the page is not available right now, it | 52 // Retrieves a page. If the page is not available right now, it |
53 // requests to have this page be rendered and returns false. | 53 // requests to have this page be rendered and returns false. |
54 // Note: locks for a short amount of time. | 54 // Note: locks for a short amount of time. |
55 bool GetPage(int page_number, scoped_refptr<PrintedPage>* page); | 55 bool GetPage(int page_number, scoped_refptr<PrintedPage>* page); |
56 | 56 |
57 // Draws the page in the context. | 57 // Draws the page in the context. |
58 // Note: locks for a short amount of time in debug only. | 58 // Note: locks for a short amount of time in debug only. |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 // All the immutable members. | 213 // All the immutable members. |
214 const Immutable immutable_; | 214 const Immutable immutable_; |
215 | 215 |
216 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); | 216 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); |
217 }; | 217 }; |
218 | 218 |
219 } // namespace printing | 219 } // namespace printing |
220 | 220 |
221 #endif // PRINTING_PRINTED_DOCUMENT_H_ | 221 #endif // PRINTING_PRINTED_DOCUMENT_H_ |
OLD | NEW |