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/service/service_utility_process_host.h" | 5 #include "chrome/service/service_utility_process_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/utility_messages.h" | 13 #include "chrome/common/utility_messages.h" |
14 #include "ipc/ipc_switches.h" | 14 #include "ipc/ipc_switches.h" |
15 #include "printing/page_range.h" | 15 #include "printing/page_range.h" |
16 #include "ui/base/ui_base_switches.h" | 16 #include "ui/base/ui_base_switches.h" |
17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
18 | 18 |
19 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
20 #include "base/scoped_ptr.h" | 20 #include "base/scoped_ptr.h" |
21 #include "base/win/scoped_handle.h" | 21 #include "base/win/scoped_handle.h" |
22 #include "printing/native_metafile_factory.h" | 22 #include "printing/emf_win.h" |
23 #include "printing/native_metafile.h" | |
24 #endif | 23 #endif |
25 | 24 |
26 ServiceUtilityProcessHost::ServiceUtilityProcessHost( | 25 ServiceUtilityProcessHost::ServiceUtilityProcessHost( |
27 Client* client, base::MessageLoopProxy* client_message_loop_proxy) | 26 Client* client, base::MessageLoopProxy* client_message_loop_proxy) |
28 : ServiceChildProcessHost(ChildProcessInfo::UTILITY_PROCESS), | 27 : ServiceChildProcessHost(ChildProcessInfo::UTILITY_PROCESS), |
29 client_(client), | 28 client_(client), |
30 client_message_loop_proxy_(client_message_loop_proxy), | 29 client_message_loop_proxy_(client_message_loop_proxy), |
31 waiting_for_reply_(false) { | 30 waiting_for_reply_(false) { |
32 } | 31 } |
33 | 32 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 195 |
197 void ServiceUtilityProcessHost::Client::MetafileAvailable( | 196 void ServiceUtilityProcessHost::Client::MetafileAvailable( |
198 const FilePath& metafile_path, | 197 const FilePath& metafile_path, |
199 int highest_rendered_page_number) { | 198 int highest_rendered_page_number) { |
200 // The metafile was created in a temp folder which needs to get deleted after | 199 // The metafile was created in a temp folder which needs to get deleted after |
201 // we have processed it. | 200 // we have processed it. |
202 ScopedTempDir scratch_metafile_dir; | 201 ScopedTempDir scratch_metafile_dir; |
203 if (!scratch_metafile_dir.Set(metafile_path.DirName())) | 202 if (!scratch_metafile_dir.Set(metafile_path.DirName())) |
204 LOG(WARNING) << "Unable to set scratch metafile directory"; | 203 LOG(WARNING) << "Unable to set scratch metafile directory"; |
205 #if defined(OS_WIN) | 204 #if defined(OS_WIN) |
206 scoped_ptr<printing::NativeMetafile> metafile( | 205 // It's important that metafile is declared after scratch_metafile_dir so |
207 printing::NativeMetafileFactory::Create()); | 206 // that the metafile destructor closes the file before the ScopedTempDir |
208 if (!metafile->CreateFromFile(metafile_path)) { | 207 // destructor tries to remove the directory. |
| 208 printing::Emf metafile; |
| 209 if (!metafile.InitFromFile(metafile_path)) { |
209 OnRenderPDFPagesToMetafileFailed(); | 210 OnRenderPDFPagesToMetafileFailed(); |
210 } else { | 211 } else { |
211 OnRenderPDFPagesToMetafileSucceeded(*metafile, | 212 OnRenderPDFPagesToMetafileSucceeded(metafile, |
212 highest_rendered_page_number); | 213 highest_rendered_page_number); |
213 // Close it so that ScopedTempDir can delete the folder. | |
214 metafile->CloseEmf(); | |
215 } | 214 } |
216 #endif // defined(OS_WIN) | 215 #endif // defined(OS_WIN) |
217 } | 216 } |
218 | 217 |
OLD | NEW |