| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/touch_selection/touch_selection_menu_runner.h" | 5 #include "ui/touch_selection/touch_selection_menu_runner.h" |
| 6 | 6 |
| 7 #include "base/logging.h" |
| 8 |
| 7 namespace ui { | 9 namespace ui { |
| 8 namespace { | 10 namespace { |
| 9 | 11 |
| 10 TouchSelectionMenuRunner* g_touch_selection_menu_runner = nullptr; | 12 TouchSelectionMenuRunner* g_touch_selection_menu_runner = nullptr; |
| 11 | 13 |
| 12 } // namespace | 14 } // namespace |
| 13 | 15 |
| 14 TouchSelectionMenuRunner::~TouchSelectionMenuRunner() { | 16 TouchSelectionMenuRunner::~TouchSelectionMenuRunner() { |
| 17 DCHECK_EQ(this, g_touch_selection_menu_runner); |
| 15 g_touch_selection_menu_runner = nullptr; | 18 g_touch_selection_menu_runner = nullptr; |
| 16 } | 19 } |
| 17 | 20 |
| 18 TouchSelectionMenuRunner* TouchSelectionMenuRunner::GetInstance() { | 21 TouchSelectionMenuRunner* TouchSelectionMenuRunner::GetInstance() { |
| 19 return g_touch_selection_menu_runner; | 22 return g_touch_selection_menu_runner; |
| 20 } | 23 } |
| 21 | 24 |
| 22 TouchSelectionMenuRunner::TouchSelectionMenuRunner() { | 25 TouchSelectionMenuRunner::TouchSelectionMenuRunner() { |
| 23 // TODO(mohsen): Ideally we should DCHECK that |g_touch_selection_menu_runner| | 26 DCHECK(!g_touch_selection_menu_runner); |
| 24 // is not set here, in order to make sure we don't create multiple menu | |
| 25 // runners accidentally. Currently, this is not possible because we can have | |
| 26 // multiple ViewsDelegate's at the same time which should not happen. See | |
| 27 // crbug.com/492991. | |
| 28 g_touch_selection_menu_runner = this; | 27 g_touch_selection_menu_runner = this; |
| 29 } | 28 } |
| 30 | 29 |
| 31 } // namespace ui | 30 } // namespace ui |
| OLD | NEW |