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

Side by Side Diff: Source/web/WebKit.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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 currentThread->addTaskObserver(s_pendingGCRunner); 158 currentThread->addTaskObserver(s_pendingGCRunner);
159 159
160 ASSERT(!s_messageLoopInterruptor); 160 ASSERT(!s_messageLoopInterruptor);
161 s_messageLoopInterruptor = new MessageLoopInterruptor(currentThread); 161 s_messageLoopInterruptor = new MessageLoopInterruptor(currentThread);
162 ThreadState::current()->addInterruptor(s_messageLoopInterruptor); 162 ThreadState::current()->addInterruptor(s_messageLoopInterruptor);
163 } 163 }
164 164
165 DEFINE_STATIC_LOCAL(ModulesInitializer, initializer, ()); 165 DEFINE_STATIC_LOCAL(ModulesInitializer, initializer, ());
166 initializer.init(); 166 initializer.init();
167 167
168 // There are some code paths (for example, running WebKit in the browser
169 // process and calling into LocalStorage before anything else) where the
170 // UTF8 string encoding tables are used on a background thread before
171 // they're set up. This is a problem because their set up routines assert
172 // they're running on the main WebKitThread. It might be possible to make
173 // the initialization thread-safe, but given that so many code paths use
174 // this, initializing this lazily probably doesn't buy us much.
175 WTF::UTF8Encoding();
176
177 setIndexedDBClientCreateFunction(IndexedDBClientImpl::create); 168 setIndexedDBClientCreateFunction(IndexedDBClientImpl::create);
178 169
179 MediaPlayer::setMediaEngineCreateFunction(WebMediaPlayerClientImpl::create); 170 MediaPlayer::setMediaEngineCreateFunction(WebMediaPlayerClientImpl::create);
180 } 171 }
181 172
182 void shutdown() 173 void shutdown()
183 { 174 {
184 // currentThread will always be non-null in production, but can be null in C hromium unit tests. 175 // currentThread will always be non-null in production, but can be null in C hromium unit tests.
185 if (Platform::current()->currentThread()) { 176 if (Platform::current()->currentThread()) {
186 // We don't need to (cannot) remove s_endOfTaskRunner from the current 177 // We don't need to (cannot) remove s_endOfTaskRunner from the current
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 #endif // !LOG_DISABLED 257 #endif // !LOG_DISABLED
267 } 258 }
268 259
269 void resetPluginCache(bool reloadPages) 260 void resetPluginCache(bool reloadPages)
270 { 261 {
271 ASSERT(!reloadPages); 262 ASSERT(!reloadPages);
272 Page::refreshPlugins(); 263 Page::refreshPlugins();
273 } 264 }
274 265
275 } // namespace blink 266 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/WebImageCache.cpp ('k') | Source/wtf/ArrayBuffer.h » ('j') | Source/wtf/Threading.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698