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

Side by Side Diff: Source/modules/webdatabase/DatabaseBackendBase.cpp

Issue 415083002: [oilpan]: fix deadlock when leaving a safepoint and sweeping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/platform/heap/HeapTest.cpp » ('j') | Source/platform/heap/ThreadState.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 result = statement.step(); 128 result = statement.step();
129 if (result != SQLResultDone) { 129 if (result != SQLResultDone) {
130 WTF_LOG_ERROR("Failed to step statement to set value in database (%s)", query.ascii().data()); 130 WTF_LOG_ERROR("Failed to step statement to set value in database (%s)", query.ascii().data());
131 return false; 131 return false;
132 } 132 }
133 133
134 return true; 134 return true;
135 } 135 }
136 136
137 // FIXME: move all guid-related functions to a DatabaseVersionTracker class. 137 // FIXME: move all guid-related functions to a DatabaseVersionTracker class.
138 static Mutex& guidMutex() 138 static RecursiveMutex& guidMutex()
139 { 139 {
140 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); 140 AtomicallyInitializedStatic(RecursiveMutex&, mutex = *new RecursiveMutex);
141 return mutex; 141 return mutex;
142 } 142 }
143 143
144 typedef HashMap<DatabaseGuid, String> GuidVersionMap; 144 typedef HashMap<DatabaseGuid, String> GuidVersionMap;
145 static GuidVersionMap& guidToVersionMap() 145 static GuidVersionMap& guidToVersionMap()
146 { 146 {
147 // Ensure the the mutex is locked. 147 // Ensure the the mutex is locked.
148 ASSERT(!guidMutex().tryLock()); 148 ASSERT(guidMutex().locked());
149 DEFINE_STATIC_LOCAL(GuidVersionMap, map, ()); 149 DEFINE_STATIC_LOCAL(GuidVersionMap, map, ());
150 return map; 150 return map;
151 } 151 }
152 152
153 // NOTE: Caller must lock guidMutex(). 153 // NOTE: Caller must lock guidMutex().
154 static inline void updateGuidVersionMap(DatabaseGuid guid, String newVersion) 154 static inline void updateGuidVersionMap(DatabaseGuid guid, String newVersion)
155 { 155 {
156 // Ensure the the mutex is locked. 156 // Ensure the the mutex is locked.
157 ASSERT(!guidMutex().tryLock()); 157 ASSERT(guidMutex().locked());
158 158
159 // Note: It is not safe to put an empty string into the guidToVersionMap() m ap. 159 // Note: It is not safe to put an empty string into the guidToVersionMap() m ap.
160 // That's because the map is cross-thread, but empty strings are per-thread. 160 // That's because the map is cross-thread, but empty strings are per-thread.
161 // The copy() function makes a version of the string you can use on the curr ent 161 // The copy() function makes a version of the string you can use on the curr ent
162 // thread, but we need a string we can keep in a cross-thread data structure . 162 // thread, but we need a string we can keep in a cross-thread data structure .
163 // FIXME: This is a quite-awkward restriction to have to program with. 163 // FIXME: This is a quite-awkward restriction to have to program with.
164 164
165 // Map null string to empty string (see comment above). 165 // Map null string to empty string (see comment above).
166 guidToVersionMap().set(guid, newVersion.isEmpty() ? String() : newVersion.is olatedCopy()); 166 guidToVersionMap().set(guid, newVersion.isEmpty() ? String() : newVersion.is olatedCopy());
167 } 167 }
168 168
169 typedef HashMap<DatabaseGuid, HashSet<DatabaseBackendBase*>*> GuidDatabaseMap; 169 typedef HashMap<DatabaseGuid, HashSet<DatabaseBackendBase*>*> GuidDatabaseMap;
170 static GuidDatabaseMap& guidToDatabaseMap() 170 static GuidDatabaseMap& guidToDatabaseMap()
171 { 171 {
172 // Ensure the the mutex is locked. 172 // Ensure the the mutex is locked.
173 ASSERT(!guidMutex().tryLock()); 173 ASSERT(guidMutex().locked());
174 DEFINE_STATIC_LOCAL(GuidDatabaseMap, map, ()); 174 DEFINE_STATIC_LOCAL(GuidDatabaseMap, map, ());
175 return map; 175 return map;
176 } 176 }
177 177
178 static DatabaseGuid guidForOriginAndName(const String& origin, const String& nam e) 178 static DatabaseGuid guidForOriginAndName(const String& origin, const String& nam e)
179 { 179 {
180 // Ensure the the mutex is locked. 180 // Ensure the the mutex is locked.
181 ASSERT(!guidMutex().tryLock()); 181 ASSERT(guidMutex().locked());
182 182
183 String stringID = origin + "/" + name; 183 String stringID = origin + "/" + name;
184 184
185 typedef HashMap<String, int> IDGuidMap; 185 typedef HashMap<String, int> IDGuidMap;
186 DEFINE_STATIC_LOCAL(IDGuidMap, stringIdentifierToGUIDMap, ()); 186 DEFINE_STATIC_LOCAL(IDGuidMap, stringIdentifierToGUIDMap, ());
187 DatabaseGuid guid = stringIdentifierToGUIDMap.get(stringID); 187 DatabaseGuid guid = stringIdentifierToGUIDMap.get(stringID);
188 if (!guid) { 188 if (!guid) {
189 static int currentNewGUID = 1; 189 static int currentNewGUID = 1;
190 guid = currentNewGUID++; 190 guid = currentNewGUID++;
191 stringIdentifierToGUIDMap.set(stringID, guid); 191 stringIdentifierToGUIDMap.set(stringID, guid);
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 { 666 {
667 executionContext()->addConsoleMessage(StorageMessageSource, ErrorMessageLeve l, message); 667 executionContext()->addConsoleMessage(StorageMessageSource, ErrorMessageLeve l, message);
668 } 668 }
669 669
670 ExecutionContext* DatabaseBackendBase::executionContext() const 670 ExecutionContext* DatabaseBackendBase::executionContext() const
671 { 671 {
672 return databaseContext()->executionContext(); 672 return databaseContext()->executionContext();
673 } 673 }
674 674
675 } // namespace blink 675 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/HeapTest.cpp » ('j') | Source/platform/heap/ThreadState.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698