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

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

Issue 23496052: Kill worker process by way of a sync IPC message before it cleans up. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 7 years, 3 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) 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 330
331 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) { 331 bool WorkerProcessHost::OnMessageReceived(const IPC::Message& message) {
332 bool msg_is_ok = true; 332 bool msg_is_ok = true;
333 bool handled = true; 333 bool handled = true;
334 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok) 334 IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok)
335 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed, 335 IPC_MESSAGE_HANDLER(WorkerHostMsg_WorkerContextClosed,
336 OnWorkerContextClosed) 336 OnWorkerContextClosed)
337 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase) 337 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowDatabase, OnAllowDatabase)
338 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem) 338 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowFileSystem, OnAllowFileSystem)
339 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB) 339 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_AllowIndexedDB, OnAllowIndexedDB)
340 IPC_MESSAGE_HANDLER(WorkerProcessHostMsg_ForceKillWorker,
341 OnForceKillWorkerProcess)
340 IPC_MESSAGE_UNHANDLED(handled = false) 342 IPC_MESSAGE_UNHANDLED(handled = false)
341 IPC_END_MESSAGE_MAP_EX() 343 IPC_END_MESSAGE_MAP_EX()
342 344
343 if (!msg_is_ok) { 345 if (!msg_is_ok) {
344 NOTREACHED(); 346 NOTREACHED();
345 RecordAction(UserMetricsAction("BadMessageTerminate_WPH")); 347 RecordAction(UserMetricsAction("BadMessageTerminate_WPH"));
346 base::KillProcess( 348 base::KillProcess(
347 process_->GetData().handle, RESULT_CODE_KILLED_BAD_MESSAGE, false); 349 process_->GetData().handle, RESULT_CODE_KILLED_BAD_MESSAGE, false);
348 } 350 }
349 351
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } 402 }
401 403
402 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id, 404 void WorkerProcessHost::OnAllowIndexedDB(int worker_route_id,
403 const GURL& url, 405 const GURL& url,
404 const string16& name, 406 const string16& name,
405 bool* result) { 407 bool* result) {
406 *result = GetContentClient()->browser()->AllowWorkerIndexedDB( 408 *result = GetContentClient()->browser()->AllowWorkerIndexedDB(
407 url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id)); 409 url, name, resource_context_, GetRenderViewIDsForWorker(worker_route_id));
408 } 410 }
409 411
412 void WorkerProcessHost::OnForceKillWorkerProcess(int worker_route_id,
413 base::ProcessHandle handle,
414 bool* result) {
415 *result = base::KillProcess(handle, 0, false);
416 }
417
410 void WorkerProcessHost::RelayMessage( 418 void WorkerProcessHost::RelayMessage(
411 const IPC::Message& message, 419 const IPC::Message& message,
412 WorkerMessageFilter* filter, 420 WorkerMessageFilter* filter,
413 int route_id) { 421 int route_id) {
414 if (message.type() == WorkerMsg_PostMessage::ID) { 422 if (message.type() == WorkerMsg_PostMessage::ID) {
415 // We want to send the receiver a routing id for the new channel, so 423 // We want to send the receiver a routing id for the new channel, so
416 // crack the message first. 424 // crack the message first.
417 string16 msg; 425 string16 msg;
418 std::vector<int> sent_message_port_ids; 426 std::vector<int> sent_message_port_ids;
419 std::vector<int> new_routing_ids; 427 std::vector<int> new_routing_ids;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 return false; 726 return false;
719 } 727 }
720 728
721 WorkerProcessHost::WorkerInstance::FilterInfo 729 WorkerProcessHost::WorkerInstance::FilterInfo
722 WorkerProcessHost::WorkerInstance::GetFilter() const { 730 WorkerProcessHost::WorkerInstance::GetFilter() const {
723 DCHECK(NumFilters() == 1); 731 DCHECK(NumFilters() == 1);
724 return *filters_.begin(); 732 return *filters_.begin();
725 } 733 }
726 734
727 } // namespace content 735 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698