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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 23b52ec2bb847062b07e51d6c29b4da6fcb90289..72eb3bcd33b45bc99e717c51ca67220d56a10cfb 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -353,6 +353,27 @@ void AddIntegerValue(CFMutableDictionaryRef dictionary,
}
#endif
+const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey";
+
+class SessionStorageHolder : public base::SupportsUserData::Data {
+ public:
+ SessionStorageHolder() {}
+ virtual ~SessionStorageHolder() {}
+
+ void Hold(const SessionStorageNamespaceMap& sessions, int view_route_id) {
+ session_storage_namespaces_awaiting_close_[view_route_id] = sessions;
+ }
+
+ void Release(int old_route_id) {
+ session_storage_namespaces_awaiting_close_.erase(old_route_id);
+ }
+
+ private:
+ std::map<int, SessionStorageNamespaceMap >
+ session_storage_namespaces_awaiting_close_;
+ DISALLOW_COPY_AND_ASSIGN(SessionStorageHolder);
+};
+
} // namespace
RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL;
@@ -1349,6 +1370,7 @@ bool RenderProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(
ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
OnAllocateGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_Close_ACK, OnCloseACK)
// Adding single handlers for your service here is fine, but once your
// service needs more than one handler, please extract them into a new
// message filter and add that filter to CreateMessageFilters().
@@ -1480,6 +1502,7 @@ void RenderProcessHostImpl::Cleanup() {
gpu_message_filter_ = NULL;
message_port_message_filter_ = NULL;
screen_orientation_dispatcher_host_ = NULL;
+ RemoveUserData(kSessionStorageHolderKey);
// Remove ourself from the list of renderer processes so that we can't be
// reused in between now and when the Delete task runs.
@@ -1893,6 +1916,7 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) {
gpu_message_filter_ = NULL;
message_port_message_filter_ = NULL;
screen_orientation_dispatcher_host_ = NULL;
+ RemoveUserData(kSessionStorageHolderKey);
IDMap<IPC::Listener>::iterator iter(&listeners_);
while (!iter.IsAtEnd()) {
@@ -1961,6 +1985,24 @@ RenderProcessHostImpl::screen_orientation_dispatcher_host() const {
return make_scoped_refptr(screen_orientation_dispatcher_host_);
}
+void RenderProcessHostImpl::ReleaseOnCloseACK(
+ RenderProcessHost* host,
+ const SessionStorageNamespaceMap& sessions,
+ int view_route_id) {
+ DCHECK(host);
+ if (sessions.empty())
+ return;
+ SessionStorageHolder* holder = static_cast<SessionStorageHolder*>
+ (host->GetUserData(kSessionStorageHolderKey));
+ if (!holder) {
+ holder = new SessionStorageHolder();
+ host->SetUserData(
+ kSessionStorageHolderKey,
+ holder);
+ }
+ holder->Hold(sessions, view_route_id);
+}
+
void RenderProcessHostImpl::OnShutdownRequest() {
// Don't shut down if there are active RenderViews, or if there are pending
// RenderViews being swapped back in.
@@ -2075,6 +2117,14 @@ void RenderProcessHostImpl::OnUserMetricsRecordAction(
RecordComputedAction(action);
}
+void RenderProcessHostImpl::OnCloseACK(int old_route_id) {
+ SessionStorageHolder* holder = static_cast<SessionStorageHolder*>
+ (GetUserData(kSessionStorageHolderKey));
+ if (!holder)
+ return;
+ holder->Release(old_route_id);
+}
+
void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size);
}

Powered by Google App Engine
This is Rietveld 408576698