Commit 7b7729f3 authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

AppCache: Refactor FillCacheInfo() -> CreateCacheInfo().

The function populates an AppCacheInfo instance passed by pointer, and
is always called with a default-initialized instance. This CL makes the
function return an AppCacheInfo instead, and relies on NVRO to avoid
degrading runtime performance.

Change-Id: I62b6f2a71409634d3264c84954744c9d265e3c8c
Reviewed-on: https://chromium-review.googlesource.com/1184506
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Reviewed-by: default avatarJoshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585039}
parent 66cfe1a9
...@@ -24,29 +24,31 @@ namespace content { ...@@ -24,29 +24,31 @@ namespace content {
namespace { namespace {
void FillCacheInfo(const AppCache* cache, AppCacheInfo CreateCacheInfo(const AppCache* cache,
const GURL& manifest_url, const GURL& manifest_url,
AppCacheStatus status, AppCacheInfo* info) { AppCacheStatus status) {
info->manifest_url = manifest_url; AppCacheInfo info;
info->status = status; info.manifest_url = manifest_url;
info.status = status;
if (!cache) if (!cache)
return; return info;
info->cache_id = cache->cache_id(); info.cache_id = cache->cache_id();
if (!cache->is_complete()) if (!cache->is_complete())
return; return info;
DCHECK(cache->owning_group()); DCHECK(cache->owning_group());
info->is_complete = true; info.is_complete = true;
info->group_id = cache->owning_group()->group_id(); info.group_id = cache->owning_group()->group_id();
info->last_update_time = cache->update_time(); info.last_update_time = cache->update_time();
info->creation_time = cache->owning_group()->creation_time(); info.creation_time = cache->owning_group()->creation_time();
info->size = cache->cache_size(); info.size = cache->cache_size();
return info;
} }
} // Anonymous namespace } // namespace
AppCacheHost::AppCacheHost(int host_id, AppCacheHost::AppCacheHost(int host_id,
AppCacheFrontend* frontend, AppCacheFrontend* frontend,
...@@ -463,9 +465,8 @@ void AppCacheHost::OnUpdateComplete(AppCacheGroup* group) { ...@@ -463,9 +465,8 @@ void AppCacheHost::OnUpdateComplete(AppCacheGroup* group) {
if (associated_cache_info_pending_ && associated_cache_.get() && if (associated_cache_info_pending_ && associated_cache_.get() &&
associated_cache_->is_complete()) { associated_cache_->is_complete()) {
AppCacheInfo info; AppCacheInfo info = CreateCacheInfo(associated_cache_.get(),
FillCacheInfo( preferred_manifest_url_, GetStatus());
associated_cache_.get(), preferred_manifest_url_, GetStatus(), &info);
associated_cache_info_pending_ = false; associated_cache_info_pending_ = false;
// In the network service world, we need to pass the URLLoaderFactory // In the network service world, we need to pass the URLLoaderFactory
// instance to the renderer which it can use to request subresources. // instance to the renderer which it can use to request subresources.
...@@ -562,11 +563,10 @@ void AppCacheHost::AssociateCacheHelper(AppCache* cache, ...@@ -562,11 +563,10 @@ void AppCacheHost::AssociateCacheHelper(AppCache* cache,
associated_cache_ = cache; associated_cache_ = cache;
SetSwappableCache(cache ? cache->owning_group() : nullptr); SetSwappableCache(cache ? cache->owning_group() : nullptr);
associated_cache_info_pending_ = cache && !cache->is_complete(); associated_cache_info_pending_ = cache && !cache->is_complete();
AppCacheInfo info;
if (cache) if (cache)
cache->AssociateHost(this); cache->AssociateHost(this);
FillCacheInfo(cache, manifest_url, GetStatus(), &info); AppCacheInfo info = CreateCacheInfo(cache, manifest_url, GetStatus());
// In the network service world, we need to pass the URLLoaderFactory // In the network service world, we need to pass the URLLoaderFactory
// instance to the renderer which it can use to request subresources. // instance to the renderer which it can use to request subresources.
// This ensures that they can be served out of the AppCache. // This ensures that they can be served out of the AppCache.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment