summaryrefslogtreecommitdiffstats
path: root/ui/base/win
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 17:26:24 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-20 17:26:24 +0000
commitf2d1ab24b41dd0e3f2c1860005d19cb03637bdf8 (patch)
treed45b8e7c1d4a6b55279030c34c9dd9c4e599a315 /ui/base/win
parentc12df4af9ad6444d1328aab90b7beb21e0f12bb0 (diff)
downloadchromium_src-f2d1ab24b41dd0e3f2c1860005d19cb03637bdf8.zip
chromium_src-f2d1ab24b41dd0e3f2c1860005d19cb03637bdf8.tar.gz
chromium_src-f2d1ab24b41dd0e3f2c1860005d19cb03637bdf8.tar.bz2
Makes WindowImpl thread safe as we apparently use it on multiple
threads. I don't think we use it on multiple threads in Chrome, but content shell/content browser tests do. BUG=none TEST=none R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/17060015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207474 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/win')
-rw-r--r--ui/base/win/singleton_hwnd.cc1
-rw-r--r--ui/base/win/window_impl.cc7
2 files changed, 6 insertions, 2 deletions
diff --git a/ui/base/win/singleton_hwnd.cc b/ui/base/win/singleton_hwnd.cc
index aad849e..2f5d7c0 100644
--- a/ui/base/win/singleton_hwnd.cc
+++ b/ui/base/win/singleton_hwnd.cc
@@ -15,7 +15,6 @@ SingletonHwnd* SingletonHwnd::GetInstance() {
}
void SingletonHwnd::AddObserver(Observer* observer) {
-
if (!hwnd()) {
if (!base::MessageLoop::current() ||
base::MessageLoop::current()->type() != base::MessageLoop::TYPE_UI) {
diff --git a/ui/base/win/window_impl.cc b/ui/base/win/window_impl.cc
index dcff81d..f53b1bf 100644
--- a/ui/base/win/window_impl.cc
+++ b/ui/base/win/window_impl.cc
@@ -9,6 +9,7 @@
#include "base/debug/alias.h"
#include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h"
+#include "base/synchronization/lock.h"
#include "base/win/wrapped_window_proc.h"
#include "ui/base/win/hwnd_util.h"
@@ -42,6 +43,7 @@ struct ClassInfo {
}
};
+// WARNING: this class may be used on multiple threads.
class ClassRegistrar {
public:
~ClassRegistrar();
@@ -73,6 +75,8 @@ class ClassRegistrar {
// Counter of how many classes have been registered so far.
int registered_count_;
+ base::Lock lock_;
+
DISALLOW_COPY_AND_ASSIGN(ClassRegistrar);
};
@@ -85,6 +89,7 @@ ClassRegistrar* ClassRegistrar::GetInstance() {
}
ATOM ClassRegistrar::RetrieveClassAtom(const ClassInfo& class_info) {
+ base::AutoLock auto_lock(lock_);
for (RegisteredClasses::const_iterator i = registered_classes_.begin();
i != registered_classes_.end(); ++i) {
if (class_info.Equals(i->info))
@@ -123,7 +128,7 @@ ClassRegistrar::RegisteredClass::RegisteredClass(const ClassInfo& info,
: info(info),
atom(atom) {}
-ClassRegistrar::ClassRegistrar() : registered_count_(0) { }
+ClassRegistrar::ClassRegistrar() : registered_count_(0) {}
///////////////////////////////////////////////////////////////////////////////