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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_factory_ozone.cc

Issue 2024953007: Make DesktopFactoryOzone instances to respect --ozone-platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make DesktopFactoryOzone instances to respect --ozone-platform Created 4 years, 6 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/widget/desktop_aura/desktop_factory_ozone.h" 5 #include "ui/views/widget/desktop_aura/desktop_factory_ozone.h"
6 6
7 #include <memory>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/ozone/platform_object.h"
8 11
9 namespace views { 12 namespace views {
10 13
11 // static 14 // static
12 DesktopFactoryOzone* DesktopFactoryOzone::impl_ = NULL; 15 DesktopFactoryOzone* DesktopFactoryOzone::impl_ = nullptr;
13 16
14 DesktopFactoryOzone::DesktopFactoryOzone() { 17 DesktopFactoryOzone::DesktopFactoryOzone() {
18 DCHECK(!impl_) << "There should only be a single DesktopFactoryOzone.";
19 impl_ = this;
15 } 20 }
16 21
17 DesktopFactoryOzone::~DesktopFactoryOzone() { 22 DesktopFactoryOzone::~DesktopFactoryOzone() {
23 DCHECK_EQ(impl_, this);
24 impl_ = nullptr;
18 } 25 }
19 26
20 DesktopFactoryOzone* DesktopFactoryOzone::GetInstance() { 27 DesktopFactoryOzone* DesktopFactoryOzone::GetInstance() {
21 CHECK(impl_) << "DesktopFactoryOzone accessed before constructed"; 28 if (!impl_) {
29 std::unique_ptr<DesktopFactoryOzone> factory =
30 ui::PlatformObject<DesktopFactoryOzone>::Create();
31
32 // TODO(tonikitoo): Currently need to leak this object.
Michael Forney 2016/06/06 20:08:21 I wasn't sure about this, but it looks like this i
33 DesktopFactoryOzone* leaky = factory.release();
34 DCHECK_EQ(impl_, leaky);
35 }
22 return impl_; 36 return impl_;
23 } 37 }
24 38
25 void DesktopFactoryOzone::SetInstance(DesktopFactoryOzone* impl) {
26 impl_ = impl;
27 }
28
29 } // namespace views 39 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698