X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcontent%2Fbrowser%2Fservice_worker%2Fservice_worker_script_cache_map.cc;h=062ae159a2aee50174aaf09143449de6bee269f6;hb=1afa4dd80ef85af7c90efaea6959db1d92330844;hp=52a27588f9c2ae3fb5dd5bc380f3a3638ba2cfe6;hpb=90762837333c13ccf56f2ad88e4481fc71e8d281;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/content/browser/service_worker/service_worker_script_cache_map.cc b/src/content/browser/service_worker/service_worker_script_cache_map.cc index 52a2758..062ae15 100644 --- a/src/content/browser/service_worker/service_worker_script_cache_map.cc +++ b/src/content/browser/service_worker/service_worker_script_cache_map.cc @@ -22,52 +22,64 @@ ServiceWorkerScriptCacheMap::ServiceWorkerScriptCacheMap( ServiceWorkerScriptCacheMap::~ServiceWorkerScriptCacheMap() { } -int64 ServiceWorkerScriptCacheMap::Lookup(const GURL& url) { - ResourceIDMap::const_iterator found = resource_ids_.find(url); - if (found == resource_ids_.end()) +int64 ServiceWorkerScriptCacheMap::LookupResourceId(const GURL& url) { + ResourceMap::const_iterator found = resource_map_.find(url); + if (found == resource_map_.end()) return kInvalidServiceWorkerResponseId; - return found->second; + return found->second.resource_id; +} + +int64 ServiceWorkerScriptCacheMap::LookupResourceSize(const GURL& url) { + ResourceMap::const_iterator found = resource_map_.find(url); + if (found == resource_map_.end()) + return kInvalidServiceWorkerResponseId; + return found->second.size_bytes; } void ServiceWorkerScriptCacheMap::NotifyStartedCaching( const GURL& url, int64 resource_id) { - DCHECK_EQ(kInvalidServiceWorkerResponseId, Lookup(url)); + DCHECK_EQ(kInvalidServiceWorkerResponseId, LookupResourceId(url)); DCHECK(owner_->status() == ServiceWorkerVersion::NEW || owner_->status() == ServiceWorkerVersion::INSTALLING); - resource_ids_[url] = resource_id; + resource_map_[url] = + ServiceWorkerDatabase::ResourceRecord(resource_id, url, -1); context_->storage()->StoreUncommittedResponseId(resource_id); } void ServiceWorkerScriptCacheMap::NotifyFinishedCaching( - const GURL& url, const net::URLRequestStatus& status) { - DCHECK_NE(kInvalidServiceWorkerResponseId, Lookup(url)); + const GURL& url, + int64 size_bytes, + const net::URLRequestStatus& status) { + DCHECK_NE(kInvalidServiceWorkerResponseId, LookupResourceId(url)); DCHECK(owner_->status() == ServiceWorkerVersion::NEW || owner_->status() == ServiceWorkerVersion::INSTALLING); if (!status.is_success()) { - context_->storage()->DoomUncommittedResponse(Lookup(url)); - resource_ids_.erase(url); + context_->storage()->DoomUncommittedResponse(LookupResourceId(url)); + resource_map_.erase(url); if (owner_->script_url() == url) main_script_status_ = status; + } else { + resource_map_[url].size_bytes = size_bytes; } } void ServiceWorkerScriptCacheMap::GetResources( std::vector* resources) { DCHECK(resources->empty()); - for (ResourceIDMap::const_iterator it = resource_ids_.begin(); - it != resource_ids_.end(); ++it) { - resources->push_back( - ServiceWorkerDatabase::ResourceRecord(it->second, it->first)); + for (ResourceMap::const_iterator it = resource_map_.begin(); + it != resource_map_.end(); + ++it) { + resources->push_back(it->second); } } void ServiceWorkerScriptCacheMap::SetResources( const std::vector& resources) { - DCHECK(resource_ids_.empty()); + DCHECK(resource_map_.empty()); typedef std::vector RecordVector; for (RecordVector::const_iterator it = resources.begin(); it != resources.end(); ++it) { - resource_ids_[it->url] = it->resource_id; + resource_map_[it->url] = *it; } }