| Index: content/browser/service_worker/service_worker_script_cache_map.cc
|
| diff --git a/content/browser/service_worker/service_worker_script_cache_map.cc b/content/browser/service_worker/service_worker_script_cache_map.cc
|
| index 52a27588f9c2ae3fb5dd5bc380f3a3638ba2cfe6..062ae159a2aee50174aaf09143449de6bee269f6 100644
|
| --- a/content/browser/service_worker/service_worker_script_cache_map.cc
|
| +++ b/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<ServiceWorkerDatabase::ResourceRecord>* 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<ServiceWorkerDatabase::ResourceRecord>& resources) {
|
| - DCHECK(resource_ids_.empty());
|
| + DCHECK(resource_map_.empty());
|
| typedef std::vector<ServiceWorkerDatabase::ResourceRecord> RecordVector;
|
| for (RecordVector::const_iterator it = resources.begin();
|
| it != resources.end(); ++it) {
|
| - resource_ids_[it->url] = it->resource_id;
|
| + resource_map_[it->url] = *it;
|
| }
|
| }
|
|
|
|
|