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