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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 const ResourceHostMsg_Request& request, | 190 const ResourceHostMsg_Request& request, |
191 ResourceContext** resource_context_out, | 191 ResourceContext** resource_context_out, |
192 net::URLRequestContext** request_context_out) { | 192 net::URLRequestContext** request_context_out) { |
193 *resource_context_out = resource_context; | 193 *resource_context_out = resource_context; |
194 *request_context_out = | 194 *request_context_out = |
195 GetRequestContext(request_context, media_request_context, | 195 GetRequestContext(request_context, media_request_context, |
196 request.resource_type); | 196 request.resource_type); |
197 } | 197 } |
198 | 198 |
199 #if defined(ENABLE_WEBRTC) | 199 #if defined(ENABLE_WEBRTC) |
200 // |first_aec_dump_open| is used for only opening the file so that it overwrites | |
201 // an existing file the first time. Consecutive opens will append. | |
sky
2014/02/11 15:07:23
'file the first create' ?
Henrik Grunell
2014/02/11 16:26:55
Done.
| |
202 // TODO(grunell): How this flag is used together with the two functions is | |
203 // confusing. We actually assume that CreateAecDumpFileForProcess will be called | |
204 // with the same |file_path| for all processes. Refactoring needed. | |
205 static bool first_aec_dump_open = true; | |
sky
2014/02/11 15:07:23
How about naming this a bit more clearly. Say crea
Henrik Grunell
2014/02/11 16:26:55
Done.
| |
206 | |
200 // Creates a file used for diagnostic echo canceller recordings for handing | 207 // Creates a file used for diagnostic echo canceller recordings for handing |
201 // over to the renderer. | 208 // over to the renderer. |
202 IPC::PlatformFileForTransit CreateAecDumpFileForProcess( | 209 IPC::PlatformFileForTransit CreateAecDumpFileForProcess( |
203 base::FilePath file_path, | 210 base::FilePath file_path, |
204 base::ProcessHandle process) { | 211 base::ProcessHandle process) { |
205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
206 base::PlatformFileError error = base::PLATFORM_FILE_OK; | 213 base::PlatformFileError error = base::PLATFORM_FILE_OK; |
214 int flags = first_aec_dump_open ? | |
215 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE : | |
216 base::PLATFORM_FILE_OPEN_ALWAYS | base::PLATFORM_FILE_APPEND; | |
207 base::PlatformFile aec_dump_file = base::CreatePlatformFile( | 217 base::PlatformFile aec_dump_file = base::CreatePlatformFile( |
208 file_path, | 218 file_path, |
209 base::PLATFORM_FILE_CREATE_ALWAYS | base::PLATFORM_FILE_WRITE, | 219 flags, |
210 NULL, | 220 NULL, |
211 &error); | 221 &error); |
212 if (error != base::PLATFORM_FILE_OK) { | 222 if (error != base::PLATFORM_FILE_OK) { |
213 VLOG(1) << "Could not open AEC dump file, error=" << error; | 223 VLOG(1) << "Could not open AEC dump file, error=" << error; |
214 return IPC::InvalidPlatformFileForTransit(); | 224 return IPC::InvalidPlatformFileForTransit(); |
215 } | 225 } |
226 first_aec_dump_open = false; | |
216 return IPC::GetFileHandleForProcess(aec_dump_file, process, true); | 227 return IPC::GetFileHandleForProcess(aec_dump_file, process, true); |
217 } | 228 } |
218 | 229 |
219 // Does nothing. Just to avoid races between enable and disable. | 230 // We assume that this function is called for all render process hosts when |
231 // called. The first one called will reset the state so that when enabled | |
232 // again, the file will be opened so that it overwrite an existing file. | |
220 void DisableAecDumpOnFileThread() { | 233 void DisableAecDumpOnFileThread() { |
221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
235 first_aec_dump_open = true; | |
222 } | 236 } |
223 | |
224 #endif | 237 #endif |
225 | 238 |
226 // the global list of all renderer processes | 239 // the global list of all renderer processes |
227 base::LazyInstance<IDMap<RenderProcessHost> >::Leaky | 240 base::LazyInstance<IDMap<RenderProcessHost> >::Leaky |
228 g_all_hosts = LAZY_INSTANCE_INITIALIZER; | 241 g_all_hosts = LAZY_INSTANCE_INITIALIZER; |
229 | 242 |
230 base::LazyInstance<scoped_refptr<BrowserPluginGeolocationPermissionContext> > | 243 base::LazyInstance<scoped_refptr<BrowserPluginGeolocationPermissionContext> > |
231 g_browser_plugin_geolocation_context = LAZY_INSTANCE_INITIALIZER; | 244 g_browser_plugin_geolocation_context = LAZY_INSTANCE_INITIALIZER; |
232 | 245 |
233 // Map of site to process, to ensure we only have one RenderProcessHost per | 246 // Map of site to process, to ensure we only have one RenderProcessHost per |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1524 #if defined(ENABLE_WEBRTC) | 1537 #if defined(ENABLE_WEBRTC) |
1525 void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) { | 1538 void RenderProcessHostImpl::EnableAecDump(const base::FilePath& file) { |
1526 BrowserThread::PostTaskAndReplyWithResult( | 1539 BrowserThread::PostTaskAndReplyWithResult( |
1527 BrowserThread::FILE, FROM_HERE, | 1540 BrowserThread::FILE, FROM_HERE, |
1528 base::Bind(&CreateAecDumpFileForProcess, file, GetHandle()), | 1541 base::Bind(&CreateAecDumpFileForProcess, file, GetHandle()), |
1529 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, | 1542 base::Bind(&RenderProcessHostImpl::SendAecDumpFileToRenderer, |
1530 weak_factory_.GetWeakPtr())); | 1543 weak_factory_.GetWeakPtr())); |
1531 } | 1544 } |
1532 | 1545 |
1533 void RenderProcessHostImpl::DisableAecDump() { | 1546 void RenderProcessHostImpl::DisableAecDump() { |
1534 // Posting on the FILE thread and then replying back on the UI thread is only | |
1535 // for avoiding races between enable and disable. Nothing is done on the FILE | |
1536 // thread. | |
1537 BrowserThread::PostTaskAndReply( | 1547 BrowserThread::PostTaskAndReply( |
1538 BrowserThread::FILE, FROM_HERE, | 1548 BrowserThread::FILE, FROM_HERE, |
1539 base::Bind(&DisableAecDumpOnFileThread), | 1549 base::Bind(&DisableAecDumpOnFileThread), |
1540 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, | 1550 base::Bind(&RenderProcessHostImpl::SendDisableAecDumpToRenderer, |
1541 weak_factory_.GetWeakPtr())); | 1551 weak_factory_.GetWeakPtr())); |
1542 } | 1552 } |
1543 | 1553 |
1544 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( | 1554 void RenderProcessHostImpl::SetWebRtcLogMessageCallback( |
1545 base::Callback<void(const std::string&)> callback) { | 1555 base::Callback<void(const std::string&)> callback) { |
1546 webrtc_log_message_callback_ = callback; | 1556 webrtc_log_message_callback_ = callback; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2073 return; | 2083 return; |
2074 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); | 2084 Send(new MediaStreamMsg_EnableAecDump(file_for_transit)); |
2075 } | 2085 } |
2076 | 2086 |
2077 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { | 2087 void RenderProcessHostImpl::SendDisableAecDumpToRenderer() { |
2078 Send(new MediaStreamMsg_DisableAecDump()); | 2088 Send(new MediaStreamMsg_DisableAecDump()); |
2079 } | 2089 } |
2080 #endif | 2090 #endif |
2081 | 2091 |
2082 } // namespace content | 2092 } // namespace content |
OLD | NEW |