Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: content/browser/indexed_db/indexed_db_connection.h

Issue 2062203004: IDBObserver: Lifetime Management: Adding Observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Observer moved to connection Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "content/browser/indexed_db/indexed_db_database.h" 11 #include "content/browser/indexed_db/indexed_db_database.h"
12 #include "content/browser/indexed_db/indexed_db_database_callbacks.h" 12 #include "content/browser/indexed_db/indexed_db_database_callbacks.h"
13 13
14 namespace content { 14 namespace content {
15 class IndexedDBCallbacks; 15 class IndexedDBCallbacks;
16 class IndexedDBDatabaseError; 16 class IndexedDBDatabaseError;
17 class IndexedDBObserver;
17 18
18 class CONTENT_EXPORT IndexedDBConnection { 19 class CONTENT_EXPORT IndexedDBConnection {
19 public: 20 public:
20 IndexedDBConnection(scoped_refptr<IndexedDBDatabase> db, 21 IndexedDBConnection(scoped_refptr<IndexedDBDatabase> db,
21 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks); 22 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks);
22 virtual ~IndexedDBConnection(); 23 virtual ~IndexedDBConnection();
23 24
24 // These methods are virtual to allow subclassing in unit tests. 25 // These methods are virtual to allow subclassing in unit tests.
25 virtual void ForceClose(); 26 virtual void ForceClose();
26 virtual void Close(); 27 virtual void Close();
27 virtual bool IsConnected(); 28 virtual bool IsConnected();
28 29
29 void VersionChangeIgnored(); 30 void VersionChangeIgnored();
31 void Unobserve(std::vector<int32_t> observersToRemove);
dmurph 2016/06/22 01:09:49 const ref, and please use underscore_naming
palakj1 2016/06/23 20:56:29 changed to const ref.
30 32
31 IndexedDBDatabase* database() const { return database_.get(); } 33 IndexedDBDatabase* database() const { return database_.get(); }
32 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } 34 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); }
33 35
36 std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_;
37
34 private: 38 private:
35 // NULL in some unit tests, and after the connection is closed. 39 // NULL in some unit tests, and after the connection is closed.
36 scoped_refptr<IndexedDBDatabase> database_; 40 scoped_refptr<IndexedDBDatabase> database_;
37 41
38 // The callbacks_ member is cleared when the connection is closed. 42 // The callbacks_ member is cleared when the connection is closed.
39 // May be NULL in unit tests. 43 // May be NULL in unit tests.
40 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; 44 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_;
41
42 base::WeakPtrFactory<IndexedDBConnection> weak_factory_; 45 base::WeakPtrFactory<IndexedDBConnection> weak_factory_;
43 46
44 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); 47 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection);
45 }; 48 };
46 49
47 } // namespace content 50 } // namespace content
48 51
49 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ 52 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698