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 12 matching lines...) Expand all Loading... | |
23 #include "base/debug/trace_event.h" | 23 #include "base/debug/trace_event.h" |
24 #include "base/files/file.h" | 24 #include "base/files/file.h" |
25 #include "base/lazy_instance.h" | 25 #include "base/lazy_instance.h" |
26 #include "base/logging.h" | 26 #include "base/logging.h" |
27 #include "base/metrics/field_trial.h" | 27 #include "base/metrics/field_trial.h" |
28 #include "base/metrics/histogram.h" | 28 #include "base/metrics/histogram.h" |
29 #include "base/numerics/safe_math.h" | 29 #include "base/numerics/safe_math.h" |
30 #include "base/path_service.h" | 30 #include "base/path_service.h" |
31 #include "base/rand_util.h" | 31 #include "base/rand_util.h" |
32 #include "base/stl_util.h" | 32 #include "base/stl_util.h" |
33 #include "base/strings/string_number_conversions.h" | |
33 #include "base/strings/string_util.h" | 34 #include "base/strings/string_util.h" |
34 #include "base/supports_user_data.h" | 35 #include "base/supports_user_data.h" |
35 #include "base/sys_info.h" | 36 #include "base/sys_info.h" |
36 #include "base/threading/thread.h" | 37 #include "base/threading/thread.h" |
37 #include "base/threading/thread_restrictions.h" | 38 #include "base/threading/thread_restrictions.h" |
38 #include "base/tracked_objects.h" | 39 #include "base/tracked_objects.h" |
39 #include "cc/base/switches.h" | 40 #include "cc/base/switches.h" |
40 #include "content/browser/appcache/appcache_dispatcher_host.h" | 41 #include "content/browser/appcache/appcache_dispatcher_host.h" |
41 #include "content/browser/appcache/chrome_appcache_service.h" | 42 #include "content/browser/appcache/chrome_appcache_service.h" |
42 #include "content/browser/battery_status/battery_status_message_filter.h" | 43 #include "content/browser/battery_status/battery_status_message_filter.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 #include "base/win/scoped_com_initializer.h" | 168 #include "base/win/scoped_com_initializer.h" |
168 #include "content/common/font_cache_dispatcher_win.h" | 169 #include "content/common/font_cache_dispatcher_win.h" |
169 #include "content/common/sandbox_win.h" | 170 #include "content/common/sandbox_win.h" |
170 #include "ui/gfx/win/dpi.h" | 171 #include "ui/gfx/win/dpi.h" |
171 #endif | 172 #endif |
172 | 173 |
173 #if defined(ENABLE_WEBRTC) | 174 #if defined(ENABLE_WEBRTC) |
174 #include "content/browser/media/webrtc_internals.h" | 175 #include "content/browser/media/webrtc_internals.h" |
175 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" | 176 #include "content/browser/renderer_host/media/media_stream_track_metrics_host.h" |
176 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" | 177 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" |
178 #include "content/common/media/aec_dump_messages.h" | |
177 #include "content/common/media/media_stream_messages.h" | 179 #include "content/common/media/media_stream_messages.h" |
178 #endif | 180 #endif |
179 | 181 |
180 extern bool g_exited_main_message_loop; | 182 extern bool g_exited_main_message_loop; |
181 | 183 |
182 static const char* kSiteProcessMapKeyName = "content_site_process_map"; | 184 static const char* kSiteProcessMapKeyName = "content_site_process_map"; |
183 | 185 |
184 namespace content { | 186 namespace content { |
185 namespace { | 187 namespace { |
186 | 188 |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1367 OnDumpHandlesDone) | 1369 OnDumpHandlesDone) |
1368 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, | 1370 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
1369 SuddenTerminationChanged) | 1371 SuddenTerminationChanged) |
1370 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, | 1372 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, |
1371 OnUserMetricsRecordAction) | 1373 OnUserMetricsRecordAction) |
1372 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) | 1374 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) |
1373 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 1375 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
1374 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, | 1376 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, |
1375 OnAllocateGpuMemoryBuffer) | 1377 OnAllocateGpuMemoryBuffer) |
1376 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) | 1378 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) |
1379 IPC_MESSAGE_HANDLER(AecDumpMsg_RegisterAecDumpConsumer, | |
no longer working on chromium
2014/06/18 08:45:38
either put them into ENABLE_WEBRTC or move all the
Henrik Grunell
2014/06/18 10:40:41
Done.
| |
1380 OnRegisterAecDumpConsumer) | |
1381 IPC_MESSAGE_HANDLER(AecDumpMsg_UnregisterAecDumpConsumer, | |
1382 OnUnregisterAecDumpConsumer) | |
1377 // Adding single handlers for your service here is fine, but once your | 1383 // Adding single handlers for your service here is fine, but once your |
1378 // service needs more than one handler, please extract them into a new | 1384 // service needs more than one handler, please extract them into a new |
1379 // message filter and add that filter to CreateMessageFilters(). | 1385 // message filter and add that filter to CreateMessageFilters(). |
1380 IPC_END_MESSAGE_MAP() | 1386 IPC_END_MESSAGE_MAP() |
1381 | 1387 |
1382 return true; | 1388 return true; |
1383 } | 1389 } |
1384 | 1390 |
1385 // Dispatch incoming messages to the appropriate IPC::Listener. | 1391 // Dispatch incoming messages to the appropriate IPC::Listener. |
1386 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); | 1392 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1538 widget_helper_->ResumeRequestsForView(route_id); | 1544 widget_helper_->ResumeRequestsForView(route_id); |
1539 } | 1545 } |
1540 | 1546 |
1541 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { | 1547 void RenderProcessHostImpl::FilterURL(bool empty_allowed, GURL* url) { |
1542 FilterURL(this, empty_allowed, url); | 1548 FilterURL(this, empty_allowed, url); |
1543 } | 1549 } |
1544 | 1550 |
1545 #if defined(ENABLE_WEBRTC) | 1551 #if defined(ENABLE_WEBRTC) |
1546 void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) { | 1552 void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) { |
1547 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1553 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1548 BrowserThread::PostTaskAndReplyWithResult( | 1554 // Enable AEC dump for each registered consumer. |
1549 BrowserThread::FILE, FROM_HERE, | 1555 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); |
1550 base::Bind(&CreateAecDumpFileForProcess, file, GetHandle()), | 1556 it != aec_dump_consumers_.end(); ++it) { |
1551 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, | 1557 EnableAecDumpForId(file, *it); |
1552 weak_factory_.GetWeakPtr())); | 1558 } |
1553 } | 1559 } |
1554 | 1560 |
1555 void RenderProcessHostImpl::DisableAecDump() { | 1561 void RenderProcessHostImpl::DisableAecDump() { |
1556 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1562 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1557 // Posting on the FILE thread and then replying back on the UI thread is only | 1563 // Posting on the FILE thread and then replying back on the UI thread is only |
1558 // for avoiding races between enable and disable. Nothing is done on the FILE | 1564 // for avoiding races between enable and disable. Nothing is done on the FILE |
1559 // thread. | 1565 // thread. |
1560 BrowserThread::PostTaskAndReply( | 1566 BrowserThread::PostTaskAndReply( |
1561 BrowserThread::FILE, FROM_HERE, | 1567 BrowserThread::FILE, FROM_HERE, |
1562 base::Bind(&DisableAecDumpOnFileThread), | 1568 base::Bind(&DisableAecDumpOnFileThread), |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2160 // Skip widgets in other processes. | 2166 // Skip widgets in other processes. |
2161 if (widget->GetProcess()->GetID() != GetID()) | 2167 if (widget->GetProcess()->GetID() != GetID()) |
2162 continue; | 2168 continue; |
2163 | 2169 |
2164 RenderViewHost* rvh = RenderViewHost::From(widget); | 2170 RenderViewHost* rvh = RenderViewHost::From(widget); |
2165 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); | 2171 rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences()); |
2166 } | 2172 } |
2167 } | 2173 } |
2168 | 2174 |
2169 #if defined(ENABLE_WEBRTC) | 2175 #if defined(ENABLE_WEBRTC) |
2176 void RenderProcessHostImpl::OnRegisterAecDumpConsumer(int id) { | |
2177 BrowserThread::PostTask( | |
2178 BrowserThread::UI, | |
2179 FROM_HERE, | |
2180 base::Bind( | |
2181 &RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread, | |
2182 weak_factory_.GetWeakPtr(), | |
2183 id)); | |
2184 } | |
2185 | |
2186 void RenderProcessHostImpl::OnUnregisterAecDumpConsumer(int id) { | |
2187 BrowserThread::PostTask( | |
2188 BrowserThread::UI, | |
2189 FROM_HERE, | |
2190 base::Bind( | |
2191 &RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread, | |
2192 weak_factory_.GetWeakPtr(), | |
2193 id)); | |
2194 } | |
2195 | |
2196 void RenderProcessHostImpl::RegisterAecDumpConsumerOnUIThread(int id) { | |
2197 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
2198 aec_dump_consumers_.push_back(id); | |
2199 if (WebRTCInternals::GetInstance()->aec_dump_enabled()) { | |
2200 EnableAecDumpForId(WebRTCInternals::GetInstance()->aec_dump_file_path(), | |
2201 id); | |
2202 } | |
2203 } | |
2204 | |
2205 void RenderProcessHostImpl::UnregisterAecDumpConsumerOnUIThread(int id) { | |
2206 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
2207 for (std::vector<int>::iterator it = aec_dump_consumers_.begin(); | |
2208 it != aec_dump_consumers_.end(); ++it) { | |
2209 if (*it == id) { | |
2210 aec_dump_consumers_.erase(it); | |
2211 break; | |
2212 } | |
2213 } | |
2214 } | |
2215 | |
2216 void RenderProcessHostImpl::EnableAecDumpForId(const base::FilePath& file, | |
2217 int id) { | |
2218 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
2219 base::FilePath unique_file = | |
2220 file.AddExtension(base::IntToString(GetID())) | |
2221 .AddExtension(base::IntToString(id)); | |
2222 BrowserThread::PostTaskAndReplyWithResult( | |
2223 BrowserThread::FILE, FROM_HERE, | |
2224 base::Bind(&CreateAecDumpFileForProcess, unique_file, GetHandle()), | |
2225 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, | |
2226 weak_factory_.GetWeakPtr(), | |
2227 id)); | |
2228 } | |
2229 | |
2170 void RenderProcessHostImpl::SendAecDumpFileToRenderer( | 2230 void RenderProcessHostImpl::SendAecDumpFileToRenderer( |
2231 int id, | |
2171 IPC::PlatformFileForTransit file_for_transit) { | 2232 IPC::PlatformFileForTransit file_for_transit) { |
2172 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) | 2233 if (file_for_transit == IPC::InvalidPlatformFileForTransit()) |
2173 return; | 2234 return; |
2174 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); | 2235 Send(new AecDumpMsg_EnableAecDump(id, file_for_transit)); |
2175 } | 2236 } |
2176 | 2237 |
2177 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { | 2238 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
2178 Send(new MediaStreamMsg_DisableAecDump()); | 2239 Send(new AecDumpMsg_DisableAecDump()); |
2179 } | 2240 } |
2180 #endif | 2241 #endif |
2181 | 2242 |
2182 void RenderProcessHostImpl::IncrementWorkerRefCount() { | 2243 void RenderProcessHostImpl::IncrementWorkerRefCount() { |
2183 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2244 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2184 ++worker_ref_count_; | 2245 ++worker_ref_count_; |
2185 } | 2246 } |
2186 | 2247 |
2187 void RenderProcessHostImpl::DecrementWorkerRefCount() { | 2248 void RenderProcessHostImpl::DecrementWorkerRefCount() { |
2188 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2249 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2300 void RenderProcessHostImpl::GpuMemoryBufferAllocated( | 2361 void RenderProcessHostImpl::GpuMemoryBufferAllocated( |
2301 IPC::Message* reply, | 2362 IPC::Message* reply, |
2302 const gfx::GpuMemoryBufferHandle& handle) { | 2363 const gfx::GpuMemoryBufferHandle& handle) { |
2303 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2364 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2304 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, | 2365 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
2305 handle); | 2366 handle); |
2306 Send(reply); | 2367 Send(reply); |
2307 } | 2368 } |
2308 | 2369 |
2309 } // namespace content | 2370 } // namespace content |
OLD | NEW |