summaryrefslogtreecommitdiffstats
path: root/WebKit/win/WebLocalizableStrings.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-11-05 09:23:40 +0000
committerSteve Block <steveblock@google.com>2009-11-10 22:41:12 +0000
commitcac0f67c402d107cdb10971b95719e2ff9c7c76b (patch)
treed182c7f87211c6f201a5f038e332336493ebdbe7 /WebKit/win/WebLocalizableStrings.cpp
parent4b2ef0f288e7c6c4602f621b7a0e9feed304b70e (diff)
downloadexternal_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.zip
external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.gz
external_webkit-cac0f67c402d107cdb10971b95719e2ff9c7c76b.tar.bz2
Merge webkit.org at r50258 : Initial merge by git.
Change-Id: I1a9e1dc4ed654b69174ad52a4f031a07240f37b0
Diffstat (limited to 'WebKit/win/WebLocalizableStrings.cpp')
-rw-r--r--WebKit/win/WebLocalizableStrings.cpp46
1 files changed, 38 insertions, 8 deletions
diff --git a/WebKit/win/WebLocalizableStrings.cpp b/WebKit/win/WebLocalizableStrings.cpp
index e2da4cb..69675e2 100644
--- a/WebKit/win/WebLocalizableStrings.cpp
+++ b/WebKit/win/WebLocalizableStrings.cpp
@@ -37,6 +37,7 @@
#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
+#include <wtf/StdLibExtras.h>
#include <CoreFoundation/CoreFoundation.h>
class LocalizedString;
@@ -45,8 +46,31 @@ using namespace WebCore;
WebLocalizableStringsBundle WebKitLocalizableStringsBundle = { "com.apple.WebKit", 0 };
-static HashMap<String, LocalizedString*> mainBundleLocStrings;
-static HashMap<String, LocalizedString*> frameworkLocStrings;
+typedef HashMap<String, LocalizedString*> LocalizedStringMap;
+
+static Mutex& mainBundleLocStringsMutex()
+{
+ DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+ return mutex;
+}
+
+static LocalizedStringMap& mainBundleLocStrings()
+{
+ DEFINE_STATIC_LOCAL(LocalizedStringMap, map, ());
+ return map;
+}
+
+static Mutex& frameworkLocStringsMutex()
+{
+ DEFINE_STATIC_LOCAL(Mutex, mutex, ());
+ return mutex;
+}
+
+static LocalizedStringMap frameworkLocStrings()
+{
+ DEFINE_STATIC_LOCAL(LocalizedStringMap, map, ());
+ return map;
+}
class LocalizedString : public Noncopyable {
public:
@@ -156,11 +180,15 @@ static CFStringRef copyLocalizedStringFromBundle(WebLocalizableStringsBundle* st
static LocalizedString* findCachedString(WebLocalizableStringsBundle* stringsBundle, const String& key)
{
- if (!stringsBundle)
- return mainBundleLocStrings.get(key);
+ if (!stringsBundle) {
+ MutexLocker lock(mainBundleLocStringsMutex());
+ return mainBundleLocStrings().get(key);
+ }
- if (stringsBundle->bundle == WebKitLocalizableStringsBundle.bundle)
- return frameworkLocStrings.get(key);
+ if (stringsBundle->bundle == WebKitLocalizableStringsBundle.bundle) {
+ MutexLocker lock(frameworkLocStringsMutex());
+ return frameworkLocStrings().get(key);
+ }
return 0;
}
@@ -168,11 +196,13 @@ static LocalizedString* findCachedString(WebLocalizableStringsBundle* stringsBun
static void cacheString(WebLocalizableStringsBundle* stringsBundle, const String& key, LocalizedString* value)
{
if (!stringsBundle) {
- mainBundleLocStrings.set(key, value);
+ MutexLocker lock(mainBundleLocStringsMutex());
+ mainBundleLocStrings().set(key, value);
return;
}
- frameworkLocStrings.set(key, value);
+ MutexLocker lock(frameworkLocStringsMutex());
+ frameworkLocStrings().set(key, value);
}
static const LocalizedString& localizedString(WebLocalizableStringsBundle* stringsBundle, const String& key)