diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
commit | 1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch) | |
tree | 4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/dom/EventNames.cpp | |
parent | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff) | |
download | external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/dom/EventNames.cpp')
-rw-r--r-- | WebCore/dom/EventNames.cpp | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/WebCore/dom/EventNames.cpp b/WebCore/dom/EventNames.cpp index c5aaa37..22a716d 100644 --- a/WebCore/dom/EventNames.cpp +++ b/WebCore/dom/EventNames.cpp @@ -21,31 +21,54 @@ */ #include "config.h" +#include "EventNames.h" + +#include <wtf/Threading.h> -#ifdef AVOID_STATIC_CONSTRUCTORS -#define DOM_EVENT_NAMES_HIDE_GLOBALS 1 +#if ENABLE(WORKERS) +#include <wtf/ThreadSpecific.h> +using namespace WTF; #endif -#include "EventNames.h" -#include "StaticConstructors.h" +namespace WebCore { -namespace WebCore { namespace EventNames { +#if ENABLE(WORKERS) +static ThreadSpecific<EventNames>* staticEventNames; +#else +static EventNames* staticEventNames; +#endif + +#define INITIALIZE_EVENT_NAME(name) \ + , name##Event(#name) +EventNames::EventNames() + : dummy(0) +DOM_EVENT_NAMES_FOR_EACH(INITIALIZE_EVENT_NAME) +{ +} -#define DEFINE_EVENT_GLOBAL(name) \ - DEFINE_GLOBAL(AtomicString, name##Event, #name) -DOM_EVENT_NAMES_FOR_EACH(DEFINE_EVENT_GLOBAL) +EventNames& eventNames() +{ +#if ENABLE(WORKERS) + return **staticEventNames; +#else + return *staticEventNames; +#endif +} -void init() +void EventNames::init() { - static bool initialized; - if (!initialized) { - // Use placement new to initialize the globals. - + if (!staticEventNames) { + // Initialization is not thread safe, so this function must be called from the main thread first. + ASSERT(isMainThread()); + AtomicString::init(); - #define INITIALIZE_GLOBAL(name) new ((void*)&name##Event) AtomicString(#name); - DOM_EVENT_NAMES_FOR_EACH(INITIALIZE_GLOBAL) - initialized = true; + +#if ENABLE(WORKERS) + staticEventNames = new ThreadSpecific<EventNames>; +#else + staticEventNames = new EventNames; +#endif } } -} } +} |