Chromium Code Reviews

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

Issue 845313004: Service Worker: Improve error messages from register(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git-cl format Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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_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 33 matching lines...)
44 if (!context_) 44 if (!context_)
45 return; // Our storage has been wiped via DeleteAndStartOver. 45 return; // Our storage has been wiped via DeleteAndStartOver.
46 resource_map_[url] = 46 resource_map_[url] =
47 ServiceWorkerDatabase::ResourceRecord(resource_id, url, -1); 47 ServiceWorkerDatabase::ResourceRecord(resource_id, url, -1);
48 context_->storage()->StoreUncommittedResponseId(resource_id); 48 context_->storage()->StoreUncommittedResponseId(resource_id);
49 } 49 }
50 50
51 void ServiceWorkerScriptCacheMap::NotifyFinishedCaching( 51 void ServiceWorkerScriptCacheMap::NotifyFinishedCaching(
52 const GURL& url, 52 const GURL& url,
53 int64 size_bytes, 53 int64 size_bytes,
54 const net::URLRequestStatus& status) { 54 const net::URLRequestStatus& status,
55 const std::string& status_message) {
55 DCHECK_NE(kInvalidServiceWorkerResponseId, LookupResourceId(url)); 56 DCHECK_NE(kInvalidServiceWorkerResponseId, LookupResourceId(url));
56 DCHECK(owner_->status() == ServiceWorkerVersion::NEW || 57 DCHECK(owner_->status() == ServiceWorkerVersion::NEW ||
57 owner_->status() == ServiceWorkerVersion::INSTALLING); 58 owner_->status() == ServiceWorkerVersion::INSTALLING);
58 if (!context_) 59 if (!context_)
59 return; // Our storage has been wiped via DeleteAndStartOver. 60 return; // Our storage has been wiped via DeleteAndStartOver.
60 if (!status.is_success()) { 61 if (!status.is_success()) {
61 context_->storage()->DoomUncommittedResponse(LookupResourceId(url)); 62 context_->storage()->DoomUncommittedResponse(LookupResourceId(url));
62 resource_map_.erase(url); 63 resource_map_.erase(url);
63 if (owner_->script_url() == url) 64 if (owner_->script_url() == url) {
64 main_script_status_ = status; 65 main_script_status_ = status;
66 main_script_status_message_ = status_message;
67 }
65 } else { 68 } else {
66 resource_map_[url].size_bytes = size_bytes; 69 resource_map_[url].size_bytes = size_bytes;
67 } 70 }
68 } 71 }
69 72
70 void ServiceWorkerScriptCacheMap::GetResources( 73 void ServiceWorkerScriptCacheMap::GetResources(
71 std::vector<ServiceWorkerDatabase::ResourceRecord>* resources) { 74 std::vector<ServiceWorkerDatabase::ResourceRecord>* resources) {
72 DCHECK(resources->empty()); 75 DCHECK(resources->empty());
73 for (ResourceMap::const_iterator it = resource_map_.begin(); 76 for (ResourceMap::const_iterator it = resource_map_.begin();
74 it != resource_map_.end(); 77 it != resource_map_.end();
75 ++it) { 78 ++it) {
76 resources->push_back(it->second); 79 resources->push_back(it->second);
77 } 80 }
78 } 81 }
79 82
80 void ServiceWorkerScriptCacheMap::SetResources( 83 void ServiceWorkerScriptCacheMap::SetResources(
81 const std::vector<ServiceWorkerDatabase::ResourceRecord>& resources) { 84 const std::vector<ServiceWorkerDatabase::ResourceRecord>& resources) {
82 DCHECK(resource_map_.empty()); 85 DCHECK(resource_map_.empty());
83 typedef std::vector<ServiceWorkerDatabase::ResourceRecord> RecordVector; 86 typedef std::vector<ServiceWorkerDatabase::ResourceRecord> RecordVector;
84 for (RecordVector::const_iterator it = resources.begin(); 87 for (RecordVector::const_iterator it = resources.begin();
85 it != resources.end(); ++it) { 88 it != resources.end(); ++it) {
86 resource_map_[it->url] = *it; 89 resource_map_[it->url] = *it;
87 } 90 }
88 } 91 }
89 92
90 } // namespace content 93 } // namespace content
OLDNEW

Powered by Google App Engine