| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
| 6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
| 7 | 7 |
| 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 base::KillProcess(process, ResultCodes::KILLED_BAD_MESSAGE, false); | 661 base::KillProcess(process, ResultCodes::KILLED_BAD_MESSAGE, false); |
| 662 } | 662 } |
| 663 | 663 |
| 664 void BrowserRenderProcessHost::OnChannelError() { | 664 void BrowserRenderProcessHost::OnChannelError() { |
| 665 // Our child process has died. If we didn't expect it, it's a crash. | 665 // Our child process has died. If we didn't expect it, it's a crash. |
| 666 // In any case, we need to let everyone know it's gone. | 666 // In any case, we need to let everyone know it's gone. |
| 667 | 667 |
| 668 DCHECK(process_.handle()); | 668 DCHECK(process_.handle()); |
| 669 DCHECK(channel_.get()); | 669 DCHECK(channel_.get()); |
| 670 | 670 |
| 671 if (base::DidProcessCrash(process_.handle())) { | 671 bool child_exited; |
| 672 if (base::DidProcessCrash(&child_exited, process_.handle())) { |
| 672 NotificationService::current()->Notify( | 673 NotificationService::current()->Notify( |
| 673 NotificationType::RENDERER_PROCESS_CRASHED, | 674 NotificationType::RENDERER_PROCESS_CRASHED, |
| 674 Source<RenderProcessHost>(this), NotificationService::NoDetails()); | 675 Source<RenderProcessHost>(this), NotificationService::NoDetails()); |
| 675 } | 676 } |
| 676 | 677 |
| 677 process_.Close(); | 678 // POSIX: If the process crashed, then the kernel closed the socket for it |
| 679 // and so the child has already died by the time we get here. Since |
| 680 // DidProcessCrash called waitpid with WNOHANG, it'll reap the process. |
| 681 // However, if DidProcessCrash didn't reap the child, we'll need to in |
| 682 // ~BrowserRenderProcessHost via ProcessWatcher. So we can't close the handle |
| 683 // here. |
| 684 // |
| 685 // This is moot on Windows where |child_exited| will always be true. |
| 686 if (child_exited) |
| 687 process_.Close(); |
| 688 |
| 678 channel_.reset(); | 689 channel_.reset(); |
| 679 | 690 |
| 680 // This process should detach all the listeners, causing the object to be | 691 // This process should detach all the listeners, causing the object to be |
| 681 // deleted. We therefore need a stack copy of the web view list to avoid | 692 // deleted. We therefore need a stack copy of the web view list to avoid |
| 682 // crashing when checking for the termination condition the last time. | 693 // crashing when checking for the termination condition the last time. |
| 683 IDMap<IPC::Channel::Listener> local_listeners(listeners_); | 694 IDMap<IPC::Channel::Listener> local_listeners(listeners_); |
| 684 for (listeners_iterator i = local_listeners.begin(); | 695 for (listeners_iterator i = local_listeners.begin(); |
| 685 i != local_listeners.end(); ++i) { | 696 i != local_listeners.end(); ++i) { |
| 686 i->second->OnMessageReceived(ViewHostMsg_RenderViewGone(i->first)); | 697 i->second->OnMessageReceived(ViewHostMsg_RenderViewGone(i->first)); |
| 687 } | 698 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 SendUserScriptsUpdate(shared_memory); | 791 SendUserScriptsUpdate(shared_memory); |
| 781 } | 792 } |
| 782 break; | 793 break; |
| 783 } | 794 } |
| 784 default: { | 795 default: { |
| 785 NOTREACHED(); | 796 NOTREACHED(); |
| 786 break; | 797 break; |
| 787 } | 798 } |
| 788 } | 799 } |
| 789 } | 800 } |
| OLD | NEW |