| 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 return false; | 366 return false; |
| 367 } | 367 } |
| 368 | 368 |
| 369 void WorkerProcessHost::OnProcessLaunched() { | 369 void WorkerProcessHost::OnProcessLaunched() { |
| 370 process_launched_ = true; | 370 process_launched_ = true; |
| 371 | 371 |
| 372 WorkerServiceImpl::GetInstance()->NotifyWorkerProcessCreated(); | 372 WorkerServiceImpl::GetInstance()->NotifyWorkerProcessCreated(); |
| 373 } | 373 } |
| 374 | 374 |
| 375 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { | 375 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { |
| 376 bool msg_is_ok = true; | |
| 377 bool handled = true; | 376 bool handled = true; |
| 378 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) | 377 IPC_BEGIN_MESSAGE_MAP(WorkerProcessHost, message) |
| 379 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, | 378 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, |
| 380 OnWorkerContextClosed) | 379 OnWorkerContextClosed) |
| 381 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextDestroyed, | 380 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextDestroyed, |
| 382 OnWorkerContextDestroyed) | 381 OnWorkerContextDestroyed) |
| 383 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoaded, | 382 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoaded, |
| 384 OnWorkerScriptLoaded) | 383 OnWorkerScriptLoaded) |
| 385 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoadFailed, | 384 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerScriptLoadFailed, |
| 386 OnWorkerScriptLoadFailed) | 385 OnWorkerScriptLoadFailed) |
| 387 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerConnected, | 386 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerConnected, |
| 388 OnWorkerConnected) | 387 OnWorkerConnected) |
| 389 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) | 388 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) |
| 390 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) | 389 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) |
| 391 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) | 390 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) |
| 392 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_ForceKillWorker, | 391 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_ForceKillWorker, |
| 393 OnForceKillWorkerProcess) | 392 OnForceKillWorkerProcess) |
| 394 IPC_MESSAGE_UNHANDLED(handled = false) | 393 IPC_MESSAGE_UNHANDLED(handled = false) |
| 395 IPC_END_MESSAGE_MAP_EX() | 394 IPC_END_MESSAGE_MAP_EX() |
| 396 | 395 |
| 397 if (!msg_is_ok) { | |
| 398 NOTREACHED(); | |
| 399 RecordAction(base::UserMetricsAction("BadMessageTerminate_WPH")); | |
| 400 base::KillProcess( | |
| 401 process_->GetData().handle, RESULT_CODE_KILLED_BAD_MESSAGE, false); | |
| 402 } | |
| 403 | |
| 404 return handled; | 396 return handled; |
| 405 } | 397 } |
| 406 | 398 |
| 407 // Sent to notify the browser process when a worker context invokes close(), so | 399 // Sent to notify the browser process when a worker context invokes close(), so |
| 408 // no new connections are sent to shared workers. | 400 // no new connections are sent to shared workers. |
| 409 void WorkerProcessHost::OnWorkerContextClosed(int worker_route_id) { | 401 void WorkerProcessHost::OnWorkerContextClosed(int worker_route_id) { |
| 410 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { | 402 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { |
| 411 if (i->worker_route_id() == worker_route_id) { | 403 if (i->worker_route_id() == worker_route_id) { |
| 412 // Set the closed flag - this will stop any further messages from | 404 // Set the closed flag - this will stop any further messages from |
| 413 // being sent to the worker (messages can still be sent from the worker, | 405 // being sent to the worker (messages can still be sent from the worker, |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 return false; | 820 return false; |
| 829 } | 821 } |
| 830 | 822 |
| 831 WorkerProcessHost::WorkerInstance::FilterInfo | 823 WorkerProcessHost::WorkerInstance::FilterInfo |
| 832 WorkerProcessHost::WorkerInstance::GetFilter() const { | 824 WorkerProcessHost::WorkerInstance::GetFilter() const { |
| 833 DCHECK(NumFilters() == 1); | 825 DCHECK(NumFilters() == 1); |
| 834 return *filters_.begin(); | 826 return *filters_.begin(); |
| 835 } | 827 } |
| 836 | 828 |
| 837 } // namespace content | 829 } // namespace content |
| OLD | NEW |