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

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

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add type check for initial value Created 5 years, 11 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 WTF_LOG_ERROR("Failed to step statement to set value in database (%s)", query.ascii().data()); 132 WTF_LOG_ERROR("Failed to step statement to set value in database (%s)", query.ascii().data());
133 return false; 133 return false;
134 } 134 }
135 135
136 return true; 136 return true;
137 } 137 }
138 138
139 // FIXME: move all guid-related functions to a DatabaseVersionTracker class. 139 // FIXME: move all guid-related functions to a DatabaseVersionTracker class.
140 static RecursiveMutex& guidMutex() 140 static RecursiveMutex& guidMutex()
141 { 141 {
142 AtomicallyInitializedStatic(RecursiveMutex&, mutex = *new RecursiveMutex); 142 AtomicallyInitializedStaticReference(RecursiveMutex, mutex, new RecursiveMut ex);
143 return mutex; 143 return mutex;
144 } 144 }
145 145
146 typedef HashMap<DatabaseGuid, String> GuidVersionMap; 146 typedef HashMap<DatabaseGuid, String> GuidVersionMap;
147 static GuidVersionMap& guidToVersionMap() 147 static GuidVersionMap& guidToVersionMap()
148 { 148 {
149 // Ensure the the mutex is locked. 149 // Ensure the the mutex is locked.
150 ASSERT(guidMutex().locked()); 150 ASSERT(guidMutex().locked());
151 DEFINE_STATIC_LOCAL(GuidVersionMap, map, ()); 151 DEFINE_STATIC_LOCAL(GuidVersionMap, map, ());
152 return map; 152 return map;
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 SecurityOrigin* Database::securityOrigin() const 920 SecurityOrigin* Database::securityOrigin() const
921 { 921 {
922 if (executionContext()->isContextThread()) 922 if (executionContext()->isContextThread())
923 return m_contextThreadSecurityOrigin.get(); 923 return m_contextThreadSecurityOrigin.get();
924 if (databaseContext()->databaseThread()->isDatabaseThread()) 924 if (databaseContext()->databaseThread()->isDatabaseThread())
925 return m_databaseThreadSecurityOrigin.get(); 925 return m_databaseThreadSecurityOrigin.get();
926 return 0; 926 return 0;
927 } 927 }
928 928
929 } // namespace blink 929 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698