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

Side by Side Diff: chrome/utility/utility_thread.cc

Issue 6544028: Create a Factory for NativeMetafile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ARM compile failure fix Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
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/utility/utility_thread.h" 5 #include "chrome/utility/utility_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/common/child_process.h" 13 #include "chrome/common/child_process.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/extensions/extension_unpacker.h" 15 #include "chrome/common/extensions/extension_unpacker.h"
16 #include "chrome/common/extensions/update_manifest.h" 16 #include "chrome/common/extensions/update_manifest.h"
17 #include "chrome/common/indexed_db_key.h" 17 #include "chrome/common/indexed_db_key.h"
18 #include "chrome/common/serialized_script_value.h" 18 #include "chrome/common/serialized_script_value.h"
19 #include "chrome/common/utility_messages.h" 19 #include "chrome/common/utility_messages.h"
20 #include "chrome/common/web_resource/web_resource_unpacker.h" 20 #include "chrome/common/web_resource/web_resource_unpacker.h"
21 #include "printing/native_metafile.h"
22 #include "printing/page_range.h" 21 #include "printing/page_range.h"
23 #include "printing/units.h" 22 #include "printing/units.h"
24 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h"
26 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
27 #include "webkit/glue/idb_bindings.h" 26 #include "webkit/glue/idb_bindings.h"
28 #include "webkit/glue/image_decoder.h" 27 #include "webkit/glue/image_decoder.h"
29 28
30 #if defined(OS_WIN) 29 #if defined(OS_WIN)
31 #include "app/win/iat_patch_function.h" 30 #include "app/win/iat_patch_function.h"
31 #include "base/scoped_ptr.h"
32 #include "base/win/scoped_handle.h" 32 #include "base/win/scoped_handle.h"
33 #include "printing/native_metafile_factory.h"
34 #include "printing/native_metafile.h"
33 #endif 35 #endif
34 36
35 namespace { 37 namespace {
36 38
37 template<typename SRC, typename DEST> 39 template<typename SRC, typename DEST>
38 void ConvertVector(const SRC& src, DEST* dest) { 40 void ConvertVector(const SRC& src, DEST* dest) {
39 dest->reserve(src.size()); 41 dest->reserve(src.size());
40 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) 42 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i)
41 dest->push_back(typename DEST::value_type(*i)); 43 dest->push_back(typename DEST::value_type(*i));
42 } 44 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 130
129 131
130 void UtilityThread::OnRenderPDFPagesToMetafile( 132 void UtilityThread::OnRenderPDFPagesToMetafile(
131 base::PlatformFile pdf_file, 133 base::PlatformFile pdf_file,
132 const FilePath& metafile_path, 134 const FilePath& metafile_path,
133 const gfx::Rect& render_area, 135 const gfx::Rect& render_area,
134 int render_dpi, 136 int render_dpi,
135 const std::vector<printing::PageRange>& page_ranges) { 137 const std::vector<printing::PageRange>& page_ranges) {
136 bool succeeded = false; 138 bool succeeded = false;
137 #if defined(OS_WIN) 139 #if defined(OS_WIN)
138 printing::NativeMetafile metafile; 140 scoped_ptr<printing::NativeMetafile> metafile(
141 printing::NativeMetafileFactory::CreateMetafile());
139 int highest_rendered_page_number = 0; 142 int highest_rendered_page_number = 0;
140 succeeded = RenderPDFToWinMetafile(pdf_file, metafile_path, render_area, 143 succeeded = RenderPDFToWinMetafile(pdf_file,
141 render_dpi, page_ranges, &metafile, 144 metafile_path,
145 render_area,
146 render_dpi,
147 page_ranges,
148 metafile.get(),
142 &highest_rendered_page_number); 149 &highest_rendered_page_number);
143 if (succeeded) { 150 if (succeeded) {
144 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded( 151 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded(
145 highest_rendered_page_number)); 152 highest_rendered_page_number));
146 } 153 }
147 #endif // defined(OS_WIN) 154 #endif // defined(OS_WIN)
148 if (!succeeded) { 155 if (!succeeded) {
149 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Failed()); 156 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Failed());
150 } 157 }
151 ReleaseProcessIfNeeded(); 158 ReleaseProcessIfNeeded();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } else { 341 } else {
335 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); 342 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name));
336 } 343 }
337 ReleaseProcessIfNeeded(); 344 ReleaseProcessIfNeeded();
338 } 345 }
339 346
340 void UtilityThread::ReleaseProcessIfNeeded() { 347 void UtilityThread::ReleaseProcessIfNeeded() {
341 if (!batch_mode_) 348 if (!batch_mode_)
342 ChildProcess::current()->ReleaseProcess(); 349 ChildProcess::current()->ReleaseProcess();
343 } 350 }
OLDNEW
« no previous file with comments | « chrome/service/service_utility_process_host.cc ('k') | content/browser/renderer_host/render_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698