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

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

Issue 6594121: Revert 76553 - Applying factory pattern (through NativeMetafileFactory class)... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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"
21 #include "printing/page_range.h" 22 #include "printing/page_range.h"
22 #include "printing/units.h" 23 #include "printing/units.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa lue.h"
25 #include "ui/gfx/rect.h" 26 #include "ui/gfx/rect.h"
26 #include "webkit/glue/idb_bindings.h" 27 #include "webkit/glue/idb_bindings.h"
27 #include "webkit/glue/image_decoder.h" 28 #include "webkit/glue/image_decoder.h"
28 29
29 #if defined(OS_WIN) 30 #if defined(OS_WIN)
30 #include "app/win/iat_patch_function.h" 31 #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"
35 #endif 33 #endif
36 34
37 namespace { 35 namespace {
38 36
39 template<typename SRC, typename DEST> 37 template<typename SRC, typename DEST>
40 void ConvertVector(const SRC& src, DEST* dest) { 38 void ConvertVector(const SRC& src, DEST* dest) {
41 dest->reserve(src.size()); 39 dest->reserve(src.size());
42 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i) 40 for (typename SRC::const_iterator i = src.begin(); i != src.end(); ++i)
43 dest->push_back(typename DEST::value_type(*i)); 41 dest->push_back(typename DEST::value_type(*i));
44 } 42 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 128
131 129
132 void UtilityThread::OnRenderPDFPagesToMetafile( 130 void UtilityThread::OnRenderPDFPagesToMetafile(
133 base::PlatformFile pdf_file, 131 base::PlatformFile pdf_file,
134 const FilePath& metafile_path, 132 const FilePath& metafile_path,
135 const gfx::Rect& render_area, 133 const gfx::Rect& render_area,
136 int render_dpi, 134 int render_dpi,
137 const std::vector<printing::PageRange>& page_ranges) { 135 const std::vector<printing::PageRange>& page_ranges) {
138 bool succeeded = false; 136 bool succeeded = false;
139 #if defined(OS_WIN) 137 #if defined(OS_WIN)
140 scoped_ptr<printing::NativeMetafile> metafile( 138 printing::NativeMetafile metafile;
141 printing::NativeMetafileFactory::CreateMetafile());
142 int highest_rendered_page_number = 0; 139 int highest_rendered_page_number = 0;
143 succeeded = RenderPDFToWinMetafile(pdf_file, 140 succeeded = RenderPDFToWinMetafile(pdf_file, metafile_path, render_area,
144 metafile_path, 141 render_dpi, page_ranges, &metafile,
145 render_area,
146 render_dpi,
147 page_ranges,
148 metafile.get(),
149 &highest_rendered_page_number); 142 &highest_rendered_page_number);
150 if (succeeded) { 143 if (succeeded) {
151 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded( 144 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded(
152 highest_rendered_page_number)); 145 highest_rendered_page_number));
153 } 146 }
154 #endif // defined(OS_WIN) 147 #endif // defined(OS_WIN)
155 if (!succeeded) { 148 if (!succeeded) {
156 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Failed()); 149 Send(new UtilityHostMsg_RenderPDFPagesToMetafile_Failed());
157 } 150 }
158 ReleaseProcessIfNeeded(); 151 ReleaseProcessIfNeeded();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } else { 334 } else {
342 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); 335 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name));
343 } 336 }
344 ReleaseProcessIfNeeded(); 337 ReleaseProcessIfNeeded();
345 } 338 }
346 339
347 void UtilityThread::ReleaseProcessIfNeeded() { 340 void UtilityThread::ReleaseProcessIfNeeded() {
348 if (!batch_mode_) 341 if (!batch_mode_)
349 ChildProcess::current()->ReleaseProcess(); 342 ChildProcess::current()->ReleaseProcess();
350 } 343 }
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