OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/printing/print_job.h" | 5 #include "chrome/browser/printing/print_job.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 #if defined(OS_WIN) | 224 #if defined(OS_WIN) |
225 | 225 |
226 class PrintJob::PdfToEmfState { | 226 class PrintJob::PdfToEmfState { |
227 public: | 227 public: |
228 PdfToEmfState(const gfx::Size& page_size, const gfx::Rect& content_area) | 228 PdfToEmfState(const gfx::Size& page_size, const gfx::Rect& content_area) |
229 : page_count_(0), | 229 : page_count_(0), |
230 current_page_(0), | 230 current_page_(0), |
231 pages_in_progress_(0), | 231 pages_in_progress_(0), |
232 page_size_(page_size), | 232 page_size_(page_size), |
233 content_area_(content_area), | 233 content_area_(content_area), |
234 converter_(PdfToEmfConverter::CreateDefault()) {} | 234 converter_(PdfConverter::CreatePdfToEmfConverter()) {} |
235 | 235 |
236 void Start(const scoped_refptr<base::RefCountedMemory>& data, | 236 void Start(const scoped_refptr<base::RefCountedMemory>& data, |
237 const PdfRenderSettings& conversion_settings, | 237 const PdfRenderSettings& conversion_settings, |
238 bool print_text_with_gdi, | 238 bool print_text_with_gdi, |
239 const PdfToEmfConverter::StartCallback& start_callback) { | 239 const PdfConverter::StartCallback& start_callback) { |
240 converter_->Start(data, conversion_settings, print_text_with_gdi, | 240 converter_->Start(data, conversion_settings, print_text_with_gdi, |
241 start_callback); | 241 start_callback); |
242 } | 242 } |
243 | 243 |
244 void GetMorePages( | 244 void GetMorePages( |
245 const PdfToEmfConverter::GetPageCallback& get_page_callback) { | 245 const PdfConverter::GetPageCallback& get_page_callback) { |
246 const int kMaxNumberOfTempFilesPerDocument = 3; | 246 const int kMaxNumberOfTempFilesPerDocument = 3; |
247 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && | 247 while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument && |
248 current_page_ < page_count_) { | 248 current_page_ < page_count_) { |
249 ++pages_in_progress_; | 249 ++pages_in_progress_; |
250 converter_->GetPage(current_page_++, get_page_callback); | 250 converter_->GetPage(current_page_++, get_page_callback); |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 void OnPageProcessed( | 254 void OnPageProcessed( |
255 const PdfToEmfConverter::GetPageCallback& get_page_callback) { | 255 const PdfConverter::GetPageCallback& get_page_callback) { |
256 --pages_in_progress_; | 256 --pages_in_progress_; |
257 GetMorePages(get_page_callback); | 257 GetMorePages(get_page_callback); |
258 // Release converter if we don't need this any more. | 258 // Release converter if we don't need this any more. |
259 if (!pages_in_progress_ && current_page_ >= page_count_) | 259 if (!pages_in_progress_ && current_page_ >= page_count_) |
260 converter_.reset(); | 260 converter_.reset(); |
261 } | 261 } |
262 | 262 |
263 void set_page_count(int page_count) { page_count_ = page_count; } | 263 void set_page_count(int page_count) { page_count_ = page_count; } |
264 gfx::Size page_size() const { return page_size_; } | 264 gfx::Size page_size() const { return page_size_; } |
265 gfx::Rect content_area() const { return content_area_; } | 265 gfx::Rect content_area() const { return content_area_; } |
266 | 266 |
267 private: | 267 private: |
268 int page_count_; | 268 int page_count_; |
269 int current_page_; | 269 int current_page_; |
270 int pages_in_progress_; | 270 int pages_in_progress_; |
271 gfx::Size page_size_; | 271 gfx::Size page_size_; |
272 gfx::Rect content_area_; | 272 gfx::Rect content_area_; |
273 std::unique_ptr<PdfToEmfConverter> converter_; | 273 std::unique_ptr<PdfConverter> converter_; |
274 }; | 274 }; |
275 | 275 |
276 void PrintJob::AppendPrintedPage(int page_number) { | 276 void PrintJob::AppendPrintedPage(int page_number) { |
277 pdf_page_mapping_.push_back(page_number); | 277 pdf_page_mapping_.push_back(page_number); |
278 } | 278 } |
279 | 279 |
280 void PrintJob::StartPdfToEmfConversion( | 280 void PrintJob::StartPdfToEmfConversion( |
281 const scoped_refptr<base::RefCountedMemory>& bytes, | 281 const scoped_refptr<base::RefCountedMemory>& bytes, |
282 const gfx::Size& page_size, | 282 const gfx::Size& page_size, |
283 const gfx::Rect& content_area, | 283 const gfx::Rect& content_area, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 457 } |
458 | 458 |
459 JobEventDetails::~JobEventDetails() { | 459 JobEventDetails::~JobEventDetails() { |
460 } | 460 } |
461 | 461 |
462 PrintedDocument* JobEventDetails::document() const { return document_.get(); } | 462 PrintedDocument* JobEventDetails::document() const { return document_.get(); } |
463 | 463 |
464 PrintedPage* JobEventDetails::page() const { return page_.get(); } | 464 PrintedPage* JobEventDetails::page() const { return page_.get(); } |
465 | 465 |
466 } // namespace printing | 466 } // namespace printing |
OLD | NEW |