| 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_
|
|
|