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_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 29 matching lines...) Expand all Loading... |
40 if (!context_) | 40 if (!context_) |
41 return; // Our storage has been wiped via DeleteAndStartOver. | 41 return; // Our storage has been wiped via DeleteAndStartOver. |
42 resource_map_[url] = | 42 resource_map_[url] = |
43 ServiceWorkerDatabase::ResourceRecord(resource_id, url, -1); | 43 ServiceWorkerDatabase::ResourceRecord(resource_id, url, -1); |
44 context_->storage()->StoreUncommittedResourceId(resource_id); | 44 context_->storage()->StoreUncommittedResourceId(resource_id); |
45 } | 45 } |
46 | 46 |
47 void ServiceWorkerScriptCacheMap::NotifyFinishedCaching( | 47 void ServiceWorkerScriptCacheMap::NotifyFinishedCaching( |
48 const GURL& url, | 48 const GURL& url, |
49 int64_t size_bytes, | 49 int64_t size_bytes, |
50 const net::URLRequestStatus& status, | 50 net::Error net_error, |
51 const std::string& status_message) { | 51 const std::string& status_message) { |
52 DCHECK_NE(kInvalidServiceWorkerResourceId, LookupResourceId(url)); | 52 DCHECK_NE(kInvalidServiceWorkerResourceId, LookupResourceId(url)); |
| 53 DCHECK_NE(net::ERR_IO_PENDING, net_error); |
53 DCHECK(owner_->status() == ServiceWorkerVersion::NEW || | 54 DCHECK(owner_->status() == ServiceWorkerVersion::NEW || |
54 owner_->status() == ServiceWorkerVersion::INSTALLING || | 55 owner_->status() == ServiceWorkerVersion::INSTALLING || |
55 owner_->status() == ServiceWorkerVersion::REDUNDANT); | 56 owner_->status() == ServiceWorkerVersion::REDUNDANT); |
56 if (!context_) | 57 if (!context_) |
57 return; // Our storage has been wiped via DeleteAndStartOver. | 58 return; // Our storage has been wiped via DeleteAndStartOver. |
58 if (!status.is_success()) { | 59 if (net_error != net::OK) { |
59 context_->storage()->DoomUncommittedResource(LookupResourceId(url)); | 60 context_->storage()->DoomUncommittedResource(LookupResourceId(url)); |
60 resource_map_.erase(url); | 61 resource_map_.erase(url); |
61 if (owner_->script_url() == url) { | 62 if (owner_->script_url() == url) { |
62 main_script_status_ = status; | 63 main_script_status_ = net::URLRequestStatus::FromError(net_error); |
63 main_script_status_message_ = status_message; | 64 main_script_status_message_ = status_message; |
64 } | 65 } |
65 } else { | 66 } else { |
66 resource_map_[url].size_bytes = size_bytes; | 67 resource_map_[url].size_bytes = size_bytes; |
67 } | 68 } |
68 } | 69 } |
69 | 70 |
70 void ServiceWorkerScriptCacheMap::GetResources( | 71 void ServiceWorkerScriptCacheMap::GetResources( |
71 std::vector<ServiceWorkerDatabase::ResourceRecord>* resources) { | 72 std::vector<ServiceWorkerDatabase::ResourceRecord>* resources) { |
72 DCHECK(resources->empty()); | 73 DCHECK(resources->empty()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 118 } |
118 | 119 |
119 void ServiceWorkerScriptCacheMap::OnMetadataWritten( | 120 void ServiceWorkerScriptCacheMap::OnMetadataWritten( |
120 std::unique_ptr<ServiceWorkerResponseMetadataWriter> writer, | 121 std::unique_ptr<ServiceWorkerResponseMetadataWriter> writer, |
121 const net::CompletionCallback& callback, | 122 const net::CompletionCallback& callback, |
122 int result) { | 123 int result) { |
123 callback.Run(result); | 124 callback.Run(result); |
124 } | 125 } |
125 | 126 |
126 } // namespace content | 127 } // namespace content |
OLD | NEW |