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

Side by Side Diff: printing/printed_page.h

Issue 1863223002: Convert //printing to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « printing/printed_document.cc ('k') | printing/printed_page.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_PAGE_H_ 5 #ifndef PRINTING_PRINTED_PAGE_H_
6 #define PRINTING_PRINTED_PAGE_H_ 6 #define PRINTING_PRINTED_PAGE_H_
7 7
8 #include <memory>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "printing/metafile.h" 12 #include "printing/metafile.h"
12 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
14 15
15 namespace printing { 16 namespace printing {
16 17
17 // Contains the data to reproduce a printed page, either on screen or on 18 // Contains the data to reproduce a printed page, either on screen or on
18 // paper. Once created, this object is immutable. It has no reference to the 19 // paper. Once created, this object is immutable. It has no reference to the
19 // PrintedDocument containing this page. 20 // PrintedDocument containing this page.
20 // Note: May be accessed from many threads at the same time. This is an non 21 // Note: May be accessed from many threads at the same time. This is an non
21 // issue since this object is immutable. The reason is that a page may be 22 // issue since this object is immutable. The reason is that a page may be
22 // printed and be displayed at the same time. 23 // printed and be displayed at the same time.
23 class PRINTING_EXPORT PrintedPage 24 class PRINTING_EXPORT PrintedPage
24 : public base::RefCountedThreadSafe<PrintedPage> { 25 : public base::RefCountedThreadSafe<PrintedPage> {
25 public: 26 public:
26 PrintedPage(int page_number, 27 PrintedPage(int page_number,
27 scoped_ptr<MetafilePlayer> metafile, 28 std::unique_ptr<MetafilePlayer> metafile,
28 const gfx::Size& page_size, 29 const gfx::Size& page_size,
29 const gfx::Rect& page_content_rect); 30 const gfx::Rect& page_content_rect);
30 31
31 // Getters 32 // Getters
32 int page_number() const { return page_number_; } 33 int page_number() const { return page_number_; }
33 const MetafilePlayer* metafile() const; 34 const MetafilePlayer* metafile() const;
34 const gfx::Size& page_size() const { return page_size_; } 35 const gfx::Size& page_size() const { return page_size_; }
35 const gfx::Rect& page_content_rect() const { return page_content_rect_; } 36 const gfx::Rect& page_content_rect() const { return page_content_rect_; }
36 #if defined(OS_WIN) 37 #if defined(OS_WIN)
37 void set_shrink_factor(float shrink_factor) { 38 void set_shrink_factor(float shrink_factor) {
38 shrink_factor_ = shrink_factor; 39 shrink_factor_ = shrink_factor;
39 } 40 }
40 float shrink_factor() const { return shrink_factor_; } 41 float shrink_factor() const { return shrink_factor_; }
41 #endif // OS_WIN 42 #endif // OS_WIN
42 43
43 // Get page content rect adjusted based on 44 // Get page content rect adjusted based on
44 // http://dev.w3.org/csswg/css3-page/#positioning-page-box 45 // http://dev.w3.org/csswg/css3-page/#positioning-page-box
45 void GetCenteredPageContentRect(const gfx::Size& paper_size, 46 void GetCenteredPageContentRect(const gfx::Size& paper_size,
46 gfx::Rect* content_rect) const; 47 gfx::Rect* content_rect) const;
47 48
48 private: 49 private:
49 friend class base::RefCountedThreadSafe<PrintedPage>; 50 friend class base::RefCountedThreadSafe<PrintedPage>;
50 51
51 ~PrintedPage(); 52 ~PrintedPage();
52 53
53 // Page number inside the printed document. 54 // Page number inside the printed document.
54 const int page_number_; 55 const int page_number_;
55 56
56 // Actual paint data. 57 // Actual paint data.
57 const scoped_ptr<MetafilePlayer> metafile_; 58 const std::unique_ptr<MetafilePlayer> metafile_;
58 59
59 #if defined(OS_WIN) 60 #if defined(OS_WIN)
60 // Shrink done in comparison to desired_dpi. 61 // Shrink done in comparison to desired_dpi.
61 float shrink_factor_; 62 float shrink_factor_;
62 #endif // OS_WIN 63 #endif // OS_WIN
63 64
64 // The physical page size. To support multiple page formats inside on print 65 // The physical page size. To support multiple page formats inside on print
65 // job. 66 // job.
66 const gfx::Size page_size_; 67 const gfx::Size page_size_;
67 68
68 // The printable area of the page. 69 // The printable area of the page.
69 const gfx::Rect page_content_rect_; 70 const gfx::Rect page_content_rect_;
70 71
71 DISALLOW_COPY_AND_ASSIGN(PrintedPage); 72 DISALLOW_COPY_AND_ASSIGN(PrintedPage);
72 }; 73 };
73 74
74 } // namespace printing 75 } // namespace printing
75 76
76 #endif // PRINTING_PRINTED_PAGE_H_ 77 #endif // PRINTING_PRINTED_PAGE_H_
OLDNEW
« no previous file with comments | « printing/printed_document.cc ('k') | printing/printed_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698