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

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

Issue 7866019: New implementation of font precache on Windows. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Update for code review Created 9 years, 3 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 "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 "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/chrome_utility_messages.h" 14 #include "chrome/common/chrome_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/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
22 #include "base/win/scoped_handle.h" 22 #include "base/win/scoped_handle.h"
23 #include "content/common/child_process_messages.h"
23 #include "printing/emf_win.h" 24 #include "printing/emf_win.h"
24 #endif 25 #endif
25 26
26 ServiceUtilityProcessHost::ServiceUtilityProcessHost( 27 ServiceUtilityProcessHost::ServiceUtilityProcessHost(
27 Client* client, base::MessageLoopProxy* client_message_loop_proxy) 28 Client* client, base::MessageLoopProxy* client_message_loop_proxy)
28 : ServiceChildProcessHost(ChildProcessInfo::UTILITY_PROCESS), 29 : ServiceChildProcessHost(ChildProcessInfo::UTILITY_PROCESS),
29 client_(client), 30 client_(client),
30 client_message_loop_proxy_(client_message_loop_proxy), 31 client_message_loop_proxy_(client_message_loop_proxy),
31 waiting_for_reply_(false) { 32 waiting_for_reply_(false) {
33 process_id_ = ChildProcessInfo::GenerateChildProcessUniqueId();
32 } 34 }
33 35
34 ServiceUtilityProcessHost::~ServiceUtilityProcessHost() { 36 ServiceUtilityProcessHost::~ServiceUtilityProcessHost() {
35 } 37 }
36 38
37 bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile( 39 bool ServiceUtilityProcessHost::StartRenderPDFPagesToMetafile(
38 const FilePath& pdf_path, 40 const FilePath& pdf_path,
39 const gfx::Rect& render_area, 41 const gfx::Rect& render_area,
40 int render_dpi, 42 int render_dpi,
41 const std::vector<printing::PageRange>& page_ranges) { 43 const std::vector<printing::PageRange>& page_ranges) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 NewRunnableMethod(client_.get(), &Client::OnChildDied)); 139 NewRunnableMethod(client_.get(), &Client::OnChildDied));
138 } 140 }
139 // The base class implementation will delete |this|. 141 // The base class implementation will delete |this|.
140 ServiceChildProcessHost::OnChildDied(); 142 ServiceChildProcessHost::OnChildDied();
141 } 143 }
142 144
143 bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) { 145 bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) {
144 bool msg_is_ok = false; 146 bool msg_is_ok = false;
145 IPC_BEGIN_MESSAGE_MAP_EX(ServiceUtilityProcessHost, message, msg_is_ok) 147 IPC_BEGIN_MESSAGE_MAP_EX(ServiceUtilityProcessHost, message, msg_is_ok)
146 #if defined(OS_WIN) // This hack is Windows-specific. 148 #if defined(OS_WIN) // This hack is Windows-specific.
147 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_PreCacheFont, OnPreCacheFont) 149 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_PreCacheFont, OnPreCacheFont)
150 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ReleaseCachedFonts,
151 OnReleaseCachedFonts)
148 #endif 152 #endif
149 IPC_MESSAGE_HANDLER( 153 IPC_MESSAGE_HANDLER(
150 ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Succeeded, 154 ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Succeeded,
151 OnRenderPDFPagesToMetafileSucceeded) 155 OnRenderPDFPagesToMetafileSucceeded)
152 IPC_MESSAGE_UNHANDLED(msg_is_ok__ = MessageForClient(message)) 156 IPC_MESSAGE_UNHANDLED(msg_is_ok__ = MessageForClient(message))
153 IPC_END_MESSAGE_MAP_EX() 157 IPC_END_MESSAGE_MAP_EX()
154 return true; 158 return true;
155 } 159 }
156 160
157 bool ServiceUtilityProcessHost::MessageForClient(const IPC::Message& message) { 161 bool ServiceUtilityProcessHost::MessageForClient(const IPC::Message& message) {
158 DCHECK(waiting_for_reply_); 162 DCHECK(waiting_for_reply_);
159 bool ret = client_message_loop_proxy_->PostTask( 163 bool ret = client_message_loop_proxy_->PostTask(
160 FROM_HERE, 164 FROM_HERE,
161 NewRunnableMethod(client_.get(), &Client::OnMessageReceived, 165 NewRunnableMethod(client_.get(), &Client::OnMessageReceived,
162 message)); 166 message));
163 waiting_for_reply_ = false; 167 waiting_for_reply_ = false;
164 return ret; 168 return ret;
165 } 169 }
166 170
167 #if defined(OS_WIN) // This hack is Windows-specific. 171 #if defined(OS_WIN) // This hack is Windows-specific.
168 void ServiceUtilityProcessHost::OnPreCacheFont(const LOGFONT& font) { 172 void ServiceUtilityProcessHost::OnPreCacheFont(const LOGFONT& font) {
169 PreCacheFont(font); 173 PreCacheFont(font, process_id_);
174 }
175
176 void ServiceUtilityProcessHost::OnReleaseCachedFonts() {
177 ReleaseCachedFonts(process_id_);
170 } 178 }
171 #endif // OS_WIN 179 #endif // OS_WIN
172 180
173 void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafileSucceeded( 181 void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafileSucceeded(
174 int highest_rendered_page_number) { 182 int highest_rendered_page_number) {
175 DCHECK(waiting_for_reply_); 183 DCHECK(waiting_for_reply_);
176 // If the metafile was successfully created, we need to take our hands off the 184 // If the metafile was successfully created, we need to take our hands off the
177 // scratch metafile directory. The client will delete it when it is done with 185 // scratch metafile directory. The client will delete it when it is done with
178 // metafile. 186 // metafile.
179 scratch_metafile_dir_->Take(); 187 scratch_metafile_dir_->Take();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 printing::Emf metafile; 226 printing::Emf metafile;
219 if (!metafile.InitFromFile(metafile_path)) { 227 if (!metafile.InitFromFile(metafile_path)) {
220 OnRenderPDFPagesToMetafileFailed(); 228 OnRenderPDFPagesToMetafileFailed();
221 } else { 229 } else {
222 OnRenderPDFPagesToMetafileSucceeded(metafile, 230 OnRenderPDFPagesToMetafileSucceeded(metafile,
223 highest_rendered_page_number); 231 highest_rendered_page_number);
224 } 232 }
225 #endif // defined(OS_WIN) 233 #endif // defined(OS_WIN)
226 } 234 }
227 235
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698