| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 FileCacheMetadata::~FileCacheMetadata() { | 90 FileCacheMetadata::~FileCacheMetadata() { |
| 91 AssertOnSequencedWorkerPool(); | 91 AssertOnSequencedWorkerPool(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 FileCacheMetadata::InitializeResult FileCacheMetadata::Initialize( | 94 FileCacheMetadata::InitializeResult FileCacheMetadata::Initialize( |
| 95 const base::FilePath& db_path) { | 95 const base::FilePath& db_path) { |
| 96 AssertOnSequencedWorkerPool(); | 96 AssertOnSequencedWorkerPool(); |
| 97 | 97 |
| 98 bool created = !file_util::PathExists(db_path); | 98 bool created = !base::PathExists(db_path); |
| 99 | 99 |
| 100 leveldb::DB* level_db = NULL; | 100 leveldb::DB* level_db = NULL; |
| 101 leveldb::Options options; | 101 leveldb::Options options; |
| 102 options.create_if_missing = true; | 102 options.create_if_missing = true; |
| 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; |
| (...skipping 72 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 |