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

Side by Side Diff: chrome/service/service_utility_process_host.cc

Issue 6544028: Create a Factory for NativeMetafile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 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/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_ptr.h"
12 #include "base/scoped_temp_dir.h" 13 #include "base/scoped_temp_dir.h"
13 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/utility_messages.h" 15 #include "chrome/common/utility_messages.h"
15 #include "ipc/ipc_switches.h" 16 #include "ipc/ipc_switches.h"
16 #include "printing/native_metafile.h" 17 #include "printing/metafile_factory.h"
17 #include "printing/page_range.h" 18 #include "printing/page_range.h"
18 #include "ui/base/ui_base_switches.h" 19 #include "ui/base/ui_base_switches.h"
19 #include "ui/gfx/rect.h" 20 #include "ui/gfx/rect.h"
20 21
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 #include "base/win/scoped_handle.h" 23 #include "base/win/scoped_handle.h"
23 #endif 24 #endif
24 25
25 ServiceUtilityProcessHost::ServiceUtilityProcessHost( 26 ServiceUtilityProcessHost::ServiceUtilityProcessHost(
26 Client* client, base::MessageLoopProxy* client_message_loop_proxy) 27 Client* client, base::MessageLoopProxy* client_message_loop_proxy)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 196
196 void ServiceUtilityProcessHost::Client::MetafileAvailable( 197 void ServiceUtilityProcessHost::Client::MetafileAvailable(
197 const FilePath& metafile_path, 198 const FilePath& metafile_path,
198 int highest_rendered_page_number) { 199 int highest_rendered_page_number) {
199 // 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
200 // we have processed it. 201 // we have processed it.
201 ScopedTempDir scratch_metafile_dir; 202 ScopedTempDir scratch_metafile_dir;
202 if (!scratch_metafile_dir.Set(metafile_path.DirName())) 203 if (!scratch_metafile_dir.Set(metafile_path.DirName()))
203 LOG(WARNING) << "Unable to set scratch metafile directory"; 204 LOG(WARNING) << "Unable to set scratch metafile directory";
204 #if defined(OS_WIN) 205 #if defined(OS_WIN)
205 printing::NativeMetafile metafile; 206 scoped_ptr<printing::NativeMetafile> metafile_ptr(
206 if (!metafile.CreateFromFile(metafile_path)) { 207 printing::MetafileFactory::GetMetafile());
208 if (!metafile_ptr->CreateFromFile(metafile_path)) {
207 OnRenderPDFPagesToMetafileFailed(); 209 OnRenderPDFPagesToMetafileFailed();
208 } else { 210 } else {
209 OnRenderPDFPagesToMetafileSucceeded(metafile, highest_rendered_page_number); 211 OnRenderPDFPagesToMetafileSucceeded(*metafile_ptr.get(), highest_rendered_pa ge_number);
210 // Close it so that ScopedTempDir can delete the folder. 212 // Close it so that ScopedTempDir can delete the folder.
211 metafile.CloseEmf(); 213 metafile_ptr->CloseEmf();
212 } 214 }
213 #endif // defined(OS_WIN) 215 #endif // defined(OS_WIN)
214 } 216 }
215 217
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698