OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { | 312 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { |
313 bool msg_is_ok = true; | 313 bool msg_is_ok = true; |
314 bool handled = true; | 314 bool handled = true; |
315 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) | 315 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) |
316 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, | 316 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, |
317 OnWorkerContextClosed) | 317 OnWorkerContextClosed) |
318 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) | 318 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) |
319 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) | 319 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) |
320 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) | 320 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) |
321 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_ForceKillWorker, | |
322 OnForceKillWorkerProcess) | |
323 IPC_MESSAGE_UNHANDLED(handled = false) | 321 IPC_MESSAGE_UNHANDLED(handled = false) |
324 IPC_END_MESSAGE_MAP_EX() | 322 IPC_END_MESSAGE_MAP_EX() |
325 | 323 |
326 if (!msg_is_ok) { | 324 if (!msg_is_ok) { |
327 NOTREACHED(); | 325 NOTREACHED(); |
328 RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); | 326 RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); |
329 base::KillProcess( | 327 base::KillProcess( |
330 process_->GetData().handle, RESULT_CODE_KILLED_BAD_MESSAGE, false); | 328 process_->GetData().handle, RESULT_CODE_KILLED_BAD_MESSAGE, false); |
331 } | 329 } |
332 | 330 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } | 381 } |
384 | 382 |
385 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, | 383 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, |
386 const GURL& url, | 384 const GURL& url, |
387 const string16& name, | 385 const string16& name, |
388 bool* result) { | 386 bool* result) { |
389 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( | 387 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( |
390 url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); | 388 url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); |
391 } | 389 } |
392 | 390 |
393 void WorkerProcessHost::OnForceKillWorkerProcess() { | |
394 if (process_ && process_launched_) | |
395 base::KillProcess( | |
396 process_->GetData().handle, RESULT_CODE_NORMAL_EXIT, false); | |
397 else | |
398 RecordAction(UserMetricsAction("WorkerProcess_BadProcessToKill")); | |
399 } | |
400 | |
401 void WorkerProcessHost::RelayMessage( | 391 void WorkerProcessHost::RelayMessage( |
402 const IPC::Message& message, | 392 const IPC::Message& message, |
403 WorkerMessageFilter* filter, | 393 WorkerMessageFilter* filter, |
404 int route_id) { | 394 int route_id) { |
405 if (message.type() == WorkerMsg_PostMessage::ID) { | 395 if (message.type() == WorkerMsg_PostMessage::ID) { |
406 // We want to send the receiver a routing id for the new channel, so | 396 // We want to send the receiver a routing id for the new channel, so |
407 // crack the message first. | 397 // crack the message first. |
408 string16 msg; | 398 string16 msg; |
409 std::vector<int> sent_message_port_ids; | 399 std::vector<int> sent_message_port_ids; |
410 std::vector<int> new_routing_ids; | 400 std::vector<int> new_routing_ids; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 return false; | 711 return false; |
722 } | 712 } |
723 | 713 |
724 WorkerProcessHost::WorkerInstance::FilterInfo | 714 WorkerProcessHost::WorkerInstance::FilterInfo |
725 WorkerProcessHost::WorkerInstance::GetFilter() const { | 715 WorkerProcessHost::WorkerInstance::GetFilter() const { |
726 DCHECK(NumFilters() == 1); | 716 DCHECK(NumFilters() == 1); |
727 return *filters_.begin(); | 717 return *filters_.begin(); |
728 } | 718 } |
729 | 719 |
730 } // namespace content | 720 } // namespace content |
OLD | NEW |