| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/service_worker/service_worker_script_cache_map.h" | 5 #include "content/browser/service_worker/service_worker_script_cache_map.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/service_worker/service_worker_context_core.h" | 8 #include "content/browser/service_worker/service_worker_context_core.h" |
| 9 #include "content/browser/service_worker/service_worker_storage.h" | 9 #include "content/browser/service_worker/service_worker_storage.h" |
| 10 #include "content/browser/service_worker/service_worker_version.h" | 10 #include "content/browser/service_worker/service_worker_version.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 if (found == resource_ids_.end()) | 28 if (found == resource_ids_.end()) |
| 29 return kInvalidServiceWorkerResponseId; | 29 return kInvalidServiceWorkerResponseId; |
| 30 return found->second; | 30 return found->second; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void ServiceWorkerScriptCacheMap::NotifyStartedCaching( | 33 void ServiceWorkerScriptCacheMap::NotifyStartedCaching( |
| 34 const GURL& url, int64 resource_id) { | 34 const GURL& url, int64 resource_id) { |
| 35 DCHECK_EQ(kInvalidServiceWorkerResponseId, Lookup(url)); | 35 DCHECK_EQ(kInvalidServiceWorkerResponseId, Lookup(url)); |
| 36 DCHECK(owner_->status() == ServiceWorkerVersion::NEW); | 36 DCHECK(owner_->status() == ServiceWorkerVersion::NEW); |
| 37 resource_ids_[url] = resource_id; | 37 resource_ids_[url] = resource_id; |
| 38 context_->storage()->StoreUncommittedReponseId(resource_id); | 38 context_->storage()->StoreUncommittedResponseId(resource_id); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ServiceWorkerScriptCacheMap::NotifyFinishedCaching( | 41 void ServiceWorkerScriptCacheMap::NotifyFinishedCaching( |
| 42 const GURL& url, bool success) { | 42 const GURL& url, bool success) { |
| 43 DCHECK_NE(kInvalidServiceWorkerResponseId, Lookup(url)); | 43 DCHECK_NE(kInvalidServiceWorkerResponseId, Lookup(url)); |
| 44 DCHECK(owner_->status() == ServiceWorkerVersion::NEW); | 44 DCHECK(owner_->status() == ServiceWorkerVersion::NEW); |
| 45 if (!success) { | 45 if (!success) { |
| 46 context_->storage()->DoomUncommittedResponse(Lookup(url)); | 46 context_->storage()->DoomUncommittedResponse(Lookup(url)); |
| 47 has_error_ = true; | 47 has_error_ = true; |
| 48 resource_ids_.erase(url); | 48 resource_ids_.erase(url); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 63 const std::vector<ServiceWorkerDatabase::ResourceRecord>& resources) { | 63 const std::vector<ServiceWorkerDatabase::ResourceRecord>& resources) { |
| 64 DCHECK(resource_ids_.empty()); | 64 DCHECK(resource_ids_.empty()); |
| 65 typedef std::vector<ServiceWorkerDatabase::ResourceRecord> RecordVector; | 65 typedef std::vector<ServiceWorkerDatabase::ResourceRecord> RecordVector; |
| 66 for (RecordVector::const_iterator it = resources.begin(); | 66 for (RecordVector::const_iterator it = resources.begin(); |
| 67 it != resources.end(); ++it) { | 67 it != resources.end(); ++it) { |
| 68 resource_ids_[it->url] = it->resource_id; | 68 resource_ids_[it->url] = it->resource_id; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace content | 72 } // namespace content |
| OLD | NEW |