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

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

Issue 2160163002: [IndexedDB] Propogating Changes to Observer : Browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Browser changes Created 4 years, 5 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 #include "content/browser/indexed_db/indexed_db_observer.h"
13 14
14 namespace content { 15 namespace content {
15 class IndexedDBCallbacks;
16 class IndexedDBDatabaseError; 16 class IndexedDBDatabaseError;
17 17
18 class CONTENT_EXPORT IndexedDBConnection { 18 class CONTENT_EXPORT IndexedDBConnection {
19 public: 19 public:
20 IndexedDBConnection(scoped_refptr<IndexedDBDatabase> db, 20 IndexedDBConnection(scoped_refptr<IndexedDBDatabase> db,
21 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks); 21 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks);
22 virtual ~IndexedDBConnection(); 22 virtual ~IndexedDBConnection();
23 23
24 // These methods are virtual to allow subclassing in unit tests. 24 // These methods are virtual to allow subclassing in unit tests.
25 virtual void ForceClose(); 25 virtual void ForceClose();
26 virtual void Close(); 26 virtual void Close();
27 virtual bool IsConnected(); 27 virtual bool IsConnected();
28 28
29 void VersionChangeIgnored(); 29 void VersionChangeIgnored();
30 30
31 virtual void ActivatePendingObservers(
32 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers);
33 // Removes observer listed in |remove_observer_ids| from active_observer of
34 // connection or pending_observer of transactions associated with this
35 // connection.
36 virtual void RemoveObservers(const std::vector<int32_t>& remove_observer_ids);
37
38 void set_id(int32_t id);
39 int32_t id() const { return id_; }
40
31 IndexedDBDatabase* database() const { return database_.get(); } 41 IndexedDBDatabase* database() const { return database_.get(); }
32 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } 42 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); }
43 const std::vector<std::unique_ptr<IndexedDBObserver>>& active_observers()
44 const {
45 return active_observers_;
46 }
47 base::WeakPtr<IndexedDBConnection> GetWeakPtr() {
48 return weak_factory_.GetWeakPtr();
49 }
33 50
34 private: 51 private:
52 enum { kInvalidId = -1 };
53 // id_ is ipc_database_id
54 int32_t id_ = kInvalidId;
55
35 // NULL in some unit tests, and after the connection is closed. 56 // NULL in some unit tests, and after the connection is closed.
36 scoped_refptr<IndexedDBDatabase> database_; 57 scoped_refptr<IndexedDBDatabase> database_;
37 58
38 // The callbacks_ member is cleared when the connection is closed. 59 // The callbacks_ member is cleared when the connection is closed.
39 // May be NULL in unit tests. 60 // May be NULL in unit tests.
40 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; 61 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_;
41 62 std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_;
42 base::WeakPtrFactory<IndexedDBConnection> weak_factory_; 63 base::WeakPtrFactory<IndexedDBConnection> weak_factory_;
43 64
44 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); 65 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection);
45 }; 66 };
46 67
47 } // namespace content 68 } // namespace content
48 69
49 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ 70 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698