summaryrefslogtreecommitdiffstats
path: root/content/browser/indexed_db/indexed_db_connection.cc
blob: 81139895366cdb66e660c7dec37171726fdfca4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 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.

#include "content/browser/indexed_db/indexed_db_connection.h"

namespace content {

IndexedDBConnection::IndexedDBConnection(
    scoped_refptr<IndexedDBDatabase> database,
    scoped_refptr<IndexedDBDatabaseCallbacks> callbacks)
    : database_(database), callbacks_(callbacks) {}

IndexedDBConnection::~IndexedDBConnection() {}

void IndexedDBConnection::Close() {
  if (!callbacks_)
    return;
  database_->Close(this, false /* forced */);
  database_ = NULL;
  callbacks_ = NULL;
}

void IndexedDBConnection::ForceClose() {
  if (!callbacks_)
    return;
  database_->Close(this, true /* forced */);
  database_ = NULL;
  callbacks_->OnForcedClose();
  callbacks_ = NULL;
}

bool IndexedDBConnection::IsConnected() {
  return database_.get() != NULL;
}

}  // namespace blink