Chromium Code Reviews| 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 // 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/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 #include "content/common/child_process_host_impl.h" | 107 #include "content/common/child_process_host_impl.h" |
| 108 #include "content/common/child_process_messages.h" | 108 #include "content/common/child_process_messages.h" |
| 109 #include "content/common/content_switches_internal.h" | 109 #include "content/common/content_switches_internal.h" |
| 110 #include "content/common/frame_messages.h" | 110 #include "content/common/frame_messages.h" |
| 111 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 111 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 112 #include "content/common/gpu/gpu_messages.h" | 112 #include "content/common/gpu/gpu_messages.h" |
| 113 #include "content/common/mojo/channel_init.h" | 113 #include "content/common/mojo/channel_init.h" |
| 114 #include "content/common/mojo/mojo_messages.h" | 114 #include "content/common/mojo/mojo_messages.h" |
| 115 #include "content/common/resource_messages.h" | 115 #include "content/common/resource_messages.h" |
| 116 #include "content/common/view_messages.h" | 116 #include "content/common/view_messages.h" |
| 117 #include "content/public/browser/bad_message.h" | |
| 117 #include "content/public/browser/browser_context.h" | 118 #include "content/public/browser/browser_context.h" |
| 118 #include "content/public/browser/content_browser_client.h" | 119 #include "content/public/browser/content_browser_client.h" |
| 119 #include "content/public/browser/navigator_connect_context.h" | 120 #include "content/public/browser/navigator_connect_context.h" |
| 120 #include "content/public/browser/notification_service.h" | 121 #include "content/public/browser/notification_service.h" |
| 121 #include "content/public/browser/notification_types.h" | 122 #include "content/public/browser/notification_types.h" |
| 122 #include "content/public/browser/render_process_host_factory.h" | 123 #include "content/public/browser/render_process_host_factory.h" |
| 123 #include "content/public/browser/render_process_host_observer.h" | 124 #include "content/public/browser/render_process_host_observer.h" |
| 124 #include "content/public/browser/render_widget_host.h" | 125 #include "content/public/browser/render_widget_host.h" |
| 125 #include "content/public/browser/render_widget_host_iterator.h" | 126 #include "content/public/browser/render_widget_host_iterator.h" |
| 126 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 127 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1036 | 1037 |
| 1037 void RenderProcessHostImpl::AddObserver(RenderProcessHostObserver* observer) { | 1038 void RenderProcessHostImpl::AddObserver(RenderProcessHostObserver* observer) { |
| 1038 observers_.AddObserver(observer); | 1039 observers_.AddObserver(observer); |
| 1039 } | 1040 } |
| 1040 | 1041 |
| 1041 void RenderProcessHostImpl::RemoveObserver( | 1042 void RenderProcessHostImpl::RemoveObserver( |
| 1042 RenderProcessHostObserver* observer) { | 1043 RenderProcessHostObserver* observer) { |
| 1043 observers_.RemoveObserver(observer); | 1044 observers_.RemoveObserver(observer); |
| 1044 } | 1045 } |
| 1045 | 1046 |
| 1046 void RenderProcessHostImpl::ReceivedBadMessage() { | 1047 void RenderProcessHostImpl::ReceivedBadMessage(BadMessage reason) { |
| 1047 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 1048 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1048 if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC)) | 1049 if (command_line->HasSwitch(switches::kDisableKillAfterBadIPC)) |
| 1049 return; | 1050 return; |
| 1050 | 1051 |
| 1051 if (run_renderer_in_process()) { | 1052 if (run_renderer_in_process()) { |
| 1052 // In single process mode it is better if we don't suicide but just | 1053 // In single process mode it is better if we don't suicide but just |
| 1053 // crash. | 1054 // crash. |
| 1054 CHECK(false); | 1055 CHECK(false); |
| 1055 } | 1056 } |
| 1057 | |
| 1058 LOG(ERROR) << "Terminating renderer for bad IPC message, reason " | |
| 1059 << static_cast<int>(reason); | |
| 1060 UMA_HISTOGRAM_ENUMERATION("Stability.BadMessageTerminated", | |
| 1061 static_cast<int>(reason), | |
| 1062 static_cast<int>(BadMessage::BAD_MESSAGE_MAX)); | |
| 1063 | |
| 1056 // We kill the renderer but don't include a NOTREACHED, because we want the | 1064 // We kill the renderer but don't include a NOTREACHED, because we want the |
| 1057 // browser to try to survive when it gets illegal messages from the renderer. | 1065 // browser to try to survive when it gets illegal messages from the renderer. |
| 1058 Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, false); | 1066 Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, false); |
| 1059 } | 1067 } |
| 1060 | 1068 |
| 1061 void RenderProcessHostImpl::WidgetRestored() { | 1069 void RenderProcessHostImpl::WidgetRestored() { |
| 1062 // Verify we were properly backgrounded. | 1070 // Verify we were properly backgrounded. |
| 1063 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); | 1071 DCHECK_EQ(backgrounded_, (visible_widgets_ == 0)); |
| 1064 visible_widgets_++; | 1072 visible_widgets_++; |
| 1065 SetBackgrounded(false); | 1073 SetBackgrounded(false); |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1552 } | 1560 } |
| 1553 | 1561 |
| 1554 void RenderProcessHostImpl::OnChannelError() { | 1562 void RenderProcessHostImpl::OnChannelError() { |
| 1555 ProcessDied(true /* already_dead */, nullptr); | 1563 ProcessDied(true /* already_dead */, nullptr); |
| 1556 } | 1564 } |
| 1557 | 1565 |
| 1558 void RenderProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { | 1566 void RenderProcessHostImpl::OnBadMessageReceived(const IPC::Message& message) { |
| 1559 // Message de-serialization failed. We consider this a capital crime. Kill the | 1567 // Message de-serialization failed. We consider this a capital crime. Kill the |
| 1560 // renderer if we have one. | 1568 // renderer if we have one. |
| 1561 LOG(ERROR) << "bad message " << message.type() << " terminating renderer."; | 1569 LOG(ERROR) << "bad message " << message.type() << " terminating renderer."; |
| 1562 BrowserChildProcessHostImpl::HistogramBadMessageTerminated( | 1570 BrowserChildProcessHostImpl::HistogramBadMessageTerminated( |
|
Charlie Reis
2015/03/13 23:41:49
Huh, I wonder if we need this anymore. I guess it
| |
| 1563 PROCESS_TYPE_RENDERER); | 1571 PROCESS_TYPE_RENDERER); |
| 1564 ReceivedBadMessage(); | 1572 ReceivedBadMessage(BadMessage::RPH_DESERIALIZATION_FAILED); |
| 1565 } | 1573 } |
| 1566 | 1574 |
| 1567 BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { | 1575 BrowserContext* RenderProcessHostImpl::GetBrowserContext() const { |
| 1568 return browser_context_; | 1576 return browser_context_; |
| 1569 } | 1577 } |
| 1570 | 1578 |
| 1571 bool RenderProcessHostImpl::InSameStoragePartition( | 1579 bool RenderProcessHostImpl::InSameStoragePartition( |
| 1572 StoragePartition* partition) const { | 1580 StoragePartition* partition) const { |
| 1573 return storage_partition_impl_ == partition; | 1581 return storage_partition_impl_ == partition; |
| 1574 } | 1582 } |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2410 if (worker_ref_count_ == 0) | 2418 if (worker_ref_count_ == 0) |
| 2411 Cleanup(); | 2419 Cleanup(); |
| 2412 } | 2420 } |
| 2413 | 2421 |
| 2414 void RenderProcessHostImpl::GetAudioOutputControllers( | 2422 void RenderProcessHostImpl::GetAudioOutputControllers( |
| 2415 const GetAudioOutputControllersCallback& callback) const { | 2423 const GetAudioOutputControllersCallback& callback) const { |
| 2416 audio_renderer_host()->GetOutputControllers(callback); | 2424 audio_renderer_host()->GetOutputControllers(callback); |
| 2417 } | 2425 } |
| 2418 | 2426 |
| 2419 } // namespace content | 2427 } // namespace content |
| OLD | NEW |