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

Unified Diff: services/ui/common/gpu_service.cc

Issue 2194003002: services/ui: Have an explicit lifetime/ownership of ui::GpuService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot merge Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/common/gpu_service.h ('k') | services/ui/demo/mus_demo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/common/gpu_service.cc
diff --git a/services/ui/common/gpu_service.cc b/services/ui/common/gpu_service.cc
index f8bf9e79e0939d11ced35b5e1313616fe85c0011..9a2f4c561a3e4b28576250d2b1782b026dcdc69e 100644
--- a/services/ui/common/gpu_service.cc
+++ b/services/ui/common/gpu_service.cc
@@ -47,21 +47,18 @@ GpuService::GpuService(shell::Connector* connector)
GpuService::~GpuService() {
DCHECK(IsMainThread());
+ DCHECK_EQ(this, g_gpu_service);
if (gpu_channel_)
gpu_channel_->DestroyChannel();
+ g_gpu_service = nullptr;
}
// static
-void GpuService::Initialize(shell::Connector* connector) {
+std::unique_ptr<GpuService> GpuService::Initialize(
+ shell::Connector* connector) {
DCHECK(!g_gpu_service);
g_gpu_service = new GpuService(connector);
-}
-
-// static
-void GpuService::Terminate() {
- DCHECK(g_gpu_service);
- delete g_gpu_service;
- g_gpu_service = nullptr;
+ return base::WrapUnique(g_gpu_service);
}
// static
« no previous file with comments | « services/ui/common/gpu_service.h ('k') | services/ui/demo/mus_demo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698