OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_index_writer.h" | 5 #include "content/browser/indexed_db/indexed_db_index_writer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 const IndexedDBObjectStoreMetadata& object_store, | 128 const IndexedDBObjectStoreMetadata& object_store, |
129 const IndexedDBKey& primary_key, // makes a copy | 129 const IndexedDBKey& primary_key, // makes a copy |
130 bool key_was_generated, | 130 bool key_was_generated, |
131 const std::vector<IndexedDBDatabase::IndexKeys>& index_keys, | 131 const std::vector<IndexedDBDatabase::IndexKeys>& index_keys, |
132 ScopedVector<IndexWriter>* index_writers, | 132 ScopedVector<IndexWriter>* index_writers, |
133 base::string16* error_message, | 133 base::string16* error_message, |
134 bool* completed) { | 134 bool* completed) { |
135 *completed = false; | 135 *completed = false; |
136 | 136 |
137 for (const auto& it : index_keys) { | 137 for (const auto& it : index_keys) { |
138 IndexedDBObjectStoreMetadata::IndexMap::const_iterator found = | 138 const auto& found = object_store.indexes.find(it.first); |
139 object_store.indexes.find(it.first); | |
140 if (found == object_store.indexes.end()) | 139 if (found == object_store.indexes.end()) |
141 continue; | 140 continue; |
142 const IndexedDBIndexMetadata& index = found->second; | 141 const IndexedDBIndexMetadata& index = found->second; |
143 IndexedDBDatabase::IndexKeys keys = it; | 142 IndexedDBDatabase::IndexKeys keys = it; |
144 | 143 |
145 // If the object_store is using auto_increment, then any indexes with an | 144 // If the object_store is using auto_increment, then any indexes with an |
146 // identical key_path need to also use the primary (generated) key as a key. | 145 // identical key_path need to also use the primary (generated) key as a key. |
147 if (key_was_generated && (index.key_path == object_store.key_path)) | 146 if (key_was_generated && (index.key_path == object_store.key_path)) |
148 keys.second.push_back(primary_key); | 147 keys.second.push_back(primary_key); |
149 | 148 |
(...skipping 14 matching lines...) Expand all Loading... |
164 return true; | 163 return true; |
165 | 164 |
166 index_writers->push_back(std::move(index_writer)); | 165 index_writers->push_back(std::move(index_writer)); |
167 } | 166 } |
168 | 167 |
169 *completed = true; | 168 *completed = true; |
170 return true; | 169 return true; |
171 } | 170 } |
172 | 171 |
173 } // namespace content | 172 } // namespace content |
OLD | NEW |