| 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/renderer/print_web_view_helper.h" | 5 #include "chrome/renderer/print_web_view_helper.h" |
| 6 | 6 |
| 7 #include "base/file_descriptor_posix.h" | 7 #include "base/file_descriptor_posix.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #if defined(OS_CHROMEOS) | 75 #if defined(OS_CHROMEOS) |
| 76 int sequence_number = -1; | 76 int sequence_number = -1; |
| 77 base::FileDescriptor fd; | 77 base::FileDescriptor fd; |
| 78 | 78 |
| 79 // Ask the browser to open a file for us. | 79 // Ask the browser to open a file for us. |
| 80 Send(new PrintHostMsg_AllocateTempFileForPrinting(&fd, &sequence_number)); | 80 Send(new PrintHostMsg_AllocateTempFileForPrinting(&fd, &sequence_number)); |
| 81 if (!metafile.SaveToFD(fd)) | 81 if (!metafile.SaveToFD(fd)) |
| 82 return false; | 82 return false; |
| 83 | 83 |
| 84 // Tell the browser we've finished writing the file. | 84 // Tell the browser we've finished writing the file. |
| 85 Send(new PrintHostMsg_TempFileForPrintingWritten(sequence_number)); | 85 Send(new PrintHostMsg_TempFileForPrintingWritten(routing_id(), |
| 86 sequence_number)); |
| 86 return true; | 87 return true; |
| 87 #else | 88 #else |
| 88 PrintHostMsg_DidPrintPage_Params printed_page_params; | 89 PrintHostMsg_DidPrintPage_Params printed_page_params; |
| 89 printed_page_params.data_size = 0; | 90 printed_page_params.data_size = 0; |
| 90 printed_page_params.document_cookie = params.params.document_cookie; | 91 printed_page_params.document_cookie = params.params.document_cookie; |
| 91 | 92 |
| 92 base::SharedMemoryHandle shared_mem_handle = | 93 base::SharedMemoryHandle shared_mem_handle = |
| 93 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(buf_size); | 94 content::RenderThread::Get()->HostAllocateSharedMemoryBuffer(buf_size); |
| 94 if (!base::SharedMemory::IsHandleValid(shared_mem_handle)) { | 95 if (!base::SharedMemory::IsHandleValid(shared_mem_handle)) { |
| 95 NOTREACHED() << "AllocateSharedMemoryBuffer returned bad handle"; | 96 NOTREACHED() << "AllocateSharedMemoryBuffer returned bad handle"; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, | 209 PrintHeaderAndFooter(canvas.get(), params.page_number + 1, |
| 209 print_preview_context_.total_page_count(), | 210 print_preview_context_.total_page_count(), |
| 210 scale_factor, page_layout_in_points, | 211 scale_factor, page_layout_in_points, |
| 211 *header_footer_info_); | 212 *header_footer_info_); |
| 212 } | 213 } |
| 213 | 214 |
| 214 // Done printing. Close the device context to retrieve the compiled metafile. | 215 // Done printing. Close the device context to retrieve the compiled metafile. |
| 215 if (!metafile->FinishPage()) | 216 if (!metafile->FinishPage()) |
| 216 NOTREACHED() << "metafile failed"; | 217 NOTREACHED() << "metafile failed"; |
| 217 } | 218 } |
| OLD | NEW |