summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-24 19:41:07 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-24 19:41:07 +0000
commit30d8e44e821f476f5d2db1d338301ad95845ca12 (patch)
tree9208b895977187a03c157cb28828350da8e35670
parenta149bfe85b66cf3194864afb96b14e448ce70391 (diff)
downloadchromium_src-30d8e44e821f476f5d2db1d338301ad95845ca12.zip
chromium_src-30d8e44e821f476f5d2db1d338301ad95845ca12.tar.gz
chromium_src-30d8e44e821f476f5d2db1d338301ad95845ca12.tar.bz2
A couple of changes that make views work from multiple threads
The change to TextInputFocusManager makes me sad, but is the best I can do fow now. Will revisit ASAP. I had to fork off the parts of ViewsInit that need to run only once into a dll. This way I can guarantee the setup only happens once. BUG=388045 TEST=none R=aa@chromium.org, ben@chromium.org, yukishiino@chromium.org Review URL: https://codereview.chromium.org/354513002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279468 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--mojo/mojo.gyp25
-rw-r--r--mojo/views/mojo_views_export.h29
-rw-r--r--mojo/views/views_init.cc13
-rw-r--r--mojo/views/views_init_internal.cc49
-rw-r--r--mojo/views/views_init_internal.h19
-rw-r--r--ui/base/ime/text_input_focus_manager.cc12
6 files changed, 132 insertions, 15 deletions
diff --git a/mojo/mojo.gyp b/mojo/mojo.gyp
index 05c69c2..6e3acbf 100644
--- a/mojo/mojo.gyp
+++ b/mojo/mojo.gyp
@@ -950,6 +950,7 @@
'../ui/views/views.gyp:views',
'../ui/wm/wm.gyp:wm',
'mojo_aura_support',
+ 'mojo_views_support_internal',
],
'sources': [
'views/native_widget_view_manager.cc',
@@ -958,6 +959,30 @@
'views/views_init.h',
],
},
+ {
+ 'target_name': 'mojo_views_support_internal',
+ 'type': '<(component)',
+ 'dependencies': [
+ '../base/base.gyp:base',
+ '../base/base.gyp:base_i18n',
+ '../base/base.gyp:base_static',
+ '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '../skia/skia.gyp:skia',
+ '../skia/skia.gyp:skia',
+ '../third_party/icu/icu.gyp:icui18n',
+ '../third_party/icu/icu.gyp:icuuc',
+ '../ui/base/ui_base.gyp:ui_base',
+ '../ui/gfx/gfx.gyp:gfx',
+ ],
+ 'sources': [
+ 'views/mojo_views_export.h',
+ 'views/views_init_internal.cc',
+ 'views/views_init_internal.h',
+ ],
+ 'defines': [
+ 'MOJO_VIEWS_IMPLEMENTATION',
+ ],
+ },
],
}],
],
diff --git a/mojo/views/mojo_views_export.h b/mojo/views/mojo_views_export.h
new file mode 100644
index 0000000..0ca8985
--- /dev/null
+++ b/mojo/views/mojo_views_export.h
@@ -0,0 +1,29 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_VIEWS_MOJO_VIEWS_EXPORT_H_
+#define MOJO_VIEWS_MOJO_VIEWS_EXPORT_H_
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(MOJO_VIEWS_IMPLEMENTATION)
+#define MOJO_VIEWS_EXPORT __declspec(dllexport)
+#else
+#define MOJO_VIEWS_EXPORT __declspec(dllimport)
+#endif // defined(MOJO_VIEWS_IMPLEMENTATION)
+
+#else // defined(WIN32)
+#if defined(MOJO_VIEWS_IMPLEMENTATION)
+#define MOJO_VIEWS_EXPORT __attribute__((visibility("default")))
+#else
+#define MOJO_VIEWS_EXPORT
+#endif
+#endif
+
+#else // defined(COMPONENT_BUILD)
+#define MOJO_VIEWS_EXPORT
+#endif
+
+#endif // MOJO_VIEWS_MOJO_VIEWS_EXPORT_H_
diff --git a/mojo/views/views_init.cc b/mojo/views/views_init.cc
index 50651ab..edd8af3 100644
--- a/mojo/views/views_init.cc
+++ b/mojo/views/views_init.cc
@@ -4,21 +4,12 @@
#include "mojo/views/views_init.h"
-#include "base/i18n/icu_util.h"
-#include "base/path_service.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/ui_base_paths.h"
+#include "mojo/views/views_init_internal.h"
namespace mojo {
ViewsInit::ViewsInit() {
- base::i18n::InitializeICU();
-
- ui::RegisterPathProvider();
-
- base::FilePath ui_test_pak_path;
- CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
- ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+ InitViews();
}
ViewsInit::~ViewsInit() {
diff --git a/mojo/views/views_init_internal.cc b/mojo/views/views_init_internal.cc
new file mode 100644
index 0000000..6d92c7c
--- /dev/null
+++ b/mojo/views/views_init_internal.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mojo/views/views_init_internal.h"
+
+#include "base/i18n/icu_util.h"
+#include "base/lazy_instance.h"
+#include "base/path_service.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+
+namespace mojo {
+
+namespace {
+
+// Used to ensure we only init once.
+class Setup {
+ public:
+ Setup() {
+ base::i18n::InitializeICU();
+
+ ui::RegisterPathProvider();
+
+ base::FilePath ui_test_pak_path;
+ CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+ ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+
+ // There is a bunch of static state in gfx::Font, by running this now,
+ // before any other apps load, we ensure all the state is set up.
+ gfx::Font();
+ }
+
+ ~Setup() {
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Setup);
+};
+
+static base::LazyInstance<Setup>::Leaky setup = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+void InitViews() {
+ setup.Get();
+}
+
+} // namespace mojo
diff --git a/mojo/views/views_init_internal.h b/mojo/views/views_init_internal.h
new file mode 100644
index 0000000..5ec66e7
--- /dev/null
+++ b/mojo/views/views_init_internal.h
@@ -0,0 +1,19 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_VIEWS_VIEWS_INIT_INTERNAL_H_
+#define MOJO_VIEWS_VIEWS_INIT_INTERNAL_H_
+
+#include "mojo/views/mojo_views_export.h"
+
+namespace mojo {
+
+// This is in a separate target so that we only initialize some common state
+// once.
+// Do not use this, it is called internally by ViewsInit.
+MOJO_VIEWS_EXPORT void InitViews();
+
+} // namespace mojo
+
+#endif // MOJO_VIEWS_VIEWS_INIT_INTERNAL_H_
diff --git a/ui/base/ime/text_input_focus_manager.cc b/ui/base/ime/text_input_focus_manager.cc
index 4fd7dcf..25033d8 100644
--- a/ui/base/ime/text_input_focus_manager.cc
+++ b/ui/base/ime/text_input_focus_manager.cc
@@ -9,26 +9,30 @@
namespace ui {
+// TODO(sky): reenable these DCHECKs. We're in the process of enabling usage
+// of views from multiple threads and this causes problems. See
+// http://crbug.com/388045 for details.
+
TextInputFocusManager* TextInputFocusManager::GetInstance() {
TextInputFocusManager* instance = Singleton<TextInputFocusManager>::get();
- DCHECK(instance->thread_checker_.CalledOnValidThread());
+ // DCHECK(instance->thread_checker_.CalledOnValidThread());
return instance;
}
TextInputClient* TextInputFocusManager::GetFocusedTextInputClient() {
- DCHECK(thread_checker_.CalledOnValidThread());
+ // DCHECK(thread_checker_.CalledOnValidThread());
return focused_text_input_client_;
}
void TextInputFocusManager::FocusTextInputClient(
TextInputClient* text_input_client) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ // DCHECK(thread_checker_.CalledOnValidThread());
focused_text_input_client_ = text_input_client;
}
void TextInputFocusManager::BlurTextInputClient(
TextInputClient* text_input_client) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ // DCHECK(thread_checker_.CalledOnValidThread());
if (focused_text_input_client_ == text_input_client)
focused_text_input_client_ = NULL;
}