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

Side by Side Diff: printing/printed_document.cc

Issue 47823002: De-duplicate job_settings parsing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Noam's comments Created 7 years, 1 month 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
« no previous file with comments | « printing/print_settings_initializer_win.cc ('k') | printing/printing_context.h » ('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 #include "printing/printed_document.h" 5 #include "printing/printed_document.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 namespace printing { 45 namespace printing {
46 46
47 PrintedDocument::PrintedDocument(const PrintSettings& settings, 47 PrintedDocument::PrintedDocument(const PrintSettings& settings,
48 PrintedPagesSource* source, 48 PrintedPagesSource* source,
49 int cookie) 49 int cookie)
50 : mutable_(source), 50 : mutable_(source),
51 immutable_(settings, source, cookie) { 51 immutable_(settings, source, cookie) {
52 52
53 // Records the expected page count if a range is setup. 53 // Records the expected page count if a range is setup.
54 if (!settings.ranges.empty()) { 54 if (!settings.ranges().empty()) {
55 // If there is a range, set the number of page 55 // If there is a range, set the number of page
56 for (unsigned i = 0; i < settings.ranges.size(); ++i) { 56 for (unsigned i = 0; i < settings.ranges().size(); ++i) {
57 const PageRange& range = settings.ranges[i]; 57 const PageRange& range = settings.ranges()[i];
58 mutable_.expected_page_count_ += range.to - range.from + 1; 58 mutable_.expected_page_count_ += range.to - range.from + 1;
59 } 59 }
60 } 60 }
61 } 61 }
62 62
63 PrintedDocument::~PrintedDocument() { 63 PrintedDocument::~PrintedDocument() {
64 } 64 }
65 65
66 void PrintedDocument::SetPage(int page_number, 66 void PrintedDocument::SetPage(int page_number,
67 Metafile* metafile, 67 Metafile* metafile,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 for (size_t i = 0; i < pages_copy.size(); ++i) { 146 for (size_t i = 0; i < pages_copy.size(); ++i) {
147 total += pages_copy[i]->metafile()->GetDataSize(); 147 total += pages_copy[i]->metafile()->GetDataSize();
148 } 148 }
149 return total; 149 return total;
150 } 150 }
151 151
152 void PrintedDocument::set_page_count(int max_page) { 152 void PrintedDocument::set_page_count(int max_page) {
153 base::AutoLock lock(lock_); 153 base::AutoLock lock(lock_);
154 DCHECK_EQ(0, mutable_.page_count_); 154 DCHECK_EQ(0, mutable_.page_count_);
155 mutable_.page_count_ = max_page; 155 mutable_.page_count_ = max_page;
156 if (immutable_.settings_.ranges.empty()) { 156 if (immutable_.settings_.ranges().empty()) {
157 mutable_.expected_page_count_ = max_page; 157 mutable_.expected_page_count_ = max_page;
158 } else { 158 } else {
159 // If there is a range, don't bother since expected_page_count_ is already 159 // If there is a range, don't bother since expected_page_count_ is already
160 // initialized. 160 // initialized.
161 DCHECK_NE(mutable_.expected_page_count_, 0); 161 DCHECK_NE(mutable_.expected_page_count_, 0);
162 } 162 }
163 } 163 }
164 164
165 int PrintedDocument::page_count() const { 165 int PrintedDocument::page_count() const {
166 base::AutoLock lock(lock_); 166 base::AutoLock lock(lock_);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 229
230 #if (defined(OS_POSIX) && defined(USE_AURA)) || defined(OS_ANDROID) 230 #if (defined(OS_POSIX) && defined(USE_AURA)) || defined(OS_ANDROID)
231 // This function is not used on aura linux/chromeos or android. 231 // This function is not used on aura linux/chromeos or android.
232 void PrintedDocument::RenderPrintedPage(const PrintedPage& page, 232 void PrintedDocument::RenderPrintedPage(const PrintedPage& page,
233 PrintingContext* context) const { 233 PrintingContext* context) const {
234 } 234 }
235 #endif 235 #endif
236 236
237 } // namespace printing 237 } // namespace printing
OLDNEW
« no previous file with comments | « printing/print_settings_initializer_win.cc ('k') | printing/printing_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698