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 "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 leveldb::Options options; | 962 leveldb::Options options; |
963 if (path_.empty()) { | 963 if (path_.empty()) { |
964 if (env_) { | 964 if (env_) { |
965 options.env = env_.get(); | 965 options.env = env_.get(); |
966 } else { | 966 } else { |
967 // In-memory database not initialized. | 967 // In-memory database not initialized. |
968 return STATUS_OK; | 968 return STATUS_OK; |
969 } | 969 } |
970 } | 970 } |
971 | 971 |
972 return LevelDBStatusToStatus( | 972 Status status = |
973 leveldb::DestroyDB(path_.AsUTF8Unsafe(), options)); | 973 LevelDBStatusToStatus(leveldb::DestroyDB(path_.AsUTF8Unsafe(), options)); |
| 974 ServiceWorkerMetrics::RecordDestroyDatabaseResult(status); |
| 975 return status; |
974 } | 976 } |
975 | 977 |
976 ServiceWorkerDatabase::Status ServiceWorkerDatabase::LazyOpen( | 978 ServiceWorkerDatabase::Status ServiceWorkerDatabase::LazyOpen( |
977 bool create_if_missing) { | 979 bool create_if_missing) { |
978 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); | 980 DCHECK(sequence_checker_.CalledOnValidSequencedThread()); |
979 | 981 |
980 // Do not try to open a database if we tried and failed once. | 982 // Do not try to open a database if we tried and failed once. |
981 if (state_ == DISABLED) | 983 if (state_ == DISABLED) |
982 return STATUS_ERROR_FAILED; | 984 return STATUS_ERROR_FAILED; |
983 if (IsOpen()) | 985 if (IsOpen()) |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 | 1445 |
1444 void ServiceWorkerDatabase::HandleWriteResult( | 1446 void ServiceWorkerDatabase::HandleWriteResult( |
1445 const tracked_objects::Location& from_here, | 1447 const tracked_objects::Location& from_here, |
1446 Status status) { | 1448 Status status) { |
1447 if (status != STATUS_OK) | 1449 if (status != STATUS_OK) |
1448 Disable(from_here, status); | 1450 Disable(from_here, status); |
1449 ServiceWorkerMetrics::CountWriteDatabaseResult(status); | 1451 ServiceWorkerMetrics::CountWriteDatabaseResult(status); |
1450 } | 1452 } |
1451 | 1453 |
1452 } // namespace content | 1454 } // namespace content |
OLD | NEW |