Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: content/browser/service_worker/service_worker_script_cache_map.cc

Issue 1393783002: ServiceWorker: Schedule DeleteAndStartOver when failing to store resource ids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_disk_cache.h" 9 #include "content/browser/service_worker/service_worker_disk_cache.h"
10 #include "content/browser/service_worker/service_worker_storage.h" 10 #include "content/browser/service_worker/service_worker_storage.h"
(...skipping 30 matching lines...) Expand all
41 void ServiceWorkerScriptCacheMap::NotifyStartedCaching( 41 void ServiceWorkerScriptCacheMap::NotifyStartedCaching(
42 const GURL& url, int64 resource_id) { 42 const GURL& url, int64 resource_id) {
43 DCHECK_EQ(kInvalidServiceWorkerResponseId, LookupResourceId(url)); 43 DCHECK_EQ(kInvalidServiceWorkerResponseId, LookupResourceId(url));
44 DCHECK(owner_->status() == ServiceWorkerVersion::NEW || 44 DCHECK(owner_->status() == ServiceWorkerVersion::NEW ||
45 owner_->status() == ServiceWorkerVersion::INSTALLING) 45 owner_->status() == ServiceWorkerVersion::INSTALLING)
46 << owner_->status(); 46 << owner_->status();
47 if (!context_) 47 if (!context_)
48 return; // Our storage has been wiped via DeleteAndStartOver. 48 return; // Our storage has been wiped via DeleteAndStartOver.
49 resource_map_[url] = 49 resource_map_[url] =
50 ServiceWorkerDatabase::ResourceRecord(resource_id, url, -1); 50 ServiceWorkerDatabase::ResourceRecord(resource_id, url, -1);
51 context_->storage()->StoreUncommittedResponseId(resource_id); 51 context_->storage()->StoreUncommittedResourceId(resource_id);
52 } 52 }
53 53
54 void ServiceWorkerScriptCacheMap::NotifyFinishedCaching( 54 void ServiceWorkerScriptCacheMap::NotifyFinishedCaching(
55 const GURL& url, 55 const GURL& url,
56 int64 size_bytes, 56 int64 size_bytes,
57 const net::URLRequestStatus& status, 57 const net::URLRequestStatus& status,
58 const std::string& status_message) { 58 const std::string& status_message) {
59 DCHECK_NE(kInvalidServiceWorkerResponseId, LookupResourceId(url)); 59 DCHECK_NE(kInvalidServiceWorkerResponseId, LookupResourceId(url));
60 DCHECK(owner_->status() == ServiceWorkerVersion::NEW || 60 DCHECK(owner_->status() == ServiceWorkerVersion::NEW ||
61 owner_->status() == ServiceWorkerVersion::INSTALLING || 61 owner_->status() == ServiceWorkerVersion::INSTALLING ||
62 owner_->status() == ServiceWorkerVersion::REDUNDANT); 62 owner_->status() == ServiceWorkerVersion::REDUNDANT);
63 if (!context_) 63 if (!context_)
64 return; // Our storage has been wiped via DeleteAndStartOver. 64 return; // Our storage has been wiped via DeleteAndStartOver.
65 if (!status.is_success()) { 65 if (!status.is_success()) {
66 context_->storage()->DoomUncommittedResponse(LookupResourceId(url)); 66 context_->storage()->ClearUncommittedResourceId(LookupResourceId(url));
nhiroki 2015/10/07 06:10:27 Renamed this to ClearUncommittedResourceId "DoomU
nhiroki 2015/10/07 08:24:43 Sorry for confusing you. This comment was complete
67 resource_map_.erase(url); 67 resource_map_.erase(url);
68 if (owner_->script_url() == url) { 68 if (owner_->script_url() == url) {
69 main_script_status_ = status; 69 main_script_status_ = status;
70 main_script_status_message_ = status_message; 70 main_script_status_message_ = status_message;
71 } 71 }
72 } else { 72 } else {
73 resource_map_[url].size_bytes = size_bytes; 73 resource_map_[url].size_bytes = size_bytes;
74 } 74 }
75 } 75 }
76 76
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 void ServiceWorkerScriptCacheMap::OnMetadataWritten( 126 void ServiceWorkerScriptCacheMap::OnMetadataWritten(
127 scoped_ptr<ServiceWorkerResponseMetadataWriter> writer, 127 scoped_ptr<ServiceWorkerResponseMetadataWriter> writer,
128 const net::CompletionCallback& callback, 128 const net::CompletionCallback& callback,
129 int result) { 129 int result) {
130 callback.Run(result); 130 callback.Run(result);
131 } 131 }
132 132
133 } // namespace content 133 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698