Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ui/events/ozone/layout/keyboard_layout_engine_manager.cc

Issue 2546973003: Replace unique_ptr.reset/release with std::move under src/ui (Closed)
Patch Set: Whitespace formatting Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/events/ozone/layout/keyboard_layout_engine_manager.h" 5 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" 8 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
9 9
10 namespace ui { 10 namespace ui {
11 11
12 // static 12 // static
13 KeyboardLayoutEngineManager* KeyboardLayoutEngineManager::instance_ = nullptr; 13 KeyboardLayoutEngineManager* KeyboardLayoutEngineManager::instance_ = nullptr;
14 14
15 KeyboardLayoutEngineManager::KeyboardLayoutEngineManager( 15 KeyboardLayoutEngineManager::KeyboardLayoutEngineManager(
16 KeyboardLayoutEngine* engine) 16 KeyboardLayoutEngine* engine)
17 : keyboard_layout_engine_(engine) { 17 : keyboard_layout_engine_(engine) {
18 CHECK(!instance_) << "Only one keyboard layout manager can be created."; 18 CHECK(!instance_) << "Only one keyboard layout manager can be created.";
19 instance_ = this; 19 instance_ = this;
20 } 20 }
21 21
22 KeyboardLayoutEngineManager::~KeyboardLayoutEngineManager() { 22 KeyboardLayoutEngineManager::~KeyboardLayoutEngineManager() {
23 CHECK_EQ(this, instance_); 23 CHECK_EQ(this, instance_);
24 instance_ = NULL; 24 instance_ = NULL;
25 } 25 }
26 26
27 void KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( 27 void KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
28 std::unique_ptr<KeyboardLayoutEngine> engine) { 28 std::unique_ptr<KeyboardLayoutEngine> engine) {
29 if (instance_) 29 if (instance_)
30 instance_->keyboard_layout_engine_.reset(engine.release()); 30 instance_->keyboard_layout_engine_ = std::move(engine);
31 else 31 else
32 new KeyboardLayoutEngineManager(engine.release()); 32 new KeyboardLayoutEngineManager(engine.release());
33 } 33 }
34 34
35 KeyboardLayoutEngine* KeyboardLayoutEngineManager::GetKeyboardLayoutEngine() { 35 KeyboardLayoutEngine* KeyboardLayoutEngineManager::GetKeyboardLayoutEngine() {
36 // TODO(kpschoedel): crbug.com/430194 This lazy initialization is a 36 // TODO(kpschoedel): crbug.com/430194 This lazy initialization is a
37 // workaround for not yet initializing KeyboardLayoutEngineManager 37 // workaround for not yet initializing KeyboardLayoutEngineManager
38 // expliclity in all tests that need it. 38 // expliclity in all tests that need it.
39 if (!instance_) 39 if (!instance_)
40 new KeyboardLayoutEngineManager(new StubKeyboardLayoutEngine()); 40 new KeyboardLayoutEngineManager(new StubKeyboardLayoutEngine());
41 return instance_->keyboard_layout_engine_.get(); 41 return instance_->keyboard_layout_engine_.get();
42 } 42 }
43 43
44 } // namespace ui 44 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698