1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "printing/printed_document.h"
7 #include "base/check.h"
8 #include "base/synchronization/lock.h"
9 #include "printing/mojom/print.mojom.h"
10 #include "printing/printed_page_win.h"
11 #include "printing/printing_context.h"
16 bool PrintedDocument::IsPageInList(const PrintedPage& page) const {
17 // Make sure the page is from our list.
18 base::AutoLock lock(lock_);
19 return &page == mutable_.pages_.find(page.page_number() - 1)->second.get();
23 mojom::ResultCode PrintedDocument::RenderPrintedPage(
24 const PrintedPage& page,
25 PrintingContext* context) const {
27 DCHECK(IsPageInList(page));
31 mojom::ResultCode result = context->RenderPage(
32 page, immutable_.settings_->page_setup_device_units());
33 if (result != mojom::ResultCode::kSuccess)
36 // Beware of any asynchronous aborts of the print job that happened during
38 if (context->PrintingAborted())
39 return mojom::ResultCode::kCanceled;
41 return mojom::ResultCode::kSuccess;
44 } // namespace printing