[Mac] Implement Ambient Light API
[chromium-blink-merge.git] / content / browser / indexed_db / indexed_db_connection.cc
blobf7133a69230da18b88b9deb75e84775823d9467e
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.
5 #include "content/browser/indexed_db/indexed_db_connection.h"
7 namespace content {
9 IndexedDBConnection::IndexedDBConnection(
10 scoped_refptr<IndexedDBDatabase> database,
11 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks)
12 : database_(database), callbacks_(callbacks), weak_factory_(this) {}
14 IndexedDBConnection::~IndexedDBConnection() {}
16 void IndexedDBConnection::Close() {
17 if (!callbacks_.get())
18 return;
19 base::WeakPtr<IndexedDBConnection> this_obj = weak_factory_.GetWeakPtr();
20 database_->Close(this, false /* forced */);
21 if (this_obj) {
22 database_ = nullptr;
23 callbacks_ = nullptr;
27 void IndexedDBConnection::ForceClose() {
28 if (!callbacks_.get())
29 return;
31 // IndexedDBDatabase::Close() can delete this instance.
32 base::WeakPtr<IndexedDBConnection> this_obj = weak_factory_.GetWeakPtr();
33 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks(callbacks_);
34 database_->Close(this, true /* forced */);
35 if (this_obj) {
36 database_ = nullptr;
37 callbacks_ = nullptr;
39 callbacks->OnForcedClose();
42 void IndexedDBConnection::VersionChangeIgnored() {
43 if (!database_.get())
44 return;
45 database_->VersionChangeIgnored();
48 bool IndexedDBConnection::IsConnected() {
49 return database_.get() != NULL;
52 } // namespace content