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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/Database.cpp

Issue 2940933003: DO NOT SUBMIT results of new clang-format (Closed)
Patch Set: Created 3 years, 6 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 /* 1 /*
2 * Copyright (C) 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2013 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 173
174 typedef HashMap<DatabaseGuid, String> GuidVersionMap; 174 typedef HashMap<DatabaseGuid, String> GuidVersionMap;
175 static GuidVersionMap& GuidToVersionMap() { 175 static GuidVersionMap& GuidToVersionMap() {
176 DEFINE_STATIC_LOCAL_WITH_LOCK(GuidVersionMap, map, ()); 176 DEFINE_STATIC_LOCAL_WITH_LOCK(GuidVersionMap, map, ());
177 return map; 177 return map;
178 } 178 }
179 179
180 // NOTE: Caller must lock guidMutex(). 180 // NOTE: Caller must lock guidMutex().
181 static inline void UpdateGuidVersionMap(DatabaseGuid guid, String new_version) { 181 static inline void UpdateGuidVersionMap(DatabaseGuid guid, String new_version) {
182 // Ensure the the mutex is locked. 182 // Ensure the the mutex is locked.
183 #if DCHECK_IS_ON() 183 #if DCHECK_IS_ON()
184 DCHECK(GuidMutex().Locked()); 184 DCHECK(GuidMutex().Locked());
185 #endif 185 #endif
186 186
187 // Note: It is not safe to put an empty string into the guidToVersionMap() 187 // Note: It is not safe to put an empty string into the guidToVersionMap()
188 // map. That's because the map is cross-thread, but empty strings are 188 // map. That's because the map is cross-thread, but empty strings are
189 // per-thread. The copy() function makes a version of the string you can 189 // per-thread. The copy() function makes a version of the string you can
190 // use on the current thread, but we need a string we can keep in a 190 // use on the current thread, but we need a string we can keep in a
191 // cross-thread data structure. 191 // cross-thread data structure.
192 // FIXME: This is a quite-awkward restriction to have to program with. 192 // FIXME: This is a quite-awkward restriction to have to program with.
193 193
194 // Map null string to empty string (see comment above). 194 // Map null string to empty string (see comment above).
195 GuidToVersionMap().Set( 195 GuidToVersionMap().Set(
196 guid, new_version.IsEmpty() ? String() : new_version.IsolatedCopy()); 196 guid, new_version.IsEmpty() ? String() : new_version.IsolatedCopy());
197 } 197 }
198 198
199 static HashCountedSet<DatabaseGuid>& GuidCount() { 199 static HashCountedSet<DatabaseGuid>& GuidCount() {
200 DEFINE_STATIC_LOCAL_WITH_LOCK(HashCountedSet<DatabaseGuid>, guid_count, ()); 200 DEFINE_STATIC_LOCAL_WITH_LOCK(HashCountedSet<DatabaseGuid>, guid_count, ());
201 return guid_count; 201 return guid_count;
202 } 202 }
203 203
204 static DatabaseGuid GuidForOriginAndName(const String& origin, 204 static DatabaseGuid GuidForOriginAndName(const String& origin,
205 const String& name) { 205 const String& name) {
206 // Ensure the the mutex is locked. 206 // Ensure the the mutex is locked.
207 #if DCHECK_IS_ON() 207 #if DCHECK_IS_ON()
208 DCHECK(GuidMutex().Locked()); 208 DCHECK(GuidMutex().Locked());
209 #endif 209 #endif
210 210
211 String string_id = origin + "/" + name; 211 String string_id = origin + "/" + name;
212 212
213 typedef HashMap<String, int> IDGuidMap; 213 typedef HashMap<String, int> IDGuidMap;
214 DEFINE_STATIC_LOCAL_WITH_LOCK(IDGuidMap, string_identifier_to_guid_map, ()); 214 DEFINE_STATIC_LOCAL_WITH_LOCK(IDGuidMap, string_identifier_to_guid_map, ());
215 DatabaseGuid guid = string_identifier_to_guid_map.at(string_id); 215 DatabaseGuid guid = string_identifier_to_guid_map.at(string_id);
216 if (!guid) { 216 if (!guid) {
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 992
993 bool Database::Opened() { 993 bool Database::Opened() {
994 return static_cast<bool>(AcquireLoad(&opened_)); 994 return static_cast<bool>(AcquireLoad(&opened_));
995 } 995 }
996 996
997 WebTaskRunner* Database::GetDatabaseTaskRunner() const { 997 WebTaskRunner* Database::GetDatabaseTaskRunner() const {
998 return database_task_runner_.Get(); 998 return database_task_runner_.Get();
999 } 999 }
1000 1000
1001 } // namespace blink 1001 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698