Make OffTheRecordObserver a Singleton.

BUG=12560
Review URL: http://codereview.chromium.org/115785

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16887 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/net/dns_global.cc b/chrome/browser/net/dns_global.cc
index 61e7ec1..de6c7f8 100644
--- a/chrome/browser/net/dns_global.cc
+++ b/chrome/browser/net/dns_global.cc
@@ -7,6 +7,7 @@
 #include <map>
 #include <string>
 
+#include "base/singleton.h"
 #include "base/stats_counters.h"
 #include "base/string_util.h"
 #include "base/values.h"
@@ -281,10 +282,6 @@
 
 class OffTheRecordObserver : public NotificationObserver {
  public:
-  OffTheRecordObserver() : lock_(), count_off_the_record_windows_(0) { }
-
-  ~OffTheRecordObserver() { }
-
   void Register() {
     // TODO(pkasting): This test should not be necessary.  See crbug.com/12475.
     if (registrar_.IsEmpty()) {
@@ -328,6 +325,10 @@
   }
 
  private:
+  friend struct DefaultSingletonTraits<OffTheRecordObserver>;
+  OffTheRecordObserver() : lock_(), count_off_the_record_windows_(0) { }
+  ~OffTheRecordObserver() { }
+
   NotificationRegistrar registrar_;
   Lock lock_;
   int count_off_the_record_windows_;
@@ -335,9 +336,6 @@
   DISALLOW_COPY_AND_ASSIGN(OffTheRecordObserver);
 };
 
-// TODO(pkasting): Should this be a Singleton or something?
-static OffTheRecordObserver off_the_record_observer;
-
 //------------------------------------------------------------------------------
 // This section supports the about:dns page.
 //------------------------------------------------------------------------------
@@ -381,7 +379,7 @@
     dns_master = new DnsMaster();
     // We did the initialization, so we should prime the pump, and set up
     // the DNS resolution system to run.
-    off_the_record_observer.Register();
+    Singleton<OffTheRecordObserver>::get()->Register();
 
     if (user_prefs) {
       bool enabled = user_prefs->GetBoolean(prefs::kDnsPrefetchingEnabled);