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 #include "content/browser/indexed_db/indexed_db_connection.h" | 5 #include "content/browser/indexed_db/indexed_db_connection.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 IndexedDBConnection::IndexedDBConnection( | 12 IndexedDBConnection::IndexedDBConnection( |
13 scoped_refptr<IndexedDBDatabase> database, | 13 scoped_refptr<IndexedDBDatabase> database, |
14 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks) | 14 scoped_refptr<IndexedDBDatabaseCallbacks> callbacks) |
15 : database_(database), callbacks_(callbacks), weak_factory_(this) {} | 15 : id_(kInvalidId), |
jsbell
2016/07/11 18:25:33
This can have the default initialization in the he
palakj1
2016/07/11 22:25:40
Done.
| |
16 database_(database), | |
17 callbacks_(callbacks), | |
18 weak_factory_(this) {} | |
16 | 19 |
17 IndexedDBConnection::~IndexedDBConnection() {} | 20 IndexedDBConnection::~IndexedDBConnection() {} |
18 | 21 |
22 void IndexedDBConnection::setId(int32_t id) { | |
23 DCHECK_EQ(id_, kInvalidId); | |
24 id_ = id; | |
25 } | |
26 | |
19 void IndexedDBConnection::Close() { | 27 void IndexedDBConnection::Close() { |
20 if (!callbacks_.get()) | 28 if (!callbacks_.get()) |
21 return; | 29 return; |
22 base::WeakPtr<IndexedDBConnection> this_obj = weak_factory_.GetWeakPtr(); | 30 base::WeakPtr<IndexedDBConnection> this_obj = weak_factory_.GetWeakPtr(); |
23 database_->Close(this, false /* forced */); | 31 database_->Close(this, false /* forced */); |
24 if (this_obj) { | 32 if (this_obj) { |
25 database_ = nullptr; | 33 database_ = nullptr; |
26 callbacks_ = nullptr; | 34 callbacks_ = nullptr; |
27 active_observers_.clear(); | 35 active_observers_.clear(); |
28 } | 36 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 if (it != active_observers_.end()) | 83 if (it != active_observers_.end()) |
76 active_observers_.erase(it); | 84 active_observers_.erase(it); |
77 else | 85 else |
78 pending_observer_ids.push_back(id_to_remove); | 86 pending_observer_ids.push_back(id_to_remove); |
79 } | 87 } |
80 if (!pending_observer_ids.empty()) | 88 if (!pending_observer_ids.empty()) |
81 database_->RemovePendingObservers(this, pending_observer_ids); | 89 database_->RemovePendingObservers(this, pending_observer_ids); |
82 } | 90 } |
83 | 91 |
84 } // namespace content | 92 } // namespace content |
OLD | NEW |