Index: content/browser/appcache/appcache_backend_impl.cc |
diff --git a/content/browser/appcache/appcache_backend_impl.cc b/content/browser/appcache/appcache_backend_impl.cc |
index 7f29c3e97a713cb7a13924b6cc27a7fb9113627a..6b98b02c3761b4d3941253ba0baf8e77b08a20e5 100644 |
--- a/content/browser/appcache/appcache_backend_impl.cc |
+++ b/content/browser/appcache/appcache_backend_impl.cc |
@@ -8,6 +8,8 @@ |
#include "content/browser/appcache/appcache.h" |
#include "content/browser/appcache/appcache_group.h" |
#include "content/browser/appcache/appcache_service_impl.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "content/public/common/browser_side_navigation_policy.h" |
namespace content { |
@@ -34,8 +36,22 @@ void AppCacheBackendImpl::Initialize(AppCacheServiceImpl* service, |
} |
bool AppCacheBackendImpl::RegisterHost(int id) { |
- if (GetHost(id)) |
+ AppCacheHost* host = GetHost(id); |
+ |
+ if (host) { |
+ // PlzNavigate. The is precreated which means we want to avoid registering |
+ // it again. |
+ if (IsBrowserSideNavigationEnabled()) { |
+ auto found = pending_hosts_.find(id); |
+ DCHECK(found != pending_hosts_.end()); |
michaeln
2016/12/05 21:52:54
Since this |id| is given to us by a potentially co
ananta
2016/12/06 01:24:38
The pending hosts are no longer needed with your s
|
+ pending_hosts_.erase(found); |
+ // Switch the frontend proxy so that the host can make IPC calls from |
+ // here on. |
+ host->set_frontend(frontend_); |
+ return true; |
+ } |
return false; |
+ } |
hosts_[id] = base::MakeUnique<AppCacheHost>(id, frontend_, service_); |
return true; |
@@ -166,4 +182,19 @@ void AppCacheBackendImpl::TransferHostIn(int new_host_id, |
found->second = std::move(host); |
} |
+void AppCacheBackendImpl::RegisterPrecreatedHost( |
+ std::unique_ptr<AppCacheHost> host) { |
+ DCHECK(IsBrowserSideNavigationEnabled()); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ |
+ DCHECK(host.get()); |
+ // Mark the host as pending so we can avoid registering it again in the |
+ // RegisterHost() call. |
+ DCHECK(pending_hosts_.find(host->host_id()) == pending_hosts_.end()); |
+ pending_hosts_.insert(host->host_id()); |
+ |
+ DCHECK(hosts_.find(host->host_id()) == hosts_.end()); |
+ hosts_[host->host_id()] = std::move(host); |
+} |
+ |
} // namespace content |