OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 base::TimeTicks begin_time = base::TimeTicks::Now(); | 134 base::TimeTicks begin_time = base::TimeTicks::Now(); |
135 RenderPage(print_params, &scale_factor, page_number, true, | 135 RenderPage(print_params, &scale_factor, page_number, true, |
136 print_preview_context_.frame(), &metafile); | 136 print_preview_context_.frame(), &metafile); |
137 | 137 |
138 print_preview_context_.RenderedPreviewPage( | 138 print_preview_context_.RenderedPreviewPage( |
139 base::TimeTicks::Now() - begin_time); | 139 base::TimeTicks::Now() - begin_time); |
140 | 140 |
141 // Release since |print_preview_context_| is the real owner. | 141 // Release since |print_preview_context_| is the real owner. |
142 metafile.release(); | 142 metafile.release(); |
143 printing::Metafile* page_metafile = NULL; | 143 scoped_ptr<printing::Metafile> page_metafile; |
144 if (print_preview_context_.IsModifiable()) { | 144 if (print_preview_context_.IsModifiable()) { |
145 page_metafile = reinterpret_cast<printing::PreviewMetafile*>( | 145 page_metafile.reset(reinterpret_cast<printing::PreviewMetafile*>( |
146 print_preview_context_.metafile())->GetMetafileForCurrentPage(); | 146 print_preview_context_.metafile())->GetMetafileForCurrentPage()); |
147 } | 147 } |
148 PreviewPageRendered(page_number, page_metafile); | 148 PreviewPageRendered(page_number, page_metafile.get()); |
149 } | 149 } |
150 | 150 |
151 void PrintWebViewHelper::RenderPage( | 151 void PrintWebViewHelper::RenderPage( |
152 const PrintMsg_Print_Params& params, float* scale_factor, int page_number, | 152 const PrintMsg_Print_Params& params, float* scale_factor, int page_number, |
153 bool is_preview, WebFrame* frame, scoped_ptr<Metafile>* metafile) { | 153 bool is_preview, WebFrame* frame, scoped_ptr<Metafile>* metafile) { |
154 PageSizeMargins page_layout_in_points; | 154 PageSizeMargins page_layout_in_points; |
155 GetPageSizeAndMarginsInPoints(frame, page_number, params, | 155 GetPageSizeAndMarginsInPoints(frame, page_number, params, |
156 &page_layout_in_points); | 156 &page_layout_in_points); |
157 | 157 |
158 int width; | 158 int width; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 shared_buf.Unmap(); | 281 shared_buf.Unmap(); |
282 return false; | 282 return false; |
283 } | 283 } |
284 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); | 284 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), shared_mem_handle); |
285 shared_buf.Unmap(); | 285 shared_buf.Unmap(); |
286 | 286 |
287 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, | 287 Send(new PrintHostMsg_DuplicateSection(routing_id(), *shared_mem_handle, |
288 shared_mem_handle)); | 288 shared_mem_handle)); |
289 return true; | 289 return true; |
290 } | 290 } |
OLD | NEW |