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

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

Issue 654823002: ServiceWorker: Convert ServiceWorkerDatabase::Status to string for logging (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate reviews and rebase Created 6 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_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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 else if (status.IsNotFound()) 255 else if (status.IsNotFound())
256 return ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND; 256 return ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND;
257 else if (status.IsIOError()) 257 else if (status.IsIOError())
258 return ServiceWorkerDatabase::STATUS_ERROR_IO_ERROR; 258 return ServiceWorkerDatabase::STATUS_ERROR_IO_ERROR;
259 else if (status.IsCorruption()) 259 else if (status.IsCorruption())
260 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED; 260 return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED;
261 else 261 else
262 return ServiceWorkerDatabase::STATUS_ERROR_FAILED; 262 return ServiceWorkerDatabase::STATUS_ERROR_FAILED;
263 } 263 }
264 264
265 const char* StatusToString(ServiceWorkerDatabase::Status status) { 265 } // namespace
266
267 const char* ServiceWorkerDatabase::StatusToString(
268 ServiceWorkerDatabase::Status status) {
266 switch (status) { 269 switch (status) {
267 case ServiceWorkerDatabase::STATUS_OK: 270 case ServiceWorkerDatabase::STATUS_OK:
268 return "Database OK"; 271 return "Database OK";
269 case ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND: 272 case ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND:
270 return "Database not found"; 273 return "Database not found";
271 case ServiceWorkerDatabase::STATUS_ERROR_IO_ERROR: 274 case ServiceWorkerDatabase::STATUS_ERROR_IO_ERROR:
272 return "Database IO error"; 275 return "Database IO error";
273 case ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED: 276 case ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED:
274 return "Database corrupted"; 277 return "Database corrupted";
275 case ServiceWorkerDatabase::STATUS_ERROR_FAILED: 278 case ServiceWorkerDatabase::STATUS_ERROR_FAILED:
276 return "Database operation failed"; 279 return "Database operation failed";
277 case ServiceWorkerDatabase::STATUS_ERROR_MAX: 280 case ServiceWorkerDatabase::STATUS_ERROR_MAX:
278 NOTREACHED(); 281 NOTREACHED();
279 return "Database unknown error"; 282 return "Database unknown error";
280 } 283 }
281 NOTREACHED(); 284 NOTREACHED();
282 return "Database unknown error"; 285 return "Database unknown error";
283 } 286 }
284 287
285 } // namespace
286
287 ServiceWorkerDatabase::RegistrationData::RegistrationData() 288 ServiceWorkerDatabase::RegistrationData::RegistrationData()
288 : registration_id(kInvalidServiceWorkerRegistrationId), 289 : registration_id(kInvalidServiceWorkerRegistrationId),
289 version_id(kInvalidServiceWorkerVersionId), 290 version_id(kInvalidServiceWorkerVersionId),
290 is_active(false), 291 is_active(false),
291 has_fetch_handler(false) { 292 has_fetch_handler(false) {
292 } 293 }
293 294
294 ServiceWorkerDatabase::RegistrationData::~RegistrationData() { 295 ServiceWorkerDatabase::RegistrationData::~RegistrationData() {
295 } 296 }
296 297
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1114
1114 void ServiceWorkerDatabase::HandleWriteResult( 1115 void ServiceWorkerDatabase::HandleWriteResult(
1115 const tracked_objects::Location& from_here, 1116 const tracked_objects::Location& from_here,
1116 Status status) { 1117 Status status) {
1117 if (status != STATUS_OK) 1118 if (status != STATUS_OK)
1118 Disable(from_here, status); 1119 Disable(from_here, status);
1119 ServiceWorkerMetrics::CountWriteDatabaseResult(status); 1120 ServiceWorkerMetrics::CountWriteDatabaseResult(status);
1120 } 1121 }
1121 1122
1122 } // namespace content 1123 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698