OLD | NEW |
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 <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 void VersionChangeIgnored(); | 32 void VersionChangeIgnored(); |
33 | 33 |
34 virtual void ActivatePendingObservers( | 34 virtual void ActivatePendingObservers( |
35 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers); | 35 std::vector<std::unique_ptr<IndexedDBObserver>> pending_observers); |
36 // Removes observer listed in |remove_observer_ids| from active_observer of | 36 // Removes observer listed in |remove_observer_ids| from active_observer of |
37 // connection or pending_observer of transactions associated with this | 37 // connection or pending_observer of transactions associated with this |
38 // connection. | 38 // connection. |
39 virtual void RemoveObservers(const std::vector<int32_t>& remove_observer_ids); | 39 virtual void RemoveObservers(const std::vector<int32_t>& remove_observer_ids); |
40 | 40 |
41 void set_id(int32_t id); | |
42 int32_t id() const { return id_; } | 41 int32_t id() const { return id_; } |
43 | 42 |
44 IndexedDBDatabase* database() const { return database_.get(); } | 43 IndexedDBDatabase* database() const { return database_.get(); } |
45 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } | 44 IndexedDBDatabaseCallbacks* callbacks() const { return callbacks_.get(); } |
46 const std::vector<std::unique_ptr<IndexedDBObserver>>& active_observers() | 45 const std::vector<std::unique_ptr<IndexedDBObserver>>& active_observers() |
47 const { | 46 const { |
48 return active_observers_; | 47 return active_observers_; |
49 } | 48 } |
50 base::WeakPtr<IndexedDBConnection> GetWeakPtr() { | 49 base::WeakPtr<IndexedDBConnection> GetWeakPtr() { |
51 return weak_factory_.GetWeakPtr(); | 50 return weak_factory_.GetWeakPtr(); |
52 } | 51 } |
53 | 52 |
54 private: | 53 private: |
55 enum { kInvalidId = -1 }; | 54 const int32_t id_; |
56 // id_ is ipc_database_id | |
57 int32_t id_ = kInvalidId; | |
58 | 55 |
59 // NULL in some unit tests, and after the connection is closed. | 56 // NULL in some unit tests, and after the connection is closed. |
60 scoped_refptr<IndexedDBDatabase> database_; | 57 scoped_refptr<IndexedDBDatabase> database_; |
61 | 58 |
62 // The callbacks_ member is cleared when the connection is closed. | 59 // The callbacks_ member is cleared when the connection is closed. |
63 // May be NULL in unit tests. | 60 // May be NULL in unit tests. |
64 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; | 61 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks_; |
65 std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_; | 62 std::vector<std::unique_ptr<IndexedDBObserver>> active_observers_; |
66 base::WeakPtrFactory<IndexedDBConnection> weak_factory_; | 63 base::WeakPtrFactory<IndexedDBConnection> weak_factory_; |
67 | 64 |
68 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); | 65 DISALLOW_COPY_AND_ASSIGN(IndexedDBConnection); |
69 }; | 66 }; |
70 | 67 |
71 } // namespace content | 68 } // namespace content |
72 | 69 |
73 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ | 70 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CONNECTION_H_ |
OLD | NEW |