diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-24 01:10:49 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-24 01:10:49 +0000 |
commit | 44141f2a8fad6f0603ae9ae0fc8ce8d67e9a84c9 (patch) | |
tree | d754a29f473782c470fd91ea8cbfc1529ced88e5 | |
parent | ac871b31d8e464a17021619ac5a7e9ee36277f70 (diff) | |
download | chromium_src-44141f2a8fad6f0603ae9ae0fc8ce8d67e9a84c9.zip chromium_src-44141f2a8fad6f0603ae9ae0fc8ce8d67e9a84c9.tar.gz chromium_src-44141f2a8fad6f0603ae9ae0fc8ce8d67e9a84c9.tar.bz2 |
Linux: Remove GObjectWeakRef which is no longer needed.
Review URL: http://codereview.chromium.org/9845039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128630 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/gtk/g_object_weak_ref.cc | 84 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/g_object_weak_ref.h | 51 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
3 files changed, 0 insertions, 137 deletions
diff --git a/chrome/browser/ui/gtk/g_object_weak_ref.cc b/chrome/browser/ui/gtk/g_object_weak_ref.cc deleted file mode 100644 index e3c7e90..0000000 --- a/chrome/browser/ui/gtk/g_object_weak_ref.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/gtk/g_object_weak_ref.h" - -#include "base/logging.h" - -class GObjectWeakRef::GObjectWeakRefDelegate - : public base::RefCounted<GObjectWeakRefDelegate> { - public: - explicit GObjectWeakRefDelegate(GObject* object); - - GObject* get() const { return object_; } - - private: - friend class base::RefCounted<GObjectWeakRefDelegate>; - - ~GObjectWeakRefDelegate(); - - static void OnFinalizedThunk(gpointer data, GObject* object); - void OnFinalized(GObject* object); - - GObject* object_; - - DISALLOW_COPY_AND_ASSIGN(GObjectWeakRefDelegate); -}; - -GObjectWeakRef::GObjectWeakRefDelegate::GObjectWeakRefDelegate(GObject* object) - : object_(object) { - if (object) - g_object_weak_ref(object, OnFinalizedThunk, this); -} - -GObjectWeakRef::GObjectWeakRefDelegate::~GObjectWeakRefDelegate() { - if (object_) - g_object_weak_unref(object_, OnFinalizedThunk, this); -} - -// static -void GObjectWeakRef::GObjectWeakRefDelegate::OnFinalizedThunk(gpointer data, - GObject* object) { - static_cast<GObjectWeakRefDelegate*>(data)->OnFinalized(object); -} - -void GObjectWeakRef::GObjectWeakRefDelegate::OnFinalized(GObject* object) { - DCHECK_EQ(object_, object); - object_ = NULL; -} - -GObjectWeakRef::GObjectWeakRef(GObject* object) { - reset(object); -} - -GObjectWeakRef::GObjectWeakRef(GtkWidget* widget) { - reset(G_OBJECT(widget)); -} - -GObjectWeakRef::GObjectWeakRef(const GObjectWeakRef& ref) : ref_(ref.ref_) {} - -GObjectWeakRef::~GObjectWeakRef() {} - -GObjectWeakRef& GObjectWeakRef::operator=(GObject* object) { - reset(object); - return *this; -} - -GObjectWeakRef& GObjectWeakRef::operator=(GtkWidget* widget) { - reset(G_OBJECT(widget)); - return *this; -} - -GObjectWeakRef& GObjectWeakRef::operator=(const GObjectWeakRef& ref) { - ref_ = ref.ref_; - return *this; -} - -GObject* GObjectWeakRef::get() const { - return ref_->get(); -} - -void GObjectWeakRef::reset(GObject* object) { - ref_ = new GObjectWeakRefDelegate(object); -} diff --git a/chrome/browser/ui/gtk/g_object_weak_ref.h b/chrome/browser/ui/gtk/g_object_weak_ref.h deleted file mode 100644 index 0010bca..0000000 --- a/chrome/browser/ui/gtk/g_object_weak_ref.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_GTK_G_OBJECT_WEAK_REF_H_ -#define CHROME_BROWSER_UI_GTK_G_OBJECT_WEAK_REF_H_ -#pragma once - -#include <gtk/gtk.h> - -#include "base/memory/ref_counted.h" - -// GObjectWeakRef is like base::WeakRef, but for GLib objects. It can be useful -// when passing GObject/GtkWidget arguments to closures (e.g. base::Bind()) that -// may not necessarily outlast the closure. It is not thread-safe. Use like so: -// -// void DelayedAction(const GObjectWeakRef& object) { -// if (!object.get()) return; -// GtkWidget* widget = GTK_WIDGET(object.get()); -// // code using |widget| -// } -// -// GtkWidget* widget = ...; -// MessageLoop::current()->PostTask( -// FROM_HERE, base::Bind(&DelayedAction, GObjectWeakRef(widget))); - -class GObjectWeakRef { - public: - // GObjectWeakRef is just a thin wrapper around GObjectWeakRefDelegate that - // can be copied and assigned, even though the delegate is reference counted. - explicit GObjectWeakRef(GObject* object); - explicit GObjectWeakRef(GtkWidget* widget); - GObjectWeakRef(const GObjectWeakRef& ref); // NOLINT: explicitly non-explicit - ~GObjectWeakRef(); - - // Assignment operators for GObject, GtkWidget, and GObjectWeakRef. - GObjectWeakRef& operator=(GObject* object); - GObjectWeakRef& operator=(GtkWidget* widget); - GObjectWeakRef& operator=(const GObjectWeakRef& ref); - - GObject* get() const; - - private: - class GObjectWeakRefDelegate; - - void reset(GObject* object); - - scoped_refptr<GObjectWeakRefDelegate> ref_; -}; - -#endif // CHROME_BROWSER_UI_GTK_G_OBJECT_WEAK_REF_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 401834e..9066c89 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2928,8 +2928,6 @@ 'browser/ui/gtk/gtk_tree.h', 'browser/ui/gtk/gtk_util.cc', 'browser/ui/gtk/gtk_util.h', - 'browser/ui/gtk/g_object_weak_ref.cc', - 'browser/ui/gtk/g_object_weak_ref.h', 'browser/ui/gtk/hover_controller_gtk.cc', 'browser/ui/gtk/hover_controller_gtk.h', 'browser/ui/gtk/html_dialog_gtk.cc', |