| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "sql/recovery.h" | 5 #include "sql/recovery.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 return false; | 101 return false; |
| 102 #else | 102 #else |
| 103 return true; | 103 return true; |
| 104 #endif | 104 #endif |
| 105 } | 105 } |
| 106 | 106 |
| 107 // static | 107 // static |
| 108 scoped_ptr<Recovery> Recovery::Begin( | 108 scoped_ptr<Recovery> Recovery::Begin( |
| 109 Connection* connection, | 109 Connection* connection, |
| 110 const base::FilePath& db_path) { | 110 const base::FilePath& db_path) { |
| 111 // Recovery is likely to be used in error handling. Since recovery changes |
| 112 // the state of the handle, protect against multiple layers attempting the |
| 113 // same recovery. |
| 114 if (!connection->is_open()) { |
| 115 // Warn about API mis-use. |
| 116 DLOG_IF(FATAL, !connection->poisoned_) |
| 117 << "Illegal to recover with closed database"; |
| 118 return scoped_ptr<Recovery>(); |
| 119 } |
| 120 |
| 111 scoped_ptr<Recovery> r(new Recovery(connection)); | 121 scoped_ptr<Recovery> r(new Recovery(connection)); |
| 112 if (!r->Init(db_path)) { | 122 if (!r->Init(db_path)) { |
| 113 // TODO(shess): Should Init() failure result in Raze()? | 123 // TODO(shess): Should Init() failure result in Raze()? |
| 114 r->Shutdown(POISON); | 124 r->Shutdown(POISON); |
| 115 return scoped_ptr<Recovery>(); | 125 return scoped_ptr<Recovery>(); |
| 116 } | 126 } |
| 117 | 127 |
| 118 return r; | 128 return r; |
| 119 } | 129 } |
| 120 | 130 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 } | 537 } |
| 528 return false; | 538 return false; |
| 529 } | 539 } |
| 530 | 540 |
| 531 RecordRecoveryEvent(RECOVERY_SUCCESS_META_VERSION); | 541 RecordRecoveryEvent(RECOVERY_SUCCESS_META_VERSION); |
| 532 *version = recovery_version.ColumnInt(0); | 542 *version = recovery_version.ColumnInt(0); |
| 533 return true; | 543 return true; |
| 534 } | 544 } |
| 535 | 545 |
| 536 } // namespace sql | 546 } // namespace sql |
| OLD | NEW |