summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/google_update.cc10
-rw-r--r--chrome/browser/google_update.h3
-rw-r--r--chrome/browser/views/about_chrome_view.cc10
-rw-r--r--chrome/browser/views/about_chrome_view.h2
4 files changed, 7 insertions, 18 deletions
diff --git a/chrome/browser/google_update.cc b/chrome/browser/google_update.cc
index c52c7ac..da56359 100644
--- a/chrome/browser/google_update.cc
+++ b/chrome/browser/google_update.cc
@@ -146,14 +146,6 @@ class GoogleUpdateJobObserver
CComPtr<IProgressWndEvents> event_sink_;
};
-// TODO(finnur): (http://b/1292883) The object is currently managing its own
-// lifetime, but should be converted to use RefCountedThreadSafe instead.
-template <>
-struct RunnableMethodTraits<GoogleUpdate> {
- static void RetainCallee(GoogleUpdate* obj) { }
- static void ReleaseCallee(GoogleUpdate* obj) { }
-};
-
////////////////////////////////////////////////////////////////////////////////
// GoogleUpdate, public:
@@ -254,8 +246,6 @@ void GoogleUpdate::ReportResults(GoogleUpdateUpgradeResult results,
error_code == GOOGLE_UPDATE_NO_ERROR);
if (listener_)
listener_->OnReportResults(results, error_code, version_available_);
-
- delete this;
}
bool GoogleUpdate::ReportFailure(HRESULT hr, GoogleUpdateErrorCode error_code,
diff --git a/chrome/browser/google_update.h b/chrome/browser/google_update.h
index c380345..78153fa 100644
--- a/chrome/browser/google_update.h
+++ b/chrome/browser/google_update.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/ref_counted.h"
#include "google_update_idl.h"
class MessageLoop;
@@ -75,7 +76,7 @@ class GoogleUpdateStatusListener {
// interface and will delete itself after reporting back.
//
////////////////////////////////////////////////////////////////////////////////
-class GoogleUpdate {
+class GoogleUpdate : public base::RefCountedThreadSafe<GoogleUpdate> {
public:
GoogleUpdate();
virtual ~GoogleUpdate();
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index 6ee840c..da99ff9 100644
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -42,12 +42,11 @@ AboutChromeView::AboutChromeView(Profile* profile)
about_title_label_(NULL),
version_label_(NULL),
main_text_label_(NULL),
- check_button_status_(CHECKBUTTON_HIDDEN),
- google_updater_(NULL) {
+ check_button_status_(CHECKBUTTON_HIDDEN) {
DCHECK(profile);
Init();
- google_updater_ = new GoogleUpdate(); // This object deletes itself.
+ google_updater_ = new GoogleUpdate();
google_updater_->AddStatusChangeListener(this);
}
@@ -342,7 +341,7 @@ bool AboutChromeView::Accept() {
// that an update is available, at which point this pointer should have been
// null-ed out.
DCHECK(!google_updater_);
- google_updater_ = new GoogleUpdate(); // This object deletes itself.
+ google_updater_ = new GoogleUpdate();
google_updater_->AddStatusChangeListener(this);
google_updater_->CheckForUpdate(true); // true=upgrade if new version found.
@@ -359,8 +358,7 @@ ChromeViews::View* AboutChromeView::GetContentsView() {
void AboutChromeView::OnReportResults(GoogleUpdateUpgradeResult result,
GoogleUpdateErrorCode error_code,
const std::wstring& version) {
- // The object will free itself after reporting its status, so we should
- // no longer refer to it.
+ // Drop the last reference to the object so that it gets cleaned up here.
google_updater_ = NULL;
// Make a note of which version Google Update is reporting is the latest
diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h
index 2b9536f..7ef9608 100644
--- a/chrome/browser/views/about_chrome_view.h
+++ b/chrome/browser/views/about_chrome_view.h
@@ -93,7 +93,7 @@ class AboutChromeView : public ChromeViews::View,
// The class that communicates with Google Update to find out if an update is
// available and asks it to start an upgrade.
- GoogleUpdate* google_updater_;
+ scoped_refptr<GoogleUpdate> google_updater_;
// Our current version.
std::wstring current_version_;