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

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

Issue 5978003: Make IPC::Channel::Listener:OnMessageReceived have a return value indicating ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 12 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // If we are yet to receive a reply then notify the client that the 121 // If we are yet to receive a reply then notify the client that the
122 // child died. 122 // child died.
123 client_message_loop_proxy_->PostTask( 123 client_message_loop_proxy_->PostTask(
124 FROM_HERE, 124 FROM_HERE,
125 NewRunnableMethod(client_.get(), &Client::OnChildDied)); 125 NewRunnableMethod(client_.get(), &Client::OnChildDied));
126 } 126 }
127 // The base class implementation will delete |this|. 127 // The base class implementation will delete |this|.
128 ServiceChildProcessHost::OnChildDied(); 128 ServiceChildProcessHost::OnChildDied();
129 } 129 }
130 130
131 void ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) { 131 bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) {
132 bool msg_is_ok = false; 132 bool msg_is_ok = false;
133 IPC_BEGIN_MESSAGE_MAP_EX(ServiceUtilityProcessHost, message, msg_is_ok) 133 IPC_BEGIN_MESSAGE_MAP_EX(ServiceUtilityProcessHost, message, msg_is_ok)
134 #if defined(OS_WIN) // This hack is Windows-specific. 134 #if defined(OS_WIN) // This hack is Windows-specific.
135 IPC_MESSAGE_HANDLER(UtilityHostMsg_PreCacheFont, OnPreCacheFont) 135 IPC_MESSAGE_HANDLER(UtilityHostMsg_PreCacheFont, OnPreCacheFont)
136 #endif 136 #endif
137 IPC_MESSAGE_HANDLER(UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded, 137 IPC_MESSAGE_HANDLER(UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded,
138 OnRenderPDFPagesToMetafileSucceeded) 138 OnRenderPDFPagesToMetafileSucceeded)
139 IPC_MESSAGE_UNHANDLED(msg_is_ok__ = MessageForClient(message)) 139 IPC_MESSAGE_UNHANDLED(msg_is_ok__ = MessageForClient(message))
140 IPC_END_MESSAGE_MAP_EX() 140 IPC_END_MESSAGE_MAP_EX()
141 return true;
141 } 142 }
142 143
143 bool ServiceUtilityProcessHost::MessageForClient(const IPC::Message& message) { 144 bool ServiceUtilityProcessHost::MessageForClient(const IPC::Message& message) {
144 DCHECK(waiting_for_reply_); 145 DCHECK(waiting_for_reply_);
145 bool ret = client_message_loop_proxy_->PostTask( 146 bool ret = client_message_loop_proxy_->PostTask(
146 FROM_HERE, 147 FROM_HERE,
147 NewRunnableMethod(client_.get(), &Client::OnMessageReceived, 148 NewRunnableMethod(client_.get(), &Client::OnMessageReceived,
148 message)); 149 message));
149 waiting_for_reply_ = false; 150 waiting_for_reply_ = false;
150 return ret; 151 return ret;
(...skipping 14 matching lines...) Expand all
165 scratch_metafile_dir_->Take(); 166 scratch_metafile_dir_->Take();
166 client_message_loop_proxy_->PostTask( 167 client_message_loop_proxy_->PostTask(
167 FROM_HERE, 168 FROM_HERE,
168 NewRunnableMethod(client_.get(), 169 NewRunnableMethod(client_.get(),
169 &Client::MetafileAvailable, 170 &Client::MetafileAvailable,
170 metafile_path_, 171 metafile_path_,
171 highest_rendered_page_number)); 172 highest_rendered_page_number));
172 waiting_for_reply_ = false; 173 waiting_for_reply_ = false;
173 } 174 }
174 175
175 void ServiceUtilityProcessHost::Client::OnMessageReceived( 176 bool ServiceUtilityProcessHost::Client::OnMessageReceived(
176 const IPC::Message& message) { 177 const IPC::Message& message) {
178 bool handled = true;
177 IPC_BEGIN_MESSAGE_MAP(ServiceUtilityProcessHost, message) 179 IPC_BEGIN_MESSAGE_MAP(ServiceUtilityProcessHost, message)
178 IPC_MESSAGE_HANDLER(UtilityHostMsg_RenderPDFPagesToMetafile_Failed, 180 IPC_MESSAGE_HANDLER(UtilityHostMsg_RenderPDFPagesToMetafile_Failed,
179 Client::OnRenderPDFPagesToMetafileFailed) 181 Client::OnRenderPDFPagesToMetafileFailed)
180 IPC_MESSAGE_HANDLER(UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded, 182 IPC_MESSAGE_HANDLER(UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
181 Client::OnGetPrinterCapsAndDefaultsSucceeded) 183 Client::OnGetPrinterCapsAndDefaultsSucceeded)
182 IPC_MESSAGE_HANDLER(UtilityHostMsg_GetPrinterCapsAndDefaults_Failed, 184 IPC_MESSAGE_HANDLER(UtilityHostMsg_GetPrinterCapsAndDefaults_Failed,
183 Client::OnGetPrinterCapsAndDefaultsFailed) 185 Client::OnGetPrinterCapsAndDefaultsFailed)
186 IPC_MESSAGE_UNHANDLED(handled = false)
184 IPC_END_MESSAGE_MAP_EX() 187 IPC_END_MESSAGE_MAP_EX()
188 return handled;
185 } 189 }
186 190
187 void ServiceUtilityProcessHost::Client::MetafileAvailable( 191 void ServiceUtilityProcessHost::Client::MetafileAvailable(
188 const FilePath& metafile_path, 192 const FilePath& metafile_path,
189 int highest_rendered_page_number) { 193 int highest_rendered_page_number) {
190 // The metafile was created in a temp folder which needs to get deleted after 194 // The metafile was created in a temp folder which needs to get deleted after
191 // we have processed it. 195 // we have processed it.
192 ScopedTempDir scratch_metafile_dir; 196 ScopedTempDir scratch_metafile_dir;
193 scratch_metafile_dir.Set(metafile_path.DirName()); 197 scratch_metafile_dir.Set(metafile_path.DirName());
194 #if defined(OS_WIN) 198 #if defined(OS_WIN)
195 printing::NativeMetafile metafile; 199 printing::NativeMetafile metafile;
196 if (!metafile.CreateFromFile(metafile_path)) { 200 if (!metafile.CreateFromFile(metafile_path)) {
197 OnRenderPDFPagesToMetafileFailed(); 201 OnRenderPDFPagesToMetafileFailed();
198 } else { 202 } else {
199 OnRenderPDFPagesToMetafileSucceeded(metafile, highest_rendered_page_number); 203 OnRenderPDFPagesToMetafileSucceeded(metafile, highest_rendered_page_number);
200 // Close it so that ScopedTempDir can delete the folder. 204 // Close it so that ScopedTempDir can delete the folder.
201 metafile.CloseEmf(); 205 metafile.CloseEmf();
202 } 206 }
203 #endif // defined(OS_WIN) 207 #endif // defined(OS_WIN)
204 } 208 }
205 209
OLDNEW
« no previous file with comments | « chrome/service/service_utility_process_host.h ('k') | chrome/test/automation/automation_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698