OLD | NEW |
1 // Copyright (c) 2010 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 "gfx/rect.h" | 15 #include "gfx/rect.h" |
16 #include "ipc/ipc_switches.h" | 16 #include "ipc/ipc_switches.h" |
17 #include "printing/native_metafile.h" | 17 #include "printing/native_metafile.h" |
18 #include "printing/page_range.h" | 18 #include "printing/page_range.h" |
19 | 19 |
| 20 #if defined(OS_WIN) |
| 21 #include "base/win/scoped_handle.h" |
| 22 #endif |
| 23 |
20 ServiceUtilityProcessHost::ServiceUtilityProcessHost( | 24 ServiceUtilityProcessHost::ServiceUtilityProcessHost( |
21 Client* client, base::MessageLoopProxy* client_message_loop_proxy) | 25 Client* client, base::MessageLoopProxy* client_message_loop_proxy) |
22 : ServiceChildProcessHost(ChildProcessInfo::UTILITY_PROCESS), | 26 : ServiceChildProcessHost(ChildProcessInfo::UTILITY_PROCESS), |
23 client_(client), | 27 client_(client), |
24 client_message_loop_proxy_(client_message_loop_proxy), | 28 client_message_loop_proxy_(client_message_loop_proxy), |
25 waiting_for_reply_(false) { | 29 waiting_for_reply_(false) { |
26 } | 30 } |
27 | 31 |
28 ServiceUtilityProcessHost::~ServiceUtilityProcessHost() { | 32 ServiceUtilityProcessHost::~ServiceUtilityProcessHost() { |
29 } | 33 } |
(...skipping 13 matching lines...) Expand all Loading... |
43 if (!scratch_metafile_dir_->CreateUniqueTempDir()) | 47 if (!scratch_metafile_dir_->CreateUniqueTempDir()) |
44 return false; | 48 return false; |
45 if (!file_util::CreateTemporaryFileInDir(scratch_metafile_dir_->path(), | 49 if (!file_util::CreateTemporaryFileInDir(scratch_metafile_dir_->path(), |
46 &metafile_path_)) { | 50 &metafile_path_)) { |
47 return false; | 51 return false; |
48 } | 52 } |
49 | 53 |
50 if (!StartProcess(false, scratch_metafile_dir_->path())) | 54 if (!StartProcess(false, scratch_metafile_dir_->path())) |
51 return false; | 55 return false; |
52 | 56 |
53 ScopedHandle pdf_file( | 57 base::win::ScopedHandle pdf_file( |
54 ::CreateFile(pdf_path.value().c_str(), | 58 ::CreateFile(pdf_path.value().c_str(), |
55 GENERIC_READ, | 59 GENERIC_READ, |
56 FILE_SHARE_READ | FILE_SHARE_WRITE, | 60 FILE_SHARE_READ | FILE_SHARE_WRITE, |
57 NULL, | 61 NULL, |
58 OPEN_EXISTING, | 62 OPEN_EXISTING, |
59 FILE_ATTRIBUTE_NORMAL, | 63 FILE_ATTRIBUTE_NORMAL, |
60 NULL)); | 64 NULL)); |
61 if (pdf_file == INVALID_HANDLE_VALUE) | 65 if (pdf_file == INVALID_HANDLE_VALUE) |
62 return false; | 66 return false; |
63 HANDLE pdf_file_in_utility_process = NULL; | 67 HANDLE pdf_file_in_utility_process = NULL; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (!metafile.CreateFromFile(metafile_path)) { | 204 if (!metafile.CreateFromFile(metafile_path)) { |
201 OnRenderPDFPagesToMetafileFailed(); | 205 OnRenderPDFPagesToMetafileFailed(); |
202 } else { | 206 } else { |
203 OnRenderPDFPagesToMetafileSucceeded(metafile, highest_rendered_page_number); | 207 OnRenderPDFPagesToMetafileSucceeded(metafile, highest_rendered_page_number); |
204 // Close it so that ScopedTempDir can delete the folder. | 208 // Close it so that ScopedTempDir can delete the folder. |
205 metafile.CloseEmf(); | 209 metafile.CloseEmf(); |
206 } | 210 } |
207 #endif // defined(OS_WIN) | 211 #endif // defined(OS_WIN) |
208 } | 212 } |
209 | 213 |
OLD | NEW |