Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 305103003: Fix for 'Simple Adblock' extension crashes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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:
360 SessionStorageHolder() {}
361 virtual ~SessionStorageHolder() {}
362
363 void Hold(const SessionStorageNamespaceMap& sessions, int view_route_id) {
364 session_storage_namespaces_awaiting_close_[view_route_id] = sessions;
365 }
366
367 void Release(int old_route_id) {
368 session_storage_namespaces_awaiting_close_.erase(old_route_id);
369 }
370
371 private:
372 std::map<int, SessionStorageNamespaceMap >
373 session_storage_namespaces_awaiting_close_;
374 DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder);
375 };
376
356 } // namespace 377 } // namespace
357 378
358 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; 379 RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
359 380
360 base::MessageLoop* g_in_process_thread; 381 base::MessageLoop* g_in_process_thread;
361 382
362 base::MessageLoop* 383 base::MessageLoop*
363 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() { 384 RenderProcessHostImpl::GetInProcessRendererThreadForTesting() {
364 return g_in_process_thread; 385 return g_in_process_thread;
365 } 386 }
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone, 1363 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DumpHandlesDone,
1343 OnDumpHandlesDone) 1364 OnDumpHandlesDone)
1344 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged, 1365 IPC_MESSAGE_HANDLER(ViewHostMsg_SuddenTerminationChanged,
1345 SuddenTerminationChanged) 1366 SuddenTerminationChanged)
1346 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, 1367 IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction,
1347 OnUserMetricsRecordAction) 1368 OnUserMetricsRecordAction)
1348 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML) 1369 IPC_MESSAGE_HANDLER(ViewHostMsg_SavedPageAsMHTML, OnSavedPageAsMHTML)
1349 IPC_MESSAGE_HANDLER_DELAY_REPLY( 1370 IPC_MESSAGE_HANDLER_DELAY_REPLY(
1350 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, 1371 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
1351 OnAllocateGpuMemoryBuffer) 1372 OnAllocateGpuMemoryBuffer)
1373 IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK)
1352 // Adding single handlers for your service here is fine, but once your 1374 // Adding single handlers for your service here is fine, but once your
1353 // service needs more than one handler, please extract them into a new 1375 // service needs more than one handler, please extract them into a new
1354 // message filter and add that filter to CreateMessageFilters(). 1376 // message filter and add that filter to CreateMessageFilters().
1355 IPC_END_MESSAGE_MAP() 1377 IPC_END_MESSAGE_MAP()
1356 1378
1357 return true; 1379 return true;
1358 } 1380 }
1359 1381
1360 // Dispatch incoming messages to the appropriate IPC::Listener. 1382 // Dispatch incoming messages to the appropriate IPC::Listener.
1361 IPC::Listener* listener = listeners_.Lookup(msg.routing_id()); 1383 IPC::Listener* listener = listeners_.Lookup(msg.routing_id());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 deleting_soon_ = true; 1495 deleting_soon_ = true;
1474 // It's important not to wait for the DeleteTask to delete the channel 1496 // It's important not to wait for the DeleteTask to delete the channel
1475 // proxy. Kill it off now. That way, in case the profile is going away, the 1497 // proxy. Kill it off now. That way, in case the profile is going away, the
1476 // rest of the objects attached to this RenderProcessHost start going 1498 // rest of the objects attached to this RenderProcessHost start going
1477 // away first, since deleting the channel proxy will post a 1499 // away first, since deleting the channel proxy will post a
1478 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread. 1500 // OnChannelClosed() to IPC::ChannelProxy::Context on the IO thread.
1479 channel_.reset(); 1501 channel_.reset();
1480 gpu_message_filter_ = NULL; 1502 gpu_message_filter_ = NULL;
1481 message_port_message_filter_ = NULL; 1503 message_port_message_filter_ = NULL;
1482 screen_orientation_dispatcher_host_ = NULL; 1504 screen_orientation_dispatcher_host_ = NULL;
1505 RemoveUserData(kSessionStorageHolderKey);
1483 1506
1484 // Remove ourself from the list of renderer processes so that we can't be 1507 // Remove ourself from the list of renderer processes so that we can't be
1485 // reused in between now and when the Delete task runs. 1508 // reused in between now and when the Delete task runs.
1486 UnregisterHost(GetID()); 1509 UnregisterHost(GetID());
1487 } 1510 }
1488 } 1511 }
1489 1512
1490 void RenderProcessHostImpl::AddPendingView() { 1513 void RenderProcessHostImpl::AddPendingView() {
1491 pending_views_++; 1514 pending_views_++;
1492 } 1515 }
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 FOR_EACH_OBSERVER(RenderProcessHostObserver, 1909 FOR_EACH_OBSERVER(RenderProcessHostObserver,
1887 observers_, 1910 observers_,
1888 RenderProcessExited(this, GetHandle(), status, exit_code)); 1911 RenderProcessExited(this, GetHandle(), status, exit_code));
1889 within_process_died_observer_ = false; 1912 within_process_died_observer_ = false;
1890 1913
1891 child_process_launcher_.reset(); 1914 child_process_launcher_.reset();
1892 channel_.reset(); 1915 channel_.reset();
1893 gpu_message_filter_ = NULL; 1916 gpu_message_filter_ = NULL;
1894 message_port_message_filter_ = NULL; 1917 message_port_message_filter_ = NULL;
1895 screen_orientation_dispatcher_host_ = NULL; 1918 screen_orientation_dispatcher_host_ = NULL;
1919 RemoveUserData(kSessionStorageHolderKey);
1896 1920
1897 IDMap<IPC::Listener>::iterator iter(&listeners_); 1921 IDMap<IPC::Listener>::iterator iter(&listeners_);
1898 while (!iter.IsAtEnd()) { 1922 while (!iter.IsAtEnd()) {
1899 iter.GetCurrentValue()->OnMessageReceived( 1923 iter.GetCurrentValue()->OnMessageReceived(
1900 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(), 1924 ViewHostMsg_RenderProcessGone(iter.GetCurrentKey(),
1901 static_cast<int>(status), 1925 static_cast<int>(status),
1902 exit_code)); 1926 exit_code));
1903 iter.Advance(); 1927 iter.Advance();
1904 } 1928 }
1905 1929
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 if (!webrtc_log_message_callback_.is_null()) 1978 if (!webrtc_log_message_callback_.is_null())
1955 webrtc_log_message_callback_.Run(message); 1979 webrtc_log_message_callback_.Run(message);
1956 } 1980 }
1957 #endif 1981 #endif
1958 1982
1959 scoped_refptr<ScreenOrientationDispatcherHost> 1983 scoped_refptr<ScreenOrientationDispatcherHost>
1960 RenderProcessHostImpl::screen_orientation_dispatcher_host() const { 1984 RenderProcessHostImpl::screen_orientation_dispatcher_host() const {
1961 return make_scoped_refptr(screen_orientation_dispatcher_host_); 1985 return make_scoped_refptr(screen_orientation_dispatcher_host_);
1962 } 1986 }
1963 1987
1988 void RenderProcessHostImpl::ReleaseOnCloseACK(
1989 RenderProcessHost* host,
1990 const SessionStorageNamespaceMap& sessions,
1991 int view_route_id) {
1992 DCHECK(host);
1993 if (sessions.empty())
1994 return;
1995 SessionStorageHolder* holder = static_cast<SessionStorageHolder*>
1996 (host->GetUserData(kSessionStorageHolderKey));
1997 if (!holder) {
1998 holder = new SessionStorageHolder();
1999 host->SetUserData(
2000 kSessionStorageHolderKey,
2001 holder);
2002 }
2003 holder->Hold(sessions, view_route_id);
2004 }
2005
1964 void RenderProcessHostImpl::OnShutdownRequest() { 2006 void RenderProcessHostImpl::OnShutdownRequest() {
1965 // Don't shut down if there are active RenderViews, or if there are pending 2007 // Don't shut down if there are active RenderViews, or if there are pending
1966 // RenderViews being swapped back in. 2008 // RenderViews being swapped back in.
1967 // In single process mode, we never shutdown the renderer. 2009 // In single process mode, we never shutdown the renderer.
1968 int num_active_views = GetActiveViewCount(); 2010 int num_active_views = GetActiveViewCount();
1969 if (pending_views_ || num_active_views > 0 || run_renderer_in_process()) 2011 if (pending_views_ || num_active_views > 0 || run_renderer_in_process())
1970 return; 2012 return;
1971 2013
1972 // Notify any contents that might have swapped out renderers from this 2014 // Notify any contents that might have swapped out renderers from this
1973 // process. They should not attempt to swap them back in. 2015 // process. They should not attempt to swap them back in.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 scoped_refptr<AudioRendererHost> 2110 scoped_refptr<AudioRendererHost>
2069 RenderProcessHostImpl::audio_renderer_host() const { 2111 RenderProcessHostImpl::audio_renderer_host() const {
2070 return audio_renderer_host_; 2112 return audio_renderer_host_;
2071 } 2113 }
2072 2114
2073 void RenderProcessHostImpl::OnUserMetricsRecordAction( 2115 void RenderProcessHostImpl::OnUserMetricsRecordAction(
2074 const std::string& action) { 2116 const std::string& action) {
2075 RecordComputedAction(action); 2117 RecordComputedAction(action);
2076 } 2118 }
2077 2119
2120 void RenderProcessHostImpl::OnCloseACK(int old_route_id) {
2121 SessionStorageHolder* holder = static_cast<SessionStorageHolder*>
2122 (GetUserData(kSessionStorageHolderKey));
2123 if (!holder)
2124 return;
2125 holder->Release(old_route_id);
2126 }
2127
2078 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { 2128 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
2079 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); 2129 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size);
2080 } 2130 }
2081 2131
2082 void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost( 2132 void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost(
2083 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { 2133 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) {
2084 TRACE_EVENT0("renderer_host", 2134 TRACE_EVENT0("renderer_host",
2085 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost"); 2135 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwappedNoHost");
2086 if (!ui::LatencyInfo::Verify(params.latency_info, 2136 if (!ui::LatencyInfo::Verify(params.latency_info,
2087 "ViewHostMsg_CompositorSurfaceBuffersSwapped")) 2137 "ViewHostMsg_CompositorSurfaceBuffersSwapped"))
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 void RenderProcessHostImpl::GpuMemoryBufferAllocated( 2299 void RenderProcessHostImpl::GpuMemoryBufferAllocated(
2250 IPC::Message* reply, 2300 IPC::Message* reply,
2251 const gfx::GpuMemoryBufferHandle& handle) { 2301 const gfx::GpuMemoryBufferHandle& handle) {
2252 DCHECK_CURRENTLY_ON(BrowserThread::UI); 2302 DCHECK_CURRENTLY_ON(BrowserThread::UI);
2253 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, 2303 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply,
2254 handle); 2304 handle);
2255 Send(reply); 2305 Send(reply);
2256 } 2306 }
2257 2307
2258 } // namespace content 2308 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698