OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 name_map->Set(name, database_set); | 111 name_map->Set(name, database_set); |
112 } | 112 } |
113 | 113 |
114 database_set->insert(database); | 114 database_set->insert(database); |
115 } | 115 } |
116 | 116 |
117 void DatabaseTracker::RemoveOpenDatabase(Database* database) { | 117 void DatabaseTracker::RemoveOpenDatabase(Database* database) { |
118 { | 118 { |
119 MutexLocker open_database_map_lock(open_database_map_guard_); | 119 MutexLocker open_database_map_lock(open_database_map_guard_); |
120 String origin_string = database->GetSecurityOrigin()->ToRawString(); | 120 String origin_string = database->GetSecurityOrigin()->ToRawString(); |
121 ASSERT(open_database_map_); | 121 DCHECK(open_database_map_); |
122 DatabaseNameMap* name_map = open_database_map_->at(origin_string); | 122 DatabaseNameMap* name_map = open_database_map_->at(origin_string); |
123 if (!name_map) | 123 if (!name_map) |
124 return; | 124 return; |
125 | 125 |
126 String name(database->StringIdentifier()); | 126 String name(database->StringIdentifier()); |
127 DatabaseSet* database_set = name_map->at(name); | 127 DatabaseSet* database_set = name_map->at(name); |
128 if (!database_set) | 128 if (!database_set) |
129 return; | 129 return; |
130 | 130 |
131 DatabaseSet::iterator found = database_set->Find(database); | 131 DatabaseSet::iterator found = database_set->Find(database); |
132 if (found == database_set->end()) | 132 if (found == database_set->end()) |
133 return; | 133 return; |
134 | 134 |
135 database_set->erase(found); | 135 database_set->erase(found); |
136 if (database_set->IsEmpty()) { | 136 if (database_set->IsEmpty()) { |
137 name_map->erase(name); | 137 name_map->erase(name); |
138 delete database_set; | 138 delete database_set; |
139 if (name_map->IsEmpty()) { | 139 if (name_map->IsEmpty()) { |
140 open_database_map_->erase(origin_string); | 140 open_database_map_->erase(origin_string); |
141 delete name_map; | 141 delete name_map; |
142 } | 142 } |
143 } | 143 } |
144 } | 144 } |
145 DatabaseClosed(database); | 145 DatabaseClosed(database); |
146 } | 146 } |
147 | 147 |
148 void DatabaseTracker::PrepareToOpenDatabase(Database* database) { | 148 void DatabaseTracker::PrepareToOpenDatabase(Database* database) { |
149 ASSERT( | 149 DCHECK( |
150 database->GetDatabaseContext()->GetExecutionContext()->IsContextThread()); | 150 database->GetDatabaseContext()->GetExecutionContext()->IsContextThread()); |
151 if (Platform::Current()->DatabaseObserver()) { | 151 if (Platform::Current()->DatabaseObserver()) { |
152 Platform::Current()->DatabaseObserver()->DatabaseOpened( | 152 Platform::Current()->DatabaseObserver()->DatabaseOpened( |
153 WebSecurityOrigin(database->GetSecurityOrigin()), | 153 WebSecurityOrigin(database->GetSecurityOrigin()), |
154 database->StringIdentifier(), database->DisplayName(), | 154 database->StringIdentifier(), database->DisplayName(), |
155 database->EstimatedSize()); | 155 database->EstimatedSize()); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 void DatabaseTracker::FailedToOpenDatabase(Database* database) { | 159 void DatabaseTracker::FailedToOpenDatabase(Database* database) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 void DatabaseTracker::ForEachOpenDatabaseInPage( | 198 void DatabaseTracker::ForEachOpenDatabaseInPage( |
199 Page* page, | 199 Page* page, |
200 std::unique_ptr<DatabaseCallback> callback) { | 200 std::unique_ptr<DatabaseCallback> callback) { |
201 MutexLocker open_database_map_lock(open_database_map_guard_); | 201 MutexLocker open_database_map_lock(open_database_map_guard_); |
202 if (!open_database_map_) | 202 if (!open_database_map_) |
203 return; | 203 return; |
204 for (auto& origin_map : *open_database_map_) { | 204 for (auto& origin_map : *open_database_map_) { |
205 for (auto& name_database_set : *origin_map.value) { | 205 for (auto& name_database_set : *origin_map.value) { |
206 for (Database* database : *name_database_set.value) { | 206 for (Database* database : *name_database_set.value) { |
207 ExecutionContext* context = database->GetExecutionContext(); | 207 ExecutionContext* context = database->GetExecutionContext(); |
208 ASSERT(context->IsDocument()); | 208 DCHECK(context->IsDocument()); |
209 if (ToDocument(context)->GetFrame()->GetPage() == page) | 209 if (ToDocument(context)->GetFrame()->GetPage() == page) |
210 (*callback)(database); | 210 (*callback)(database); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 void DatabaseTracker::CloseOneDatabaseImmediately(const String& origin_string, | 216 void DatabaseTracker::CloseOneDatabaseImmediately(const String& origin_string, |
217 const String& name, | 217 const String& name, |
218 Database* database) { | 218 Database* database) { |
(...skipping 15 matching lines...) Expand all Loading... |
234 if (found == database_set->end()) | 234 if (found == database_set->end()) |
235 return; | 235 return; |
236 } | 236 } |
237 | 237 |
238 // And we have to call closeImmediately() without our collection lock being | 238 // And we have to call closeImmediately() without our collection lock being |
239 // held. | 239 // held. |
240 database->CloseImmediately(); | 240 database->CloseImmediately(); |
241 } | 241 } |
242 | 242 |
243 } // namespace blink | 243 } // namespace blink |
OLD | NEW |