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

Side by Side Diff: ui/ozone/public/ozone_client.cc

Issue 1128113011: ozone: Introduce ClientPixmap and ClientPixmapFactory for non-GPU processes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce OzoneClient Created 5 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "base/lazy_instance.h"
7 #include "base/logging.h"
8 #include "base/trace_event/trace_event.h"
9 #include "ui/ozone/platform_object.h"
10 #include "ui/ozone/platform_selection.h"
11 #include "ui/ozone/public/ozone_client.h"
12 #include "ui/ozone/public/ozone_platform.h"
13 #include "ui/ozone/public/ozone_switches.h"
14
15 namespace ui {
16
17 namespace {
18
19 OzoneClient* g_instance = nullptr;
20
21 } // namespace
22
23 OzoneClient::OzoneClient() {
24 DCHECK(!g_instance) << "There should only be a single OzoneClient.";
25 g_instance = this;
26 }
27
28 OzoneClient::~OzoneClient() {
29 DCHECK_EQ(g_instance, this);
30 g_instance = nullptr;
31 }
32
33 // static
34 void OzoneClient::InitializeForUI() {
35 if (g_instance)
36 return;
37
38 CreateInstance();
39 g_instance->InitializeUI();
40 }
41
42 // static
43 void OzoneClient::InitializeForRenderer() {
44 if (g_instance)
45 return;
46
47 CreateInstance();
48 g_instance->InitializeRenderer();
49 }
50
51 // static
52 OzoneClient* OzoneClient::GetInstance() {
53 DCHECK(g_instance) << "OzoneClient is not initialized";
54 return g_instance;
55 }
56
57 // static
58 void OzoneClient::CreateInstance() {
59 if (!g_instance) {
60 TRACE_EVENT1("ozone", "OzoneClient::CreateInstance", "platform",
61 GetOzonePlatformName());
62 scoped_ptr<OzoneClient> platform = PlatformObject<OzoneClient>::Create();
63
64 // TODO(spang): Currently need to leak this object.
65 OzoneClient* pl = platform.release();
66 DCHECK_EQ(g_instance, pl);
67 }
68 }
69
70 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698