Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: sql/scoped_attach.h

Issue 18180013: Scoped recovery module for sql/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops, add recover_unittest.cc Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« sql/recovery.h ('K') | « sql/recovery.cc ('k') | sql/scoped_attach.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/scoped_attach.h
diff --git a/sql/scoped_attach.h b/sql/scoped_attach.h
new file mode 100644
index 0000000000000000000000000000000000000000..48b9f3f65768e903ef1fa01dd3e90eb375940a8e
--- /dev/null
+++ b/sql/scoped_attach.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SQL_SCOPED_ATTACH_H_
+#define SQL_SCOPED_ATTACH_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "sql/sql_export.h"
+
+namespace base {
+class FilePath;
+}
+
+namespace sql {
+
+// Helper to automatically detach attached database when things go out
+// of scope.
+
+class Connection;
+
+// TODO(shess): Make the attach/detach code part of sql::Connection,
+// and the scoper simply calls that.
+// TODO(shess): Break transactions on detach?
+class SQL_EXPORT ScopedAttach {
+ public:
+ explicit ScopedAttach(Connection* connection);
+ ~ScopedAttach();
+
+ bool Attach(const base::FilePath& other_db_path,
+ const char* attach_as);
+ void Detach();
+
+ private:
+ Connection* db_;
+ std::string attached_as_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedAttach);
+};
+
+} // namespace sql
+
+#endif // SQL_SCOPED_ATTACH_H_
« sql/recovery.h ('K') | « sql/recovery.cc ('k') | sql/scoped_attach.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698