Seventh patch in making destructors of refcounted objects private.
BUG=26749
Review URL: http://codereview.chromium.org/371006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31192 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h
index 0918cde..916e765 100644
--- a/chrome/browser/net/chrome_url_request_context.h
+++ b/chrome/browser/net/chrome_url_request_context.h
@@ -43,9 +43,6 @@
ChromeURLRequestContextGetter(Profile* profile,
ChromeURLRequestContextFactory* factory);
- // Must be called on the IO thread.
- virtual ~ChromeURLRequestContextGetter();
-
// Note that GetURLRequestContext() can only be called from the IO
// thread (it will assert otherwise). GetCookieStore() however can
// be called from any thread.
@@ -100,6 +97,9 @@
const NotificationDetails& details);
private:
+ // Must be called on the IO thread.
+ virtual ~ChromeURLRequestContextGetter();
+
// Registers an observer on |profile|'s preferences which will be used
// to update the context when the default language and charset change.
void RegisterPrefsObserver(Profile* profile);
diff --git a/chrome/browser/net/dns_master.h b/chrome/browser/net/dns_master.h
index 451e9ed9..8309789 100644
--- a/chrome/browser/net/dns_master.h
+++ b/chrome/browser/net/dns_master.h
@@ -44,7 +44,6 @@
// |host_resolver| instance.
DnsMaster(net::HostResolver* host_resolver,
TimeDelta max_queue_delay_ms, size_t max_concurrent);
- ~DnsMaster();
// Cancel pending requests and prevent new ones from being made.
void Shutdown();
@@ -101,6 +100,7 @@
size_t max_concurrent_lookups() const { return max_concurrent_lookups_; }
private:
+ friend class base::RefCountedThreadSafe<DnsMaster>;
FRIEND_TEST(DnsMasterTest, BenefitLookupTest);
FRIEND_TEST(DnsMasterTest, ShutdownWhenResolutionIsPendingTest);
FRIEND_TEST(DnsMasterTest, SingleLookupTest);
@@ -110,6 +110,8 @@
FRIEND_TEST(DnsMasterTest, PriorityQueueReorderTest);
friend class WaitForResolutionHelper; // For testing.
+ ~DnsMaster();
+
class LookupRequest;
// A simple priority queue for handling host names.
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store.cc b/chrome/browser/net/sqlite_persistent_cookie_store.cc
index c79fa42..0216b40 100644
--- a/chrome/browser/net/sqlite_persistent_cookie_store.cc
+++ b/chrome/browser/net/sqlite_persistent_cookie_store.cc
@@ -32,12 +32,6 @@
DCHECK(db_) << "Database must exist.";
}
- // You should call Close() before destructing this object.
- ~Backend() {
- DCHECK(!db_) << "Close should have already been called.";
- DCHECK(num_pending_ == 0 && pending_.empty());
- }
-
// Batch a cookie addition.
void AddCookie(const std::string& key,
const net::CookieMonster::CanonicalCookie& cc);
@@ -53,6 +47,14 @@
void Close();
private:
+ friend class base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend>;
+
+ // You should call Close() before destructing this object.
+ ~Backend() {
+ DCHECK(!db_) << "Close should have already been called.";
+ DCHECK(num_pending_ == 0 && pending_.empty());
+ }
+
class PendingOperation {
public:
typedef enum {
diff --git a/chrome/browser/net/url_fetcher.cc b/chrome/browser/net/url_fetcher.cc
index 7d0aad7..600fb738 100644
--- a/chrome/browser/net/url_fetcher.cc
+++ b/chrome/browser/net/url_fetcher.cc
@@ -53,6 +53,10 @@
URLFetcher::Delegate* delegate() const { return delegate_; }
private:
+ friend class base::RefCountedThreadSafe<URLFetcher::Core>;
+
+ ~Core() {}
+
// Wrapper functions that allow us to ensure actions happen on the right
// thread.
void StartURLRequest();
diff --git a/chrome/browser/net/url_fetcher_unittest.cc b/chrome/browser/net/url_fetcher_unittest.cc
index 8ec69dce..d186b40 100644
--- a/chrome/browser/net/url_fetcher_unittest.cc
+++ b/chrome/browser/net/url_fetcher_unittest.cc
@@ -30,6 +30,8 @@
return context_;
}
private:
+ ~TestURLRequestContextGetter() {}
+
scoped_refptr<URLRequestContext> context_;
};
@@ -176,6 +178,8 @@
}
private:
+ ~CancelTestURLRequestContextGetter() {}
+
scoped_refptr<URLRequestContext> context_;
bool* destructor_called_;
};
diff --git a/chrome/browser/net/url_request_context_getter.h b/chrome/browser/net/url_request_context_getter.h
index b5c8070d..78edbd12 100644
--- a/chrome/browser/net/url_request_context_getter.h
+++ b/chrome/browser/net/url_request_context_getter.h
@@ -17,13 +17,16 @@
class URLRequestContextGetter
: public base::RefCountedThreadSafe<URLRequestContextGetter> {
public:
- virtual ~URLRequestContextGetter() {}
-
virtual URLRequestContext* GetURLRequestContext() = 0;
// Defaults to GetURLRequestContext()->cookie_store(), but
// implementations can override it.
virtual net::CookieStore* GetCookieStore();
+
+ protected:
+ friend class base::RefCountedThreadSafe<URLRequestContextGetter>;
+
+ virtual ~URLRequestContextGetter() {}
};
#endif // CHROME_BROWSER_NET_URL_REQUEST_CONTEXT_GETTER_H_