Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: printing/printed_document.h

Issue 6516022: Linux: Refactor printing to be more like Windows/Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac build Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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/ref_counted.h" 10 #include "base/ref_counted.h"
11 #include "base/scoped_ptr.h" 11 #include "base/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 "printing/native_metafile.h" 16 #include "printing/native_metafile.h"
17 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
18 18
19 class FilePath; 19 class FilePath;
20 class MessageLoop; 20 class MessageLoop;
21 21
22 namespace gfx { 22 namespace gfx {
23 class Font; 23 class Font;
24 } 24 }
25 25
26 namespace printing { 26 namespace printing {
27 27
28 class PrintedPage; 28 class PrintedPage;
29 class PrintedPagesSource; 29 class PrintedPagesSource;
30 class PrintingContext;
30 31
31 // 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
32 // settings are changed, a new PrintedDocument must be created. 33 // settings are changed, a new PrintedDocument must be created.
33 // 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
34 // will have write access. Sensible functions are protected by a lock. 35 // will have write access. Sensible functions are protected by a lock.
35 // 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
36 // under low memory conditions. 37 // under low memory conditions.
37 class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> { 38 class PrintedDocument : public base::RefCountedThreadSafe<PrintedDocument> {
38 public: 39 public:
39 // 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
40 // originating source and settings. 41 // originating source and settings.
41 PrintedDocument(const PrintSettings& settings, 42 PrintedDocument(const PrintSettings& settings,
42 PrintedPagesSource* source, 43 PrintedPagesSource* source,
43 int cookie); 44 int cookie);
44 45
45 // Sets a page's data. 0-based. Takes metafile ownership. 46 // Sets a page's data. 0-based. Takes metafile ownership.
46 // Note: locks for a short amount of time. 47 // Note: locks for a short amount of time.
47 void SetPage(int page_number, NativeMetafile* metafile, double shrink, 48 void SetPage(int page_number, NativeMetafile* metafile, double shrink,
48 const gfx::Size& paper_size, const gfx::Rect& page_rect, 49 const gfx::Size& paper_size, const gfx::Rect& page_rect,
49 bool has_visible_overlays); 50 bool has_visible_overlays);
50 51
51 // 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
52 // requests to have this page be rendered and returns false. 53 // requests to have this page be rendered and returns false.
53 // Note: locks for a short amount of time. 54 // Note: locks for a short amount of time.
54 bool GetPage(int page_number, scoped_refptr<PrintedPage>* page); 55 bool GetPage(int page_number, scoped_refptr<PrintedPage>* page);
55 56
56 // Draws the page in the context. 57 // Draws the page in the context.
57 // Note: locks for a short amount of time in debug only. 58 // Note: locks for a short amount of time in debug only.
59 #if defined(OS_WIN) || defined(OS_MACOSX)
58 void RenderPrintedPage(const PrintedPage& page, 60 void RenderPrintedPage(const PrintedPage& page,
59 gfx::NativeDrawingContext context) const; 61 gfx::NativeDrawingContext context) const;
62 #elif defined(OS_POSIX)
63 void RenderPrintedPage(const PrintedPage& page,
64 PrintingContext* context) const;
65 #endif
60 66
61 // Returns true if all the necessary pages for the settings are already 67 // Returns true if all the necessary pages for the settings are already
62 // rendered. 68 // rendered.
63 // Note: locks while parsing the whole tree. 69 // Note: locks while parsing the whole tree.
64 bool IsComplete() const; 70 bool IsComplete() const;
65 71
66 // Disconnects the PrintedPage source (PrintedPagesSource). It is done when 72 // Disconnects the PrintedPage source (PrintedPagesSource). It is done when
67 // the source is being destroyed. 73 // the source is being destroyed.
68 void DisconnectSource(); 74 void DisconnectSource();
69 75
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 207
202 // All the immutable members. 208 // All the immutable members.
203 const Immutable immutable_; 209 const Immutable immutable_;
204 210
205 DISALLOW_COPY_AND_ASSIGN(PrintedDocument); 211 DISALLOW_COPY_AND_ASSIGN(PrintedDocument);
206 }; 212 };
207 213
208 } // namespace printing 214 } // namespace printing
209 215
210 #endif // PRINTING_PRINTED_DOCUMENT_H_ 216 #endif // PRINTING_PRINTED_DOCUMENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698