Revert "Omit calls to set composing region when pasting image."
[chromium-blink-merge.git] / sql / transaction.cc
blobaf4b9f890cc9c201a3c25db2c95cc288ddebedd4
1 // Copyright (c) 2011 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.
5 #include "sql/transaction.h"
7 #include "base/logging.h"
8 #include "sql/connection.h"
10 namespace sql {
12 Transaction::Transaction(Connection* connection)
13 : connection_(connection),
14 is_open_(false) {
17 Transaction::~Transaction() {
18 if (is_open_)
19 connection_->RollbackTransaction();
22 bool Transaction::Begin() {
23 DCHECK(!is_open_) << "Beginning a transaction twice!";
24 is_open_ = connection_->BeginTransaction();
25 return is_open_;
28 void Transaction::Rollback() {
29 DCHECK(is_open_) << "Attempting to roll back a nonexistent transaction. "
30 << "Did you remember to call Begin() and check its return?";
31 is_open_ = false;
32 connection_->RollbackTransaction();
35 bool Transaction::Commit() {
36 DCHECK(is_open_) << "Attempting to commit a nonexistent transaction. "
37 << "Did you remember to call Begin() and check its return?";
38 is_open_ = false;
39 return connection_->CommitTransaction();
42 } // namespace sql