OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SQL_SCOPED_ATTACH_H_ |
| 6 #define SQL_SCOPED_ATTACH_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "sql/sql_export.h" |
| 12 |
| 13 namespace base { |
| 14 class FilePath; |
| 15 } |
| 16 |
| 17 namespace sql { |
| 18 |
| 19 // Helper to automatically detach attached database when things go out |
| 20 // of scope. |
| 21 |
| 22 class Connection; |
| 23 |
| 24 // TODO(shess): Make the attach/detach code part of sql::Connection, |
| 25 // and the scoper simply calls that. |
| 26 // TODO(shess): Break transactions on detach? |
| 27 class SQL_EXPORT ScopedAttach { |
| 28 public: |
| 29 explicit ScopedAttach(Connection* connection); |
| 30 ~ScopedAttach(); |
| 31 |
| 32 bool Attach(const base::FilePath& other_db_path, |
| 33 const char* attach_as); |
| 34 void Detach(); |
| 35 |
| 36 private: |
| 37 Connection* db_; |
| 38 std::string attached_as_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(ScopedAttach); |
| 41 }; |
| 42 |
| 43 } // namespace sql |
| 44 |
| 45 #endif // SQL_SCOPED_ATTACH_H_ |
OLD | NEW |