OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "printing/printed_document.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "printing/page_number.h" |
| 9 #include "printing/printed_page.h" |
| 10 |
| 11 #if defined(USE_CUPS) |
| 12 #include "printing/printing_context_chromeos.h" |
| 13 #endif // USE_CUPS |
| 14 |
| 15 namespace printing { |
| 16 |
| 17 void PrintedDocument::RenderPrintedPage(const PrintedPage& page, |
| 18 PrintingContext* context) const { |
| 19 #if defined(USE_CUPS) |
| 20 #if defined(NDEBUG) |
| 21 { |
| 22 // Make sure the page is from our list. |
| 23 base::AutoLock lock(lock_); |
| 24 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get()); |
| 25 } |
| 26 #endif // NDEBUG |
| 27 |
| 28 DCHECK(context); |
| 29 |
| 30 { |
| 31 base::AutoLock lock(lock_); |
| 32 if (page.page_number() - 1 == mutable_.first_page) { |
| 33 std::vector<char> buffer; |
| 34 |
| 35 if (page.metafile()->GetDataAsVector(&buffer)) { |
| 36 static_cast<PrintingContextChromeos*>(context)->StreamData(buffer); |
| 37 } else { |
| 38 LOG(WARNING) << "Failed to read data from metafile"; |
| 39 } |
| 40 } |
| 41 } |
| 42 #else |
| 43 NOTREACHED(); |
| 44 #endif // USE_CUPS |
| 45 } |
| 46 |
| 47 } // namespace printing |
OLD | NEW |