// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_BASE_GLIB_SCOPED_GOBJECT_H_ #define UI_BASE_GLIB_SCOPED_GOBJECT_H_ #include <glib-object.h> #include <cstddef> #include "base/check.h" #include "base/memory/raw_ptr.h" // Similar to a scoped_refptr for GObject types. template <typename T> class ScopedGObject { … }; // Create a ScopedGObject and do not increase the GObject's reference count. // This is usually used to reference a newly-created GObject, which are created // with a reference count of 1 by default. template <typename T> ScopedGObject<T> TakeGObject(T* obj) { … } // Create a ScopedGObject and increase the GObject's reference count by 1. // This is usually used to reference an existing GObject. template <typename T> ScopedGObject<T> WrapGObject(T* obj) { … } #endif // UI_BASE_GLIB_SCOPED_GOBJECT_H_