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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 | 346 |
347 void AddIntegerValue(CFMutableDictionaryRef dictionary, | 347 void AddIntegerValue(CFMutableDictionaryRef dictionary, |
348 const CFStringRef key, | 348 const CFStringRef key, |
349 int32 value) { | 349 int32 value) { |
350 base::ScopedCFTypeRef<CFNumberRef> number( | 350 base::ScopedCFTypeRef<CFNumberRef> number( |
351 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); | 351 CFNumberCreate(NULL, kCFNumberSInt32Type, &value)); |
352 CFDictionaryAddValue(dictionary, key, number.get()); | 352 CFDictionaryAddValue(dictionary, key, number.get()); |
353 } | 353 } |
354 #endif | 354 #endif |
355 | 355 |
356 const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; | |
357 | |
358 class SessionStorageHolder : public base::SupportsUserData::Data { | |
359 public: | |
jochen (gone - plz use gerrit)
2014/06/04 08:16:24
nit. add explicit ctor and virtual dtor
michaeln
2014/06/04 23:53:28
Done.
| |
360 void Hold(const SessionStorageNamespaceMap& sessions, int view_route_id) { | |
361 session_storage_namespaces_awaiting_close_[view_route_id] = sessions; | |
362 } | |
363 | |
364 void Release(int old_route_id) { | |
365 session_storage_namespaces_awaiting_close_.erase(old_route_id); | |
366 } | |
367 | |
368 private: | |
369 std::map<int, SessionStorageNamespaceMap > | |
370 session_storage_namespaces_awaiting_close_; | |
371 }; | |
jochen (gone - plz use gerrit)
2014/06/04 08:16:24
nit. DISALLOW_COPY_AND_ASSIGN()
michaeln
2014/06/04 23:53:28
Done.
| |
372 | |
356 } // namespace | 373 } // namespace |
357 | 374 |
358 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; | 375 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
359 | 376 |
360 base::MessageLoop* g_in_process_thread; | 377 base::MessageLoop* g_in_process_thread; |
361 | 378 |
362 base::MessageLoop* | 379 base::MessageLoop* |
363 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { | 380 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { |
364 return g_in_process_thread; | 381 return g_in_process_thread; |
365 } | 382 } |
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1341 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, | 1358 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, |
1342 OnDumpHandlesDone) | 1359 OnDumpHandlesDone) |
1343 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, | 1360 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, |
1344 SuddenTerminationChanged) | 1361 SuddenTerminationChanged) |
1345 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, | 1362 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, |
1346 OnUserMetricsRecordAction) | 1363 OnUserMetricsRecordAction) |
1347 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) | 1364 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) |
1348 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 1365 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
1349 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, | 1366 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, |
1350 OnAllocateGpuMemoryBuffer) | 1367 OnAllocateGpuMemoryBuffer) |
1368 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK) | |
1351 // Adding single handlers for your service here is fine, but once your | 1369 // Adding single handlers for your service here is fine, but once your |
1352 // service needs more than one handler, please extract them into a new | 1370 // service needs more than one handler, please extract them into a new |
1353 // message filter and add that filter to CreateMessageFilters(). | 1371 // message filter and add that filter to CreateMessageFilters(). |
1354 IPC_END_MESSAGE_MAP() | 1372 IPC_END_MESSAGE_MAP() |
1355 | 1373 |
1356 return true; | 1374 return true; |
1357 } | 1375 } |
1358 | 1376 |
1359 // Dispatch incoming messages to the appropriate IPC::Listener. | 1377 // Dispatch incoming messages to the appropriate IPC::Listener. |
1360 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); | 1378 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1472 deleting_soon_ = true; | 1490 deleting_soon_ = true; |
1473 // It's important not to wait for the DeleteTask to delete the channel | 1491 // It's important not to wait for the DeleteTask to delete the channel |
1474 // proxy. Kill it off now. That way, in case the profile is going away, the | 1492 // proxy. Kill it off now. That way, in case the profile is going away, the |
1475 // rest of the objects attached to this RenderProcessHost start going | 1493 // rest of the objects attached to this RenderProcessHost start going |
1476 // away first, since deleting the channel proxy will post a | 1494 // away first, since deleting the channel proxy will post a |
1477 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. | 1495 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. |
1478 channel_.reset(); | 1496 channel_.reset(); |
1479 gpu_message_filter_ = NULL; | 1497 gpu_message_filter_ = NULL; |
1480 message_port_message_filter_ = NULL; | 1498 message_port_message_filter_ = NULL; |
1481 screen_orientation_dispatcher_host_ = NULL; | 1499 screen_orientation_dispatcher_host_ = NULL; |
1500 RemoveUserData(kSessionStorageHolderKey); | |
1482 | 1501 |
1483 // Remove ourself from the list of renderer processes so that we can't be | 1502 // Remove ourself from the list of renderer processes so that we can't be |
1484 // reused in between now and when the Delete task runs. | 1503 // reused in between now and when the Delete task runs. |
1485 UnregisterHost(GetID()); | 1504 UnregisterHost(GetID()); |
1486 } | 1505 } |
1487 } | 1506 } |
1488 | 1507 |
1489 void RenderProcessHostImpl::AddPendingView() { | 1508 void RenderProcessHostImpl::AddPendingView() { |
1490 pending_views_++; | 1509 pending_views_++; |
1491 } | 1510 } |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1885 FOR_EACH_OBSERVER(RenderProcessHostObserver, | 1904 FOR_EACH_OBSERVER(RenderProcessHostObserver, |
1886 observers_, | 1905 observers_, |
1887 RenderProcessExited(this, GetHandle(), status, exit_code)); | 1906 RenderProcessExited(this, GetHandle(), status, exit_code)); |
1888 within_process_died_observer_ = false; | 1907 within_process_died_observer_ = false; |
1889 | 1908 |
1890 child_process_launcher_.reset(); | 1909 child_process_launcher_.reset(); |
1891 channel_.reset(); | 1910 channel_.reset(); |
1892 gpu_message_filter_ = NULL; | 1911 gpu_message_filter_ = NULL; |
1893 message_port_message_filter_ = NULL; | 1912 message_port_message_filter_ = NULL; |
1894 screen_orientation_dispatcher_host_ = NULL; | 1913 screen_orientation_dispatcher_host_ = NULL; |
1914 RemoveUserData(kSessionStorageHolderKey); | |
1895 | 1915 |
1896 IDMap<IPC::Listener>::iterator iter(&listeners_); | 1916 IDMap<IPC::Listener>::iterator iter(&listeners_); |
1897 while (!iter.IsAtEnd()) { | 1917 while (!iter.IsAtEnd()) { |
1898 iter.GetCurrentValue()->OnMessageReceived( | 1918 iter.GetCurrentValue()->OnMessageReceived( |
1899 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), | 1919 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), |
1900 static_cast<int>(status), | 1920 static_cast<int>(status), |
1901 exit_code)); | 1921 exit_code)); |
1902 iter.Advance(); | 1922 iter.Advance(); |
1903 } | 1923 } |
1904 | 1924 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1953 if (!webrtc_log_message_callback_.is_null()) | 1973 if (!webrtc_log_message_callback_.is_null()) |
1954 webrtc_log_message_callback_.Run(message); | 1974 webrtc_log_message_callback_.Run(message); |
1955 } | 1975 } |
1956 #endif | 1976 #endif |
1957 | 1977 |
1958 scoped_refptr<ScreenOrientationDispatcherHost> | 1978 scoped_refptr<ScreenOrientationDispatcherHost> |
1959 RenderProcessHostImpl::screen_orientation_dispatcher_host() const { | 1979 RenderProcessHostImpl::screen_orientation_dispatcher_host() const { |
1960 return make_scoped_refptr(screen_orientation_dispatcher_host_); | 1980 return make_scoped_refptr(screen_orientation_dispatcher_host_); |
1961 } | 1981 } |
1962 | 1982 |
1983 void RenderProcessHostImpl::ReleaseOnCloseACK( | |
1984 RenderProcessHost* host, | |
1985 const SessionStorageNamespaceMap& sessions, | |
1986 int view_route_id) { | |
1987 DCHECK(host); | |
1988 if (sessions.empty()) | |
1989 return; | |
1990 SessionStorageHolder* holder = static_cast<SessionStorageHolder*> | |
1991 (host->GetUserData(kSessionStorageHolderKey)); | |
1992 if (!holder) { | |
1993 holder = new SessionStorageHolder(); | |
1994 host->SetUserData( | |
1995 kSessionStorageHolderKey, | |
1996 holder); | |
1997 } | |
1998 holder->Hold(sessions, view_route_id); | |
1999 } | |
2000 | |
1963 void RenderProcessHostImpl::OnShutdownRequest() { | 2001 void RenderProcessHostImpl::OnShutdownRequest() { |
1964 // Don't shut down if there are active RenderViews, or if there are pending | 2002 // Don't shut down if there are active RenderViews, or if there are pending |
1965 // RenderViews being swapped back in. | 2003 // RenderViews being swapped back in. |
1966 // In single process mode, we never shutdown the renderer. | 2004 // In single process mode, we never shutdown the renderer. |
1967 int num_active_views = GetActiveViewCount(); | 2005 int num_active_views = GetActiveViewCount(); |
1968 if (pending_views_ || num_active_views > 0 || run_renderer_in_process()) | 2006 if (pending_views_ || num_active_views > 0 || run_renderer_in_process()) |
1969 return; | 2007 return; |
1970 | 2008 |
1971 // Notify any contents that might have swapped out renderers from this | 2009 // Notify any contents that might have swapped out renderers from this |
1972 // process. They should not attempt to swap them back in. | 2010 // process. They should not attempt to swap them back in. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2067 scoped_refptr<AudioRendererHost> | 2105 scoped_refptr<AudioRendererHost> |
2068 RenderProcessHostImpl::audio_renderer_host() const { | 2106 RenderProcessHostImpl::audio_renderer_host() const { |
2069 return audio_renderer_host_; | 2107 return audio_renderer_host_; |
2070 } | 2108 } |
2071 | 2109 |
2072 void RenderProcessHostImpl::OnUserMetricsRecordAction( | 2110 void RenderProcessHostImpl::OnUserMetricsRecordAction( |
2073 const std::string& action) { | 2111 const std::string& action) { |
2074 RecordComputedAction(action); | 2112 RecordComputedAction(action); |
2075 } | 2113 } |
2076 | 2114 |
2115 void RenderProcessHostImpl::OnCloseACK(int old_route_id) { | |
2116 SessionStorageHolder* holder = static_cast<SessionStorageHolder*> | |
2117 (GetUserData(kSessionStorageHolderKey)); | |
2118 if (!holder) | |
2119 return; | |
2120 holder->Release(old_route_id); | |
2121 } | |
2122 | |
2077 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 2123 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
2078 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); | 2124 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); |
2079 } | 2125 } |
2080 | 2126 |
2081 void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost( | 2127 void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost( |
2082 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { | 2128 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { |
2083 TRACE_EVENT0("renderer_host", | 2129 TRACE_EVENT0("renderer_host", |
2084 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); | 2130 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); |
2085 if (!ui::LatencyInfo::Verify(params.latency_info, | 2131 if (!ui::LatencyInfo::Verify(params.latency_info, |
2086 "ViewHostMsg_CompositorSurfaceBuffersSwapped")) | 2132 "ViewHostMsg_CompositorSurfaceBuffersSwapped")) |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2248 void RenderProcessHostImpl::GpuMemoryBufferAllocated( | 2294 void RenderProcessHostImpl::GpuMemoryBufferAllocated( |
2249 IPC::Message* reply, | 2295 IPC::Message* reply, |
2250 const gfx::GpuMemoryBufferHandle& handle) { | 2296 const gfx::GpuMemoryBufferHandle& handle) { |
2251 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 2297 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
2252 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, | 2298 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
2253 handle); | 2299 handle); |
2254 Send(reply); | 2300 Send(reply); |
2255 } | 2301 } |
2256 | 2302 |
2257 } // namespace content | 2303 } // namespace content |
OLD | NEW |