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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 316 |
317 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { | 317 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { |
318 bool msg_is_ok = true; | 318 bool msg_is_ok = true; |
319 bool handled = true; | 319 bool handled = true; |
320 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) | 320 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) |
321 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, | 321 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, |
322 OnWorkerContextClosed) | 322 OnWorkerContextClosed) |
323 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) | 323 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) |
324 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) | 324 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) |
325 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) | 325 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) |
| 326 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_ForceKillWorker, |
| 327 OnForceKillWorkerProcess) |
326 IPC_MESSAGE_UNHANDLED(handled = false) | 328 IPC_MESSAGE_UNHANDLED(handled = false) |
327 IPC_END_MESSAGE_MAP_EX() | 329 IPC_END_MESSAGE_MAP_EX() |
328 | 330 |
329 if (!msg_is_ok) { | 331 if (!msg_is_ok) { |
330 NOTREACHED(); | 332 NOTREACHED(); |
331 RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); | 333 RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); |
332 base::KillProcess( | 334 base::KillProcess( |
333 process_->GetData().handle, RESULT_CODE_KILLED_BAD_MESSAGE, false); | 335 process_->GetData().handle, RESULT_CODE_KILLED_BAD_MESSAGE, false); |
334 } | 336 } |
335 | 337 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 } | 388 } |
387 | 389 |
388 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, | 390 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, |
389 const GURL& url, | 391 const GURL& url, |
390 const string16& name, | 392 const string16& name, |
391 bool* result) { | 393 bool* result) { |
392 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( | 394 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( |
393 url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); | 395 url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); |
394 } | 396 } |
395 | 397 |
| 398 void WorkerProcessHost::OnForceKillWorkerProcess() { |
| 399 if (process_ && process_launched_) |
| 400 base::KillProcess( |
| 401 process_->GetData().handle, RESULT_CODE_NORMAL_EXIT, false); |
| 402 else |
| 403 RecordAction(UserMetricsAction("WorkerProcess_BadProcessToKill")); |
| 404 } |
| 405 |
396 void WorkerProcessHost::RelayMessage( | 406 void WorkerProcessHost::RelayMessage( |
397 const IPC::Message& message, | 407 const IPC::Message& message, |
398 WorkerMessageFilter* filter, | 408 WorkerMessageFilter* filter, |
399 int route_id) { | 409 int route_id) { |
400 if (message.type() == WorkerMsg_Connect::ID) { | 410 if (message.type() == WorkerMsg_Connect::ID) { |
401 // Crack the SharedWorker Connect message to setup routing for the port. | 411 // Crack the SharedWorker Connect message to setup routing for the port. |
402 int sent_message_port_id; | 412 int sent_message_port_id; |
403 int new_routing_id; | 413 int new_routing_id; |
404 if (!WorkerMsg_Connect::Read( | 414 if (!WorkerMsg_Connect::Read( |
405 &message, &sent_message_port_id, &new_routing_id)) { | 415 &message, &sent_message_port_id, &new_routing_id)) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 return false; | 699 return false; |
690 } | 700 } |
691 | 701 |
692 WorkerProcessHost::WorkerInstance::FilterInfo | 702 WorkerProcessHost::WorkerInstance::FilterInfo |
693 WorkerProcessHost::WorkerInstance::GetFilter() const { | 703 WorkerProcessHost::WorkerInstance::GetFilter() const { |
694 DCHECK(NumFilters() == 1); | 704 DCHECK(NumFilters() == 1); |
695 return *filters_.begin(); | 705 return *filters_.begin(); |
696 } | 706 } |
697 | 707 |
698 } // namespace content | 708 } // namespace content |
OLD | NEW |