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_database.h" | 5 #include "content/browser/service_worker/service_worker_database.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 DCHECK(out); | 208 DCHECK(out); |
209 ServiceWorkerRegistrationData data; | 209 ServiceWorkerRegistrationData data; |
210 if (!data.ParseFromString(serialized)) | 210 if (!data.ParseFromString(serialized)) |
211 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; | 211 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; |
212 | 212 |
213 GURL scope_url(data.scope_url()); | 213 GURL scope_url(data.scope_url()); |
214 GURL script_url(data.script_url()); | 214 GURL script_url(data.script_url()); |
215 if (!scope_url.is_valid() || | 215 if (!scope_url.is_valid() || |
216 !script_url.is_valid() || | 216 !script_url.is_valid() || |
217 scope_url.GetOrigin() != script_url.GetOrigin()) { | 217 scope_url.GetOrigin() != script_url.GetOrigin()) { |
218 DLOG(ERROR) << "Scope URL '" << data.scope_url() << "' and/or script url '" | |
219 << data.script_url() | |
220 << "' are invalid or have mismatching origins."; | |
221 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; | 218 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; |
222 } | 219 } |
223 | 220 |
224 // Convert ServiceWorkerRegistrationData to RegistrationData. | 221 // Convert ServiceWorkerRegistrationData to RegistrationData. |
225 out->registration_id = data.registration_id(); | 222 out->registration_id = data.registration_id(); |
226 out->scope = scope_url; | 223 out->scope = scope_url; |
227 out->script = script_url; | 224 out->script = script_url; |
228 out->version_id = data.version_id(); | 225 out->version_id = data.version_id(); |
229 out->is_active = data.is_active(); | 226 out->is_active = data.is_active(); |
230 out->has_fetch_handler = data.has_fetch_handler(); | 227 out->has_fetch_handler = data.has_fetch_handler(); |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 | 1113 |
1117 void ServiceWorkerDatabase::HandleWriteResult( | 1114 void ServiceWorkerDatabase::HandleWriteResult( |
1118 const tracked_objects::Location& from_here, | 1115 const tracked_objects::Location& from_here, |
1119 Status status) { | 1116 Status status) { |
1120 if (status != STATUS_OK) | 1117 if (status != STATUS_OK) |
1121 Disable(from_here, status); | 1118 Disable(from_here, status); |
1122 ServiceWorkerMetrics::CountWriteDatabaseResult(status); | 1119 ServiceWorkerMetrics::CountWriteDatabaseResult(status); |
1123 } | 1120 } |
1124 | 1121 |
1125 } // namespace content | 1122 } // namespace content |
OLD | NEW |