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 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/browser/indexed_db/indexed_db_database.h"
11 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
14 class IndexedDBCallbacks
;
15 class IndexedDBDatabaseError
;
17 class CONTENT_EXPORT IndexedDBConnection
{
19 IndexedDBConnection(scoped_refptr
<IndexedDBDatabase
> db
,
20 scoped_refptr
<IndexedDBDatabaseCallbacks
> callbacks
);
21 virtual ~IndexedDBConnection();
23 // These methods are virtual to allow subclassing in unit tests.
24 virtual void ForceClose();
26 virtual bool IsConnected();
28 void VersionChangeIgnored();
30 IndexedDBDatabase
* database() const { return database_
.get(); }
31 IndexedDBDatabaseCallbacks
* callbacks() const { return callbacks_
.get(); }
34 // NULL in some unit tests, and after the connection is closed.
35 scoped_refptr
<IndexedDBDatabase
> database_
;
37 // The callbacks_ member is cleared when the connection is closed.
38 // May be NULL in unit tests.
39 scoped_refptr
<IndexedDBDatabaseCallbacks
> callbacks_
;
41 base::WeakPtrFactory
<IndexedDBConnection
> weak_factory_
;
43 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection
);
46 } // namespace content
48 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_