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
3// found in the LICENSE file.
4
5#include "content/browser/indexed_db/indexed_db_connection.h"
6
7namespace content {
8
9IndexedDBConnection::IndexedDBConnection(
10    scoped_refptr<IndexedDBDatabase> database,
11    scoped_refptr<IndexedDBDatabaseCallbacks> callbacks)
12    : database_(database), callbacks_(callbacks) {}
13
14IndexedDBConnection::~IndexedDBConnection() {}
15
16void IndexedDBConnection::Close() {
17  if (!callbacks_)
18    return;
19  database_->Close(this, false /* forced */);
20  database_ = NULL;
21  callbacks_ = NULL;
22}
23
24void IndexedDBConnection::ForceClose() {
25  if (!callbacks_)
26    return;
27  database_->Close(this, true /* forced */);
28  database_ = NULL;
29  callbacks_->OnForcedClose();
30  callbacks_ = NULL;
31}
32
33bool IndexedDBConnection::IsConnected() {
34  return database_.get() != NULL;
35}
36
37}  // namespace content
38