OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/browser_render_process_host.h" | 8 #include "content/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 483 } |
484 } | 484 } |
485 | 485 |
486 int BrowserRenderProcessHost::VisibleWidgetCount() const { | 486 int BrowserRenderProcessHost::VisibleWidgetCount() const { |
487 return visible_widgets_; | 487 return visible_widgets_; |
488 } | 488 } |
489 | 489 |
490 void BrowserRenderProcessHost::AppendRendererCommandLine( | 490 void BrowserRenderProcessHost::AppendRendererCommandLine( |
491 CommandLine* command_line) const { | 491 CommandLine* command_line) const { |
492 // Pass the process type first, so it shows first in process listings. | 492 // Pass the process type first, so it shows first in process listings. |
493 // Extensions use a special pseudo-process type to make them distinguishable, | |
494 // even though they're just renderers. | |
495 command_line->AppendSwitchASCII(switches::kProcessType, | 493 command_line->AppendSwitchASCII(switches::kProcessType, |
496 is_extension_process_ ? switches::kExtensionProcess : | 494 switches::kRendererProcess); |
497 switches::kRendererProcess); | |
498 | 495 |
499 if (accessibility_enabled_) | 496 if (accessibility_enabled_) |
500 command_line->AppendSwitch(switches::kEnableAccessibility); | 497 command_line->AppendSwitch(switches::kEnableAccessibility); |
501 | 498 |
502 // Now send any options from our own command line we want to propagate. | 499 // Now send any options from our own command line we want to propagate. |
503 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 500 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
504 PropagateBrowserCommandLineToRenderer(browser_command_line, command_line); | 501 PropagateBrowserCommandLineToRenderer(browser_command_line, command_line); |
505 | 502 |
506 // Pass on the browser locale. | 503 // Pass on the browser locale. |
507 const std::string locale = | 504 const std::string locale = |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 } | 854 } |
858 | 855 |
859 void BrowserRenderProcessHost::ProcessDied( | 856 void BrowserRenderProcessHost::ProcessDied( |
860 base::TerminationStatus status, int exit_code, bool was_alive) { | 857 base::TerminationStatus status, int exit_code, bool was_alive) { |
861 // Our child process has died. If we didn't expect it, it's a crash. | 858 // Our child process has died. If we didn't expect it, it's a crash. |
862 // In any case, we need to let everyone know it's gone. | 859 // In any case, we need to let everyone know it's gone. |
863 // The OnChannelError notification can fire multiple times due to nested sync | 860 // The OnChannelError notification can fire multiple times due to nested sync |
864 // calls to a renderer. If we don't have a valid channel here it means we | 861 // calls to a renderer. If we don't have a valid channel here it means we |
865 // already handled the error. | 862 // already handled the error. |
866 | 863 |
867 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || | 864 RendererClosedDetails details(status, exit_code, was_alive); |
868 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { | |
869 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", | |
870 is_extension_process_ ? 2 : 1); | |
871 if (was_alive) { | |
872 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashesWasAlive", | |
873 is_extension_process_ ? 2 : 1); | |
874 } | |
875 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | |
876 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", | |
877 is_extension_process_ ? 2 : 1); | |
878 if (was_alive) { | |
879 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKillsWasAlive", | |
880 is_extension_process_ ? 2 : 1); | |
881 } | |
882 } | |
883 | |
884 RendererClosedDetails details(status, exit_code, is_extension_process_); | |
885 NotificationService::current()->Notify( | 865 NotificationService::current()->Notify( |
886 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 866 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
887 Source<RenderProcessHost>(this), | 867 Source<RenderProcessHost>(this), |
888 Details<RendererClosedDetails>(&details)); | 868 Details<RendererClosedDetails>(&details)); |
889 | 869 |
890 child_process_launcher_.reset(); | 870 child_process_launcher_.reset(); |
891 channel_.reset(); | 871 channel_.reset(); |
892 | 872 |
893 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); | 873 IDMap<IPC::Channel::Listener>::iterator iter(&listeners_); |
894 while (!iter.IsAtEnd()) { | 874 while (!iter.IsAtEnd()) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { | 974 void BrowserRenderProcessHost::OnRevealFolderInOS(const FilePath& path) { |
995 // Only honor the request if appropriate persmissions are granted. | 975 // Only honor the request if appropriate persmissions are granted. |
996 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) | 976 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(id(), path)) |
997 content::GetContentClient()->browser()->OpenItem(path); | 977 content::GetContentClient()->browser()->OpenItem(path); |
998 } | 978 } |
999 | 979 |
1000 void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 980 void BrowserRenderProcessHost::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
1001 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> | 981 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> |
1002 MHTMLGenerated(job_id, data_size); | 982 MHTMLGenerated(job_id, data_size); |
1003 } | 983 } |
OLD | NEW |