OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/drive/file_cache_metadata.h" | 5 #include "chrome/browser/chromeos/drive/file_cache_metadata.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 leveldb::Status db_status = leveldb::DB::Open(options, db_path.AsUTF8Unsafe(), | 103 leveldb::Status db_status = leveldb::DB::Open(options, db_path.AsUTF8Unsafe(), |
104 &level_db); | 104 &level_db); |
105 | 105 |
106 // Delete the db and scan the physical cache. This will fix a corrupt db, but | 106 // Delete the db and scan the physical cache. This will fix a corrupt db, but |
107 // perhaps not other causes of failed DB::Open. | 107 // perhaps not other causes of failed DB::Open. |
108 DBOpenStatus uma_status = DB_OPEN_SUCCESS; | 108 DBOpenStatus uma_status = DB_OPEN_SUCCESS; |
109 if (!db_status.ok()) { | 109 if (!db_status.ok()) { |
110 LOG(WARNING) << "Cache db failed to open: " << db_status.ToString(); | 110 LOG(WARNING) << "Cache db failed to open: " << db_status.ToString(); |
111 uma_status = db_status.IsCorruption() ? | 111 uma_status = db_status.IsCorruption() ? |
112 DB_OPEN_FAILURE_CORRUPTION : DB_OPEN_FAILURE_OTHER; | 112 DB_OPEN_FAILURE_CORRUPTION : DB_OPEN_FAILURE_OTHER; |
113 const bool deleted = base::Delete(db_path, true); | 113 const bool deleted = base::DeleteFile(db_path, true); |
114 DCHECK(deleted); | 114 DCHECK(deleted); |
115 db_status = leveldb::DB::Open(options, db_path.value(), &level_db); | 115 db_status = leveldb::DB::Open(options, db_path.value(), &level_db); |
116 if (!db_status.ok()) { | 116 if (!db_status.ok()) { |
117 LOG(WARNING) << "Still failed to open: " << db_status.ToString(); | 117 LOG(WARNING) << "Still failed to open: " << db_status.ToString(); |
118 UMA_HISTOGRAM_ENUMERATION("Drive.CacheDBOpenStatus", | 118 UMA_HISTOGRAM_ENUMERATION("Drive.CacheDBOpenStatus", |
119 DB_OPEN_FAILURE_UNRECOVERABLE, | 119 DB_OPEN_FAILURE_UNRECOVERABLE, |
120 DB_OPEN_MAX_VALUE); | 120 DB_OPEN_MAX_VALUE); |
121 return INITIALIZE_FAILED; | 121 return INITIALIZE_FAILED; |
122 } | 122 } |
123 | 123 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 return make_scoped_ptr(new Iterator(iter.Pass())); | 181 return make_scoped_ptr(new Iterator(iter.Pass())); |
182 } | 182 } |
183 | 183 |
184 void FileCacheMetadata::AssertOnSequencedWorkerPool() { | 184 void FileCacheMetadata::AssertOnSequencedWorkerPool() { |
185 DCHECK(!blocking_task_runner_.get() || | 185 DCHECK(!blocking_task_runner_.get() || |
186 blocking_task_runner_->RunsTasksOnCurrentThread()); | 186 blocking_task_runner_->RunsTasksOnCurrentThread()); |
187 } | 187 } |
188 | 188 |
189 } // namespace internal | 189 } // namespace internal |
190 } // namespace drive | 190 } // namespace drive |
OLD | NEW |