Chromium Code Reviews| 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 98e45d6a13a3609dcd123f443c7b52a23bcfe362..29411e470e66f736f15a76c5a92aee7fa7210f02 100644 |
| --- a/content/browser/renderer_host/render_process_host_impl.cc |
| +++ b/content/browser/renderer_host/render_process_host_impl.cc |
| @@ -353,6 +353,23 @@ void AddIntegerValue(CFMutableDictionaryRef dictionary, |
| } |
| #endif |
| +const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; |
| + |
| +class SessionStorageHolder : public base::SupportsUserData::Data { |
| + 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.
|
| + 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_; |
| +}; |
|
jochen (gone - plz use gerrit)
2014/06/04 08:16:24
nit. DISALLOW_COPY_AND_ASSIGN()
michaeln
2014/06/04 23:53:28
Done.
|
| + |
| } // namespace |
| RendererMainThreadFactoryFunction g_renderer_main_thread_factory = NULL; |
| @@ -1348,6 +1365,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(). |
| @@ -1479,6 +1497,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. |
| @@ -1892,6 +1911,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()) { |
| @@ -1960,6 +1980,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. |
| @@ -2074,6 +2112,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); |
| } |