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

Side by Side Diff: content/browser/worker_host/worker_process_host.cc

Issue 7012007: Chrome side of having the WebKit FileSystem API use WebPermissionClient for checking if using fil... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
« no previous file with comments | « content/browser/worker_host/worker_process_host.h ('k') | content/common/worker_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/worker_host/worker_process_host.h" 5 #include "content/browser/worker_host/worker_process_host.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 base::PLATFORM_FILE_CREATE_ALWAYS | 194 base::PLATFORM_FILE_CREATE_ALWAYS |
195 base::PLATFORM_FILE_READ | 195 base::PLATFORM_FILE_READ |
196 base::PLATFORM_FILE_WRITE | 196 base::PLATFORM_FILE_WRITE |
197 base::PLATFORM_FILE_EXCLUSIVE_READ | 197 base::PLATFORM_FILE_EXCLUSIVE_READ |
198 base::PLATFORM_FILE_EXCLUSIVE_WRITE | 198 base::PLATFORM_FILE_EXCLUSIVE_WRITE |
199 base::PLATFORM_FILE_ASYNC | 199 base::PLATFORM_FILE_ASYNC |
200 base::PLATFORM_FILE_TRUNCATE | 200 base::PLATFORM_FILE_TRUNCATE |
201 base::PLATFORM_FILE_WRITE_ATTRIBUTES); 201 base::PLATFORM_FILE_WRITE_ATTRIBUTES);
202 } 202 }
203 203
204 // Call the embedder first so that their IPC filters have priority.
205 content::GetContentClient()->browser()->WorkerProcessHostCreated(this);
204 CreateMessageFilters(render_process_id); 206 CreateMessageFilters(render_process_id);
205 207
206 content::GetContentClient()->browser()->WorkerProcessHostCreated(this);
207
208 return true; 208 return true;
209 } 209 }
210 210
211 void WorkerProcessHost::CreateMessageFilters(int render_process_id) { 211 void WorkerProcessHost::CreateMessageFilters(int render_process_id) {
212 DCHECK(resource_context_); 212 DCHECK(resource_context_);
213 net::URLRequestContext* request_context = 213 net::URLRequestContext* request_context =
214 resource_context_->request_context(); 214 resource_context_->request_context();
215 215
216 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter( 216 ResourceMessageFilter* resource_message_filter = new ResourceMessageFilter(
217 id(), WORKER_PROCESS, resource_context_, 217 id(), WORKER_PROCESS, resource_context_,
218 new URLRequestContextSelector(request_context), 218 new URLRequestContextSelector(request_context),
219 resource_dispatcher_host_); 219 resource_dispatcher_host_);
220 AddFilter(resource_message_filter); 220 AddFilter(resource_message_filter);
221 221
222 worker_message_filter_ = new WorkerMessageFilter( 222 worker_message_filter_ = new WorkerMessageFilter(
223 render_process_id, 223 render_process_id,
224 resource_context_, 224 resource_context_,
225 resource_dispatcher_host_, 225 resource_dispatcher_host_,
226 NewCallbackWithReturnValue( 226 NewCallbackWithReturnValue(
227 WorkerService::GetInstance(), &WorkerService::next_worker_route_id)); 227 WorkerService::GetInstance(), &WorkerService::next_worker_route_id));
228 AddFilter(worker_message_filter_); 228 AddFilter(worker_message_filter_);
229 AddFilter(new AppCacheDispatcherHost(resource_context_, id())); 229 AddFilter(new AppCacheDispatcherHost(resource_context_, id()));
230 AddFilter(new FileSystemDispatcherHost( 230 AddFilter(new FileSystemDispatcherHost(
231 request_context, 231 request_context, resource_context_->file_system_context()));
232 resource_context_->host_content_settings_map(),
233 resource_context_->file_system_context()));
234 AddFilter(new FileUtilitiesMessageFilter(id())); 232 AddFilter(new FileUtilitiesMessageFilter(id()));
235 AddFilter( 233 AddFilter(
236 new BlobMessageFilter(id(), resource_context_->blob_storage_context())); 234 new BlobMessageFilter(id(), resource_context_->blob_storage_context()));
237 AddFilter(new MimeRegistryMessageFilter()); 235 AddFilter(new MimeRegistryMessageFilter());
238 AddFilter(new DatabaseMessageFilter( 236 AddFilter(new DatabaseMessageFilter(
239 resource_context_->database_tracker())); 237 resource_context_->database_tracker()));
240 238
241 SocketStreamDispatcherHost* socket_stream_dispatcher_host = 239 SocketStreamDispatcherHost* socket_stream_dispatcher_host =
242 new SocketStreamDispatcherHost( 240 new SocketStreamDispatcherHost(
243 new URLRequestContextSelector(request_context)); 241 new URLRequestContextSelector(request_context));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 284
287 void WorkerProcessHost::OnProcessLaunched() { 285 void WorkerProcessHost::OnProcessLaunched() {
288 } 286 }
289 287
290 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { 288 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) {
291 bool msg_is_ok = true; 289 bool msg_is_ok = true;
292 bool handled = true; 290 bool handled = true;
293 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) 291 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok)
294 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, 292 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed,
295 OnWorkerContextClosed) 293 OnWorkerContextClosed)
294 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase)
295 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem)
296 IPC_MESSAGE_UNHANDLED(handled = false) 296 IPC_MESSAGE_UNHANDLED(handled = false)
297 IPC_END_MESSAGE_MAP_EX() 297 IPC_END_MESSAGE_MAP_EX()
298 298
299 if (!msg_is_ok) { 299 if (!msg_is_ok) {
300 NOTREACHED(); 300 NOTREACHED();
301 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); 301 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_WPH"));
302 base::KillProcess(handle(), ResultCodes::KILLED_BAD_MESSAGE, false); 302 base::KillProcess(handle(), ResultCodes::KILLED_BAD_MESSAGE, false);
303 } 303 }
304 304
305 if (handled) 305 if (handled)
(...skipping 25 matching lines...) Expand all
331 if (i->worker_route_id() == worker_route_id) { 331 if (i->worker_route_id() == worker_route_id) {
332 // Set the closed flag - this will stop any further messages from 332 // Set the closed flag - this will stop any further messages from
333 // being sent to the worker (messages can still be sent from the worker, 333 // being sent to the worker (messages can still be sent from the worker,
334 // for exception reporting, etc). 334 // for exception reporting, etc).
335 i->set_closed(true); 335 i->set_closed(true);
336 break; 336 break;
337 } 337 }
338 } 338 }
339 } 339 }
340 340
341 void WorkerProcessHost::OnAllowDatabase(int worker_route_id,
342 const GURL& url,
343 const string16& name,
344 const string16& display_name,
345 unsigned long estimated_size,
346 bool* result) {
347 *result = true;
348 }
349
350 void WorkerProcessHost::OnAllowFileSystem(int worker_route_id,
351 const GURL& url,
352 bool* result) {
353 *result = true;
354 }
355
341 void WorkerProcessHost::RelayMessage( 356 void WorkerProcessHost::RelayMessage(
342 const IPC::Message& message, 357 const IPC::Message& message,
343 WorkerMessageFilter* filter, 358 WorkerMessageFilter* filter,
344 int route_id) { 359 int route_id) {
345 if (message.type() == WorkerMsg_PostMessage::ID) { 360 if (message.type() == WorkerMsg_PostMessage::ID) {
346 // We want to send the receiver a routing id for the new channel, so 361 // We want to send the receiver a routing id for the new channel, so
347 // crack the message first. 362 // crack the message first.
348 string16 msg; 363 string16 msg;
349 std::vector<int> sent_message_port_ids; 364 std::vector<int> sent_message_port_ids;
350 std::vector<int> new_routing_ids; 365 std::vector<int> new_routing_ids;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 616 }
602 } 617 }
603 return false; 618 return false;
604 } 619 }
605 620
606 WorkerProcessHost::WorkerInstance::FilterInfo 621 WorkerProcessHost::WorkerInstance::FilterInfo
607 WorkerProcessHost::WorkerInstance::GetFilter() const { 622 WorkerProcessHost::WorkerInstance::GetFilter() const {
608 DCHECK(NumFilters() == 1); 623 DCHECK(NumFilters() == 1);
609 return *filters_.begin(); 624 return *filters_.begin();
610 } 625 }
OLDNEW
« no previous file with comments | « content/browser/worker_host/worker_process_host.h ('k') | content/common/worker_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698