summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormohsen <mohsen@chromium.org>2015-06-10 09:58:40 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-10 16:59:08 +0000
commit20a7d9f7cf570609d5314fbc6ab3b1514b9e3308 (patch)
treef7e9d2bb65c02c3cd98806be0678bf13e72b73b2
parentafad64194903cd855acecbeb28c538d615b2571d (diff)
downloadchromium_src-20a7d9f7cf570609d5314fbc6ab3b1514b9e3308.zip
chromium_src-20a7d9f7cf570609d5314fbc6ab3b1514b9e3308.tar.gz
chromium_src-20a7d9f7cf570609d5314fbc6ab3b1514b9e3308.tar.bz2
Add DCHECKs for the touch selection menu runner singleton
This is to ensure that there exists at most one instance of the menu runner simultaneously. This fix is now possible because of the ViewsDelegate refactoring. BUG=399721,492991 Review URL: https://codereview.chromium.org/1173083002 Cr-Commit-Position: refs/heads/master@{#333747}
-rw-r--r--ui/touch_selection/touch_selection_menu_runner.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/ui/touch_selection/touch_selection_menu_runner.cc b/ui/touch_selection/touch_selection_menu_runner.cc
index 860a24b..bf70874 100644
--- a/ui/touch_selection/touch_selection_menu_runner.cc
+++ b/ui/touch_selection/touch_selection_menu_runner.cc
@@ -4,6 +4,8 @@
#include "ui/touch_selection/touch_selection_menu_runner.h"
+#include "base/logging.h"
+
namespace ui {
namespace {
@@ -12,6 +14,7 @@ TouchSelectionMenuRunner* g_touch_selection_menu_runner = nullptr;
} // namespace
TouchSelectionMenuRunner::~TouchSelectionMenuRunner() {
+ DCHECK_EQ(this, g_touch_selection_menu_runner);
g_touch_selection_menu_runner = nullptr;
}
@@ -20,11 +23,7 @@ TouchSelectionMenuRunner* TouchSelectionMenuRunner::GetInstance() {
}
TouchSelectionMenuRunner::TouchSelectionMenuRunner() {
- // TODO(mohsen): Ideally we should DCHECK that |g_touch_selection_menu_runner|
- // is not set here, in order to make sure we don't create multiple menu
- // runners accidentally. Currently, this is not possible because we can have
- // multiple ViewsDelegate's at the same time which should not happen. See
- // crbug.com/492991.
+ DCHECK(!g_touch_selection_menu_runner);
g_touch_selection_menu_runner = this;
}