Upload upstream chromium 73.0.3683.0
[platform/framework/web/chromium-efl.git] / printing / printed_document_chromeos.cc
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
9 #if defined(USE_CUPS)
10 #include "printing/metafile.h"
11 #include "printing/printing_context_chromeos.h"
12 #endif
13
14 namespace printing {
15
16 bool PrintedDocument::RenderPrintedDocument(PrintingContext* context) {
17 #if defined(USE_CUPS)
18   DCHECK(context);
19
20   if (context->NewPage() != PrintingContext::OK)
21     return false;
22   {
23     base::AutoLock lock(lock_);
24     std::vector<char> buffer;
25     const MetafilePlayer* metafile = GetMetafile();
26     DCHECK(metafile);
27     if (metafile->GetDataAsVector(&buffer)) {
28       static_cast<PrintingContextChromeos*>(context)->StreamData(buffer);
29     } else {
30       LOG(WARNING) << "Failed to read data from metafile";
31     }
32   }
33   return context->PageDone() == PrintingContext::OK;
34 #else
35   NOTREACHED();
36   return false;
37 #endif  // defined(USE_CUPS)
38 }
39
40 }  // namespace printing