summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WebKit/android/WebCoreSupport/PlatformBridge.cpp4
-rw-r--r--WebKit/android/WebCoreSupport/WebRequestContext.cpp28
-rw-r--r--WebKit/android/WebCoreSupport/WebRequestContext.h3
3 files changed, 20 insertions, 15 deletions
diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
index f17a73a..cd5088b 100644
--- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp
+++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp
@@ -161,11 +161,11 @@ FloatRect PlatformBridge::screenRect()
String PlatformBridge::computeDefaultLanguage()
{
#if USE(CHROME_NETWORK_STACK)
- std::string acceptLanguages = WebRequestContext::get(false)->GetAcceptLanguage();
+ String acceptLanguages = WebRequestContext::acceptLanguage();
size_t length = acceptLanguages.find(',');
if (length == std::string::npos)
length = acceptLanguages.length();
- return String::fromUTF8(acceptLanguages.c_str(), length);
+ return acceptLanguages.substring(0, length);
#else
return "en";
#endif
diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp
index 0e785cb..eed8863 100644
--- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp
+++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp
@@ -38,10 +38,11 @@ namespace {
// TODO: The userAgent should not be a static, as it can be set per WebView.
// http://b/3113804
std::string userAgent("");
-std::string acceptLanguage("");
-
Lock userAgentLock;
-Lock acceptLanguageLock;
+
+std::string acceptLanguageStdString("");
+WTF::String acceptLanguageWtfString("");
+WTF::Mutex acceptLanguageMutex;
}
using namespace WTF;
@@ -78,20 +79,23 @@ const std::string& WebRequestContext::GetUserAgent(const GURL& url) const
return userAgent;
}
-void WebRequestContext::setAcceptLanguage(String string)
+void WebRequestContext::setAcceptLanguage(const String& string)
{
- // The accept language is set on the WebCore thread and read on the network
- // stack's IO thread.
- AutoLock aLock(acceptLanguageLock);
- acceptLanguage = string.utf8().data();
+ MutexLocker lock(acceptLanguageMutex);
+ acceptLanguageStdString = string.utf8().data();
+ acceptLanguageWtfString = string;
}
const std::string& WebRequestContext::GetAcceptLanguage() const
{
- // The accept language is set on the WebCore thread and read on the network
- // stack's IO thread.
- AutoLock aLock(acceptLanguageLock);
- return acceptLanguage;
+ MutexLocker lock(acceptLanguageMutex);
+ return acceptLanguageStdString;
+}
+
+const String& WebRequestContext::acceptLanguage()
+{
+ MutexLocker lock(acceptLanguageMutex);
+ return acceptLanguageWtfString;
}
WebRequestContext* WebRequestContext::getImpl(bool isPrivateBrowsing)
diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.h b/WebKit/android/WebCoreSupport/WebRequestContext.h
index f0f4074..ec1561b 100644
--- a/WebKit/android/WebCoreSupport/WebRequestContext.h
+++ b/WebKit/android/WebCoreSupport/WebRequestContext.h
@@ -47,7 +47,8 @@ public:
// These methods are threadsafe.
static bool cleanupPrivateBrowsingFiles();
static void setUserAgent(WTF::String);
- static void setAcceptLanguage(WTF::String);
+ static void setAcceptLanguage(const WTF::String&);
+ static const WTF::String& acceptLanguage();
// A helper function used by the cache and cookie managers. Should probably
// find a better home, but wait for the refactoring in b/3113804 to be