| 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 "webkit/browser/dom_storage/dom_storage_database.h" | 5 #include "webkit/browser/dom_storage/dom_storage_database.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "sql/statement.h" | 10 #include "sql/statement.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 DCHECK(!IsOpen()); | 259 DCHECK(!IsOpen()); |
| 260 DCHECK(base::PathExists(file_path_)); | 260 DCHECK(base::PathExists(file_path_)); |
| 261 | 261 |
| 262 // We should only try and do this once. | 262 // We should only try and do this once. |
| 263 if (tried_to_recreate_) | 263 if (tried_to_recreate_) |
| 264 return false; | 264 return false; |
| 265 | 265 |
| 266 tried_to_recreate_ = true; | 266 tried_to_recreate_ = true; |
| 267 | 267 |
| 268 // If it's not a directory and we can delete the file, try and open it again. | 268 // If it's not a directory and we can delete the file, try and open it again. |
| 269 if (!file_util::DirectoryExists(file_path_) && | 269 if (!base::DirectoryExists(file_path_) && |
| 270 sql::Connection::Delete(file_path_)) { | 270 sql::Connection::Delete(file_path_)) { |
| 271 return LazyOpen(true); | 271 return LazyOpen(true); |
| 272 } | 272 } |
| 273 | 273 |
| 274 failed_to_open_ = true; | 274 failed_to_open_ = true; |
| 275 return false; | 275 return false; |
| 276 } | 276 } |
| 277 | 277 |
| 278 bool DomStorageDatabase::UpgradeVersion1To2() { | 278 bool DomStorageDatabase::UpgradeVersion1To2() { |
| 279 DCHECK(IsOpen()); | 279 DCHECK(IsOpen()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 299 CreateTableV2() && | 299 CreateTableV2() && |
| 300 CommitChanges(false, values) && | 300 CommitChanges(false, values) && |
| 301 migration.Commit(); | 301 migration.Commit(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void DomStorageDatabase::Close() { | 304 void DomStorageDatabase::Close() { |
| 305 db_.reset(NULL); | 305 db_.reset(NULL); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace dom_storage | 308 } // namespace dom_storage |
| OLD | NEW |