| 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 #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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 Metafile* metafile, | 67 Metafile* metafile, |
| 68 double shrink, | 68 double shrink, |
| 69 const gfx::Size& paper_size, | 69 const gfx::Size& paper_size, |
| 70 const gfx::Rect& page_rect) { | 70 const gfx::Rect& page_rect) { |
| 71 // Notice the page_number + 1, the reason is that this is the value that will | 71 // Notice the page_number + 1, the reason is that this is the value that will |
| 72 // be shown. Users dislike 0-based counting. | 72 // be shown. Users dislike 0-based counting. |
| 73 scoped_refptr<PrintedPage> page( | 73 scoped_refptr<PrintedPage> page( |
| 74 new PrintedPage(page_number + 1, | 74 new PrintedPage(page_number + 1, |
| 75 metafile, | 75 metafile, |
| 76 paper_size, | 76 paper_size, |
| 77 page_rect)); | 77 page_rect, |
| 78 shrink)); |
| 78 { | 79 { |
| 79 base::AutoLock lock(lock_); | 80 base::AutoLock lock(lock_); |
| 80 mutable_.pages_[page_number] = page; | 81 mutable_.pages_[page_number] = page; |
| 81 | 82 |
| 82 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 83 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 83 if (page_number < mutable_.first_page) | 84 if (page_number < mutable_.first_page) |
| 84 mutable_.first_page = page_number; | 85 mutable_.first_page = page_number; |
| 85 #endif | 86 #endif |
| 86 | |
| 87 if (mutable_.shrink_factor == 0) { | |
| 88 mutable_.shrink_factor = shrink; | |
| 89 } else { | |
| 90 DCHECK_EQ(mutable_.shrink_factor, shrink); | |
| 91 } | |
| 92 } | 87 } |
| 93 DebugDump(*page); | 88 DebugDump(*page); |
| 94 } | 89 } |
| 95 | 90 |
| 96 bool PrintedDocument::GetPage(int page_number, | 91 bool PrintedDocument::GetPage(int page_number, |
| 97 scoped_refptr<PrintedPage>* page) { | 92 scoped_refptr<PrintedPage>* page) { |
| 98 base::AutoLock lock(lock_); | 93 base::AutoLock lock(lock_); |
| 99 PrintedPages::const_iterator itr = mutable_.pages_.find(page_number); | 94 PrintedPages::const_iterator itr = mutable_.pages_.find(page_number); |
| 100 if (itr != mutable_.pages_.end()) { | 95 if (itr != mutable_.pages_.end()) { |
| 101 if (itr->second.get()) { | 96 if (itr->second.get()) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 g_debug_dump_info.Get().debug_dump_path = debug_dump_path; | 196 g_debug_dump_info.Get().debug_dump_path = debug_dump_path; |
| 202 } | 197 } |
| 203 | 198 |
| 204 const FilePath& PrintedDocument::debug_dump_path() { | 199 const FilePath& PrintedDocument::debug_dump_path() { |
| 205 return g_debug_dump_info.Get().debug_dump_path; | 200 return g_debug_dump_info.Get().debug_dump_path; |
| 206 } | 201 } |
| 207 | 202 |
| 208 PrintedDocument::Mutable::Mutable(PrintedPagesSource* source) | 203 PrintedDocument::Mutable::Mutable(PrintedPagesSource* source) |
| 209 : source_(source), | 204 : source_(source), |
| 210 expected_page_count_(0), | 205 expected_page_count_(0), |
| 211 page_count_(0), | 206 page_count_(0) { |
| 212 shrink_factor(0) { | |
| 213 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 207 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 214 first_page = INT_MAX; | 208 first_page = INT_MAX; |
| 215 #endif | 209 #endif |
| 216 } | 210 } |
| 217 | 211 |
| 218 PrintedDocument::Mutable::~Mutable() { | 212 PrintedDocument::Mutable::~Mutable() { |
| 219 } | 213 } |
| 220 | 214 |
| 221 PrintedDocument::Immutable::Immutable(const PrintSettings& settings, | 215 PrintedDocument::Immutable::Immutable(const PrintSettings& settings, |
| 222 PrintedPagesSource* source, | 216 PrintedPagesSource* source, |
| 223 int cookie) | 217 int cookie) |
| 224 : settings_(settings), | 218 : settings_(settings), |
| 225 source_message_loop_(MessageLoop::current()), | 219 source_message_loop_(MessageLoop::current()), |
| 226 name_(source->RenderSourceName()), | 220 name_(source->RenderSourceName()), |
| 227 cookie_(cookie) { | 221 cookie_(cookie) { |
| 228 } | 222 } |
| 229 | 223 |
| 230 PrintedDocument::Immutable::~Immutable() { | 224 PrintedDocument::Immutable::~Immutable() { |
| 231 } | 225 } |
| 232 | 226 |
| 233 #if defined(OS_POSIX) && defined(USE_AURA) | 227 #if defined(OS_POSIX) && defined(USE_AURA) |
| 234 // This function is not used on aura linux/chromeos. | 228 // This function is not used on aura linux/chromeos. |
| 235 void PrintedDocument::RenderPrintedPage(const PrintedPage& page, | 229 void PrintedDocument::RenderPrintedPage(const PrintedPage& page, |
| 236 PrintingContext* context) const { | 230 PrintingContext* context) const { |
| 237 } | 231 } |
| 238 #endif | 232 #endif |
| 239 | 233 |
| 240 } // namespace printing | 234 } // namespace printing |
| OLD | NEW |