Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: components/printing/renderer/print_web_view_helper_linux.cc

Issue 2653963002: [Experimental] Supporting OOPIF printing
Patch Set: Rename service, fix for webview, and connect to DiscardableMemoryManager Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/printing/renderer/print_web_view_helper.h" 5 #include "components/printing/renderer/print_web_view_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 PrintMsg_PrintPage_Params page_params; 57 PrintMsg_PrintPage_Params page_params;
58 page_params.params = params.params; 58 page_params.params = params.params;
59 for (int page_number : printed_pages) { 59 for (int page_number : printed_pages) {
60 page_params.page_number = page_number; 60 page_params.page_number = page_number;
61 PrintPageInternal(page_params, frame, &metafile, nullptr, nullptr, nullptr); 61 PrintPageInternal(page_params, frame, &metafile, nullptr, nullptr, nullptr);
62 } 62 }
63 63
64 // blink::printEnd() for PDF should be called before metafile is closed. 64 // blink::printEnd() for PDF should be called before metafile is closed.
65 FinishFramePrinting(); 65 FinishFramePrinting();
66 66
67 metafile.FinishDocument(); 67 metafile.FinishAllPages();
68 68
69 #if defined(OS_ANDROID) 69 #if defined(OS_ANDROID)
70 int sequence_number = -1; 70 int sequence_number = -1;
71 base::FileDescriptor fd; 71 base::FileDescriptor fd;
72 72
73 // Ask the browser to open a file for us. 73 // Ask the browser to open a file for us.
74 Send(new PrintHostMsg_AllocateTempFileForPrinting(routing_id(), 74 Send(new PrintHostMsg_AllocateTempFileForPrinting(routing_id(),
75 &fd, 75 &fd,
76 &sequence_number)); 76 &sequence_number));
77 if (!SaveToFD(metafile, fd)) 77 if (!SaveToFD(metafile, fd))
78 return false; 78 return false;
79 79
80 // Tell the browser we've finished writing the file. 80 // Tell the browser we've finished writing the file.
81 Send(new PrintHostMsg_TempFileForPrintingWritten(routing_id(), 81 Send(new PrintHostMsg_TempFileForPrintingWritten(routing_id(),
82 sequence_number)); 82 sequence_number));
83 return true; 83 return true;
84 #else 84 #else
85 PrintHostMsg_DidPrintPage_Params printed_page_params; 85 PrintHostMsg_DidPrintPage_Params printed_page_params;
86 86
87 if (!CopyMetafileDataToSharedMem( 87 if (!CopyMetafileDataToSharedMem(metafile, &printed_page_params)) {
88 metafile, &printed_page_params.metafile_data_handle)) {
89 return false; 88 return false;
90 } 89 }
91 90
92 printed_page_params.data_size = metafile.GetDataSize();
93 printed_page_params.document_cookie = params.params.document_cookie; 91 printed_page_params.document_cookie = params.params.document_cookie;
94 92
95 for (size_t i = 0; i < printed_pages.size(); ++i) { 93 for (size_t i = 0; i < printed_pages.size(); ++i) {
96 printed_page_params.page_number = printed_pages[i]; 94 printed_page_params.page_number = printed_pages[i];
97 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params)); 95 Send(new PrintHostMsg_DidPrintPage(routing_id(), printed_page_params));
98 // Send the rest of the pages with an invalid metafile handle. 96 // Send the rest of the pages with an invalid metafile handle.
99 printed_page_params.metafile_data_handle.fd = -1; 97 printed_page_params.metafile_data_handle.fd = -1;
100 } 98 }
101 return true; 99 return true;
102 #endif // defined(OS_ANDROID) 100 #endif // defined(OS_ANDROID)
103 } 101 }
104 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) 102 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
105 103
106 } // namespace printing 104 } // namespace printing
OLDNEW
« no previous file with comments | « components/printing/renderer/print_web_view_helper.cc ('k') | components/printing/renderer/print_web_view_helper_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698