diff options
77 files changed, 333 insertions, 133 deletions
diff --git a/net/base/address_list.h b/net/base/address_list.h index 165086c..3087472 100644 --- a/net/base/address_list.h +++ b/net/base/address_list.h @@ -54,11 +54,15 @@ class AddressList { struct Data : public base::RefCountedThreadSafe<Data> { Data(struct addrinfo* ai, bool is_system_created) : head(ai), is_system_created(is_system_created) {} - ~Data(); struct addrinfo* head; // Indicates which free function to use for |head|. bool is_system_created; + + private: + friend class base::RefCountedThreadSafe<Data>; + + ~Data(); }; explicit AddressList(Data* data) : data_(data) {} diff --git a/net/base/cert_verifier.cc b/net/base/cert_verifier.cc index 70be229..703ecfe 100644 --- a/net/base/cert_verifier.cc +++ b/net/base/cert_verifier.cc @@ -35,8 +35,6 @@ class CertVerifier::Request : error_(OK) { } - ~Request() {} - void DoVerify() { // Running on the worker thread error_ = cert_->Verify(hostname_, flags_, &result_); @@ -92,6 +90,10 @@ class CertVerifier::Request : } private: + friend class base::RefCountedThreadSafe<CertVerifier::Request>; + + ~Request() {} + // Set on the origin thread, read on the worker thread. scoped_refptr<X509Certificate> cert_; std::string hostname_; diff --git a/net/base/cookie_monster.h b/net/base/cookie_monster.h index 7b8362d..18ebe25 100644 --- a/net/base/cookie_monster.h +++ b/net/base/cookie_monster.h @@ -69,8 +69,6 @@ class CookieMonster : public CookieStore { } #endif - ~CookieMonster(); - // Parse the string with the cookie time (very forgivingly). static base::Time ParseCookieTime(const std::string& time_string); @@ -136,6 +134,8 @@ class CookieMonster : public CookieStore { static bool enable_file_scheme_; private: + ~CookieMonster(); + // Called by all non-static functions to ensure that the cookies store has // been initialized. This is not done during creating so it doesn't block // the window showing. diff --git a/net/base/cookie_monster_perftest.cc b/net/base/cookie_monster_perftest.cc index ebdc2da..9e76ac8 100644 --- a/net/base/cookie_monster_perftest.cc +++ b/net/base/cookie_monster_perftest.cc @@ -40,7 +40,7 @@ TEST(ParsedCookieTest, TestParseBigCookies) { static const GURL kUrlGoogle("http://www.google.izzle"); TEST(CookieMonsterTest, TestAddCookiesOnSingleHost) { - net::CookieMonster cm; + scoped_refptr<net::CookieMonster> cm(new net::CookieMonster); std::vector<std::string> cookies; for (int i = 0; i < kNumCookies; i++) { cookies.push_back(StringPrintf("a%03d=b", i)); @@ -50,24 +50,24 @@ TEST(CookieMonsterTest, TestAddCookiesOnSingleHost) { PerfTimeLogger timer("Cookie_monster_add_single_host"); for (std::vector<std::string>::const_iterator it = cookies.begin(); it != cookies.end(); ++it) { - EXPECT_TRUE(cm.SetCookie(kUrlGoogle, *it)); + EXPECT_TRUE(cm->SetCookie(kUrlGoogle, *it)); } timer.Done(); PerfTimeLogger timer2("Cookie_monster_query_single_host"); for (std::vector<std::string>::const_iterator it = cookies.begin(); it != cookies.end(); ++it) { - cm.GetCookies(kUrlGoogle); + cm->GetCookies(kUrlGoogle); } timer2.Done(); PerfTimeLogger timer3("Cookie_monster_deleteall_single_host"); - cm.DeleteAll(false); + cm->DeleteAll(false); timer3.Done(); } TEST(CookieMonsterTest, TestAddCookieOnManyHosts) { - net::CookieMonster cm; + scoped_refptr<net::CookieMonster> cm(new net::CookieMonster); std::string cookie(kCookieLine); std::vector<GURL> gurls; // just wanna have ffffuunnn for (int i = 0; i < kNumCookies; ++i) { @@ -78,18 +78,18 @@ TEST(CookieMonsterTest, TestAddCookieOnManyHosts) { PerfTimeLogger timer("Cookie_monster_add_many_hosts"); for (std::vector<GURL>::const_iterator it = gurls.begin(); it != gurls.end(); ++it) { - EXPECT_TRUE(cm.SetCookie(*it, cookie)); + EXPECT_TRUE(cm->SetCookie(*it, cookie)); } timer.Done(); PerfTimeLogger timer2("Cookie_monster_query_many_hosts"); for (std::vector<GURL>::const_iterator it = gurls.begin(); it != gurls.end(); ++it) { - cm.GetCookies(*it); + cm->GetCookies(*it); } timer2.Done(); PerfTimeLogger timer3("Cookie_monster_deleteall_many_hosts"); - cm.DeleteAll(false); + cm->DeleteAll(false); timer3.Done(); } diff --git a/net/base/cookie_store.h b/net/base/cookie_store.h index b1dd5ab..e4d9b5d 100644 --- a/net/base/cookie_store.h +++ b/net/base/cookie_store.h @@ -24,8 +24,6 @@ class CookieMonster; // be thread safe as its methods can be accessed from IO as well as UI threads. class CookieStore : public base::RefCountedThreadSafe<CookieStore> { public: - virtual ~CookieStore() {} - // Set a single cookie. Expects a cookie line, like "a=1; domain=b.com". virtual bool SetCookie(const GURL& url, const std::string& cookie_line) = 0; virtual bool SetCookieWithOptions(const GURL& url, @@ -60,6 +58,10 @@ class CookieStore : public base::RefCountedThreadSafe<CookieStore> { virtual CookieMonster* GetCookieMonster() { return NULL; }; + + protected: + friend class base::RefCountedThreadSafe<CookieStore>; + virtual ~CookieStore() {} }; } // namespace net diff --git a/net/base/directory_lister.h b/net/base/directory_lister.h index 27204b6..83dc1ef 100644 --- a/net/base/directory_lister.h +++ b/net/base/directory_lister.h @@ -35,7 +35,6 @@ class DirectoryLister : public base::RefCountedThreadSafe<DirectoryLister>, }; DirectoryLister(const FilePath& dir, DirectoryListerDelegate* delegate); - ~DirectoryLister(); // Call this method to start the directory enumeration thread. bool Start(); @@ -53,8 +52,11 @@ class DirectoryLister : public base::RefCountedThreadSafe<DirectoryLister>, void ThreadMain(); private: + friend class base::RefCountedThreadSafe<DirectoryLister>; friend class DirectoryDataEvent; + ~DirectoryLister(); + void OnReceivedData(const file_util::FileEnumerator::FindInfo* data, int count); void OnDone(int error); diff --git a/net/base/fixed_host_resolver.h b/net/base/fixed_host_resolver.h index cf1bd74..3ae3209 100644 --- a/net/base/fixed_host_resolver.h +++ b/net/base/fixed_host_resolver.h @@ -32,6 +32,8 @@ class FixedHostResolver : public HostResolver { virtual void Shutdown() {} private: + ~FixedHostResolver() {} + AddressList address_; bool initialized_; }; diff --git a/net/base/host_cache.h b/net/base/host_cache.h index b36af35..c7127b0 100644 --- a/net/base/host_cache.h +++ b/net/base/host_cache.h @@ -22,7 +22,6 @@ class HostCache { // Stores the latest address list that was looked up for a hostname. struct Entry : public base::RefCounted<Entry> { Entry(int error, const AddressList& addrlist, base::TimeTicks expiration); - ~Entry(); // The resolve results for this entry. int error; @@ -30,6 +29,11 @@ class HostCache { // The time when this entry expires. base::TimeTicks expiration; + + private: + friend class base::RefCounted<Entry>; + + ~Entry(); }; struct Key { diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index 9534e03..baaf2ac 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -104,11 +104,6 @@ class HostResolver : public base::RefCountedThreadSafe<HostResolver> { // Opaque type used to cancel a request. typedef void* RequestHandle; - // If any completion callbacks are pending when the resolver is destroyed, - // the host resolutions are cancelled, and the completion callbacks will not - // be called. - virtual ~HostResolver() {} - // Resolves the given hostname (or IP address literal), filling out the // |addresses| object upon success. The |info.port| parameter will be set as // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if @@ -157,8 +152,15 @@ class HostResolver : public base::RefCountedThreadSafe<HostResolver> { virtual void SetDefaultAddressFamily(AddressFamily address_family) {} protected: + friend class base::RefCountedThreadSafe<HostResolver>; + HostResolver() { } + // If any completion callbacks are pending when the resolver is destroyed, + // the host resolutions are cancelled, and the completion callbacks will not + // be called. + virtual ~HostResolver() {} + private: DISALLOW_COPY_AND_ASSIGN(HostResolver); }; diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index 557d42a..15ab7e8 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -149,11 +149,6 @@ class HostResolverImpl::Job error_(OK) { } - ~Job() { - // Free the requests attached to this job. - STLDeleteElements(&requests_); - } - // Attaches a request to this job. The job takes ownership of |req| and will // take care to delete it. void AddRequest(Request* req) { @@ -215,6 +210,13 @@ class HostResolverImpl::Job } private: + friend class base::RefCountedThreadSafe<HostResolverImpl::Job>; + + ~Job() { + // Free the requests attached to this job. + STLDeleteElements(&requests_); + } + void DoLookup() { // Running on the worker thread error_ = ResolveAddrInfo(resolver_proc_, diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h index 5399e69..9dad6f8 100644 --- a/net/base/host_resolver_impl.h +++ b/net/base/host_resolver_impl.h @@ -51,11 +51,6 @@ class HostResolverImpl : public HostResolver { int max_cache_entries, int cache_duration_ms); - // If any completion callbacks are pending when the resolver is destroyed, - // the host resolutions are cancelled, and the completion callbacks will not - // be called. - virtual ~HostResolverImpl(); - // HostResolver methods: virtual int Resolve(const RequestInfo& info, AddressList* addresses, @@ -82,6 +77,11 @@ class HostResolverImpl : public HostResolver { typedef std::map<Key, scoped_refptr<Job> > JobMap; typedef std::vector<Observer*> ObserversList; + // If any completion callbacks are pending when the resolver is destroyed, + // the host resolutions are cancelled, and the completion callbacks will not + // be called. + virtual ~HostResolverImpl(); + // Returns the HostResolverProc to use for this instance. HostResolverProc* effective_resolver_proc() const { return resolver_proc_ ? diff --git a/net/base/host_resolver_impl_unittest.cc b/net/base/host_resolver_impl_unittest.cc index eee6fd1..63e06a7 100644 --- a/net/base/host_resolver_impl_unittest.cc +++ b/net/base/host_resolver_impl_unittest.cc @@ -67,6 +67,8 @@ class CapturingHostResolverProc : public HostResolverProc { } private: + ~CapturingHostResolverProc() {} + std::vector<std::string> capture_list_; mutable Lock lock_; base::WaitableEvent event_; diff --git a/net/base/host_resolver_proc.h b/net/base/host_resolver_proc.h index 8507e03..f2bff25 100644 --- a/net/base/host_resolver_proc.h +++ b/net/base/host_resolver_proc.h @@ -24,7 +24,6 @@ class AddressList; class HostResolverProc : public base::RefCountedThreadSafe<HostResolverProc> { public: explicit HostResolverProc(HostResolverProc* previous); - virtual ~HostResolverProc() {} // Resolves |host| to an address list, restricting the results to addresses // in |address_family|. If successful returns OK and fills |addrlist| with @@ -34,6 +33,10 @@ class HostResolverProc : public base::RefCountedThreadSafe<HostResolverProc> { AddressList* addrlist) = 0; protected: + friend class base::RefCountedThreadSafe<HostResolverProc>; + + virtual ~HostResolverProc() {} + // Asks the fallback procedure (if set) to do the resolve. int ResolveUsingPrevious(const std::string& host, AddressFamily address_family, diff --git a/net/base/io_buffer.h b/net/base/io_buffer.h index e301df8..adcf698 100644 --- a/net/base/io_buffer.h +++ b/net/base/io_buffer.h @@ -18,16 +18,20 @@ class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> { public: IOBuffer() : data_(NULL) {} explicit IOBuffer(int buffer_size); - virtual ~IOBuffer() { - delete[] data_; - } char* data() { return data_; } protected: + friend class base::RefCountedThreadSafe<IOBuffer>; + // Only allow derived classes to specify data_. // In all other cases, we own data_, and must delete it at destruction time. explicit IOBuffer(char* data) : data_(data) {} + + virtual ~IOBuffer() { + delete[] data_; + } + char* data_; }; @@ -38,11 +42,12 @@ class IOBuffer : public base::RefCountedThreadSafe<IOBuffer> { class IOBufferWithSize : public IOBuffer { public: explicit IOBufferWithSize(int size) : IOBuffer(size), size_(size) {} - ~IOBufferWithSize() {} int size() const { return size_; } private: + ~IOBufferWithSize() {} + int size_; }; @@ -55,15 +60,16 @@ class StringIOBuffer : public IOBuffer { string_data_(s) { data_ = const_cast<char*>(string_data_.data()); } + + int size() const { return string_data_.size(); } + + private: ~StringIOBuffer() { // We haven't allocated the buffer, so remove it before the base class // destructor tries to delete[] it. data_ = NULL; } - int size() const { return string_data_.size(); } - - private: std::string string_data_; }; @@ -73,10 +79,6 @@ class DrainableIOBuffer : public IOBuffer { public: DrainableIOBuffer(IOBuffer* base, int size) : IOBuffer(base->data()), base_(base), size_(size), used_(0) {} - ~DrainableIOBuffer() { - // The buffer is owned by the |base_| instance. - data_ = NULL; - } // DidConsume() changes the |data_| pointer so that |data_| always points // to the first unconsumed byte. @@ -95,6 +97,11 @@ class DrainableIOBuffer : public IOBuffer { int size() const { return size_; } private: + ~DrainableIOBuffer() { + // The buffer is owned by the |base_| instance. + data_ = NULL; + } + scoped_refptr<IOBuffer> base_; int size_; int used_; @@ -104,7 +111,6 @@ class DrainableIOBuffer : public IOBuffer { class GrowableIOBuffer : public IOBuffer { public: GrowableIOBuffer() : IOBuffer(), capacity_(0), offset_(0) {} - ~GrowableIOBuffer() { data_ = NULL; } // realloc memory to the specified capacity. Returns true on success. // On failure, the capacity and buffer are unchanged. @@ -119,6 +125,8 @@ class GrowableIOBuffer : public IOBuffer { char* StartOfBuffer() { return real_data_.get(); } private: + ~GrowableIOBuffer() { data_ = NULL; } + scoped_ptr_malloc<char> real_data_; int capacity_; int offset_; @@ -133,6 +141,8 @@ class WrappedIOBuffer : public IOBuffer { public: explicit WrappedIOBuffer(const char* data) : IOBuffer(const_cast<char*>(data)) {} + + protected: ~WrappedIOBuffer() { data_ = NULL; } diff --git a/net/base/listen_socket.h b/net/base/listen_socket.h index 9ed30b6..585a094 100644 --- a/net/base/listen_socket.h +++ b/net/base/listen_socket.h @@ -59,7 +59,6 @@ class ListenSocket : public base::RefCountedThreadSafe<ListenSocket>, // accept local connections. static ListenSocket* Listen(std::string ip, int port, ListenSocketDelegate* del); - virtual ~ListenSocket(); // Send data to the socket. void Send(const char* bytes, int len, bool append_linefeed = false); @@ -72,10 +71,13 @@ class ListenSocket : public base::RefCountedThreadSafe<ListenSocket>, void ResumeReads(); protected: + friend class base::RefCountedThreadSafe<ListenSocket>; + static const SOCKET kInvalidSocket; static const int kSocketError; ListenSocket(SOCKET s, ListenSocketDelegate* del); + virtual ~ListenSocket(); static SOCKET Listen(std::string ip, int port); // if valid, returned SOCKET is non-blocking static SOCKET Accept(SOCKET s); diff --git a/net/base/listen_socket_unittest.h b/net/base/listen_socket_unittest.h index f9a9e0e..81cbb95 100644 --- a/net/base/listen_socket_unittest.h +++ b/net/base/listen_socket_unittest.h @@ -67,6 +67,10 @@ class ListenSocketTester : public base::RefCountedThreadSafe<ListenSocketTester> { protected: + friend class base::RefCountedThreadSafe<ListenSocketTester>; + + virtual ~ListenSocketTester() {} + virtual ListenSocket* DoListen(); public: @@ -77,9 +81,6 @@ class ListenSocketTester : connection_(NULL){ } - virtual ~ListenSocketTester() { - } - virtual void SetUp(); virtual void TearDown(); diff --git a/net/base/load_log.h b/net/base/load_log.h index 46f5530..7ee5185 100644 --- a/net/base/load_log.h +++ b/net/base/load_log.h @@ -106,6 +106,10 @@ class LoadLog : public base::RefCountedThreadSafe<LoadLog> { void Append(const LoadLog* log); private: + friend class base::RefCountedThreadSafe<LoadLog>; + + ~LoadLog() {} + EventList events_; }; diff --git a/net/base/mock_host_resolver.h b/net/base/mock_host_resolver.h index eee005c..72f10b4 100644 --- a/net/base/mock_host_resolver.h +++ b/net/base/mock_host_resolver.h @@ -38,8 +38,6 @@ class RuleBasedHostResolverProc; // Base class shared by MockHostResolver and MockCachingHostResolver. class MockHostResolverBase : public HostResolver { public: - virtual ~MockHostResolverBase() {} - // HostResolver methods: virtual int Resolve(const RequestInfo& info, AddressList* addresses, @@ -65,8 +63,8 @@ class MockHostResolverBase : public HostResolver { protected: MockHostResolverBase(bool use_caching); + virtual ~MockHostResolverBase() {} - private: scoped_refptr<HostResolverImpl> impl_; scoped_refptr<RuleBasedHostResolverProc> rules_; bool synchronous_mode_; @@ -76,6 +74,9 @@ class MockHostResolverBase : public HostResolver { class MockHostResolver : public MockHostResolverBase { public: MockHostResolver() : MockHostResolverBase(false /*use_caching*/) {} + + private: + virtual ~MockHostResolver() {} }; // Same as MockHostResolver, except internally it uses a host-cache. @@ -86,6 +87,9 @@ class MockHostResolver : public MockHostResolverBase { class MockCachingHostResolver : public MockHostResolverBase { public: MockCachingHostResolver() : MockHostResolverBase(true /*use_caching*/) {} + + private: + ~MockCachingHostResolver() {} }; // RuleBasedHostResolverProc applies a set of rules to map a host string to @@ -95,7 +99,6 @@ class MockCachingHostResolver : public MockHostResolverBase { class RuleBasedHostResolverProc : public HostResolverProc { public: explicit RuleBasedHostResolverProc(HostResolverProc* previous); - ~RuleBasedHostResolverProc(); // Any hostname matching the given pattern will be replaced with the given // replacement value. Usually, replacement should be an IP address literal. @@ -131,6 +134,8 @@ class RuleBasedHostResolverProc : public HostResolverProc { AddressList* addrlist); private: + ~RuleBasedHostResolverProc(); + struct Rule; typedef std::list<Rule> RuleList; @@ -155,6 +160,9 @@ class WaitingHostResolverProc : public HostResolverProc { return ResolveUsingPrevious(host, address_family, addrlist); } + private: + ~WaitingHostResolverProc() {} + base::WaitableEvent event_; }; diff --git a/net/base/sdch_manager.h b/net/base/sdch_manager.h index 5716da9..b5f9500 100644 --- a/net/base/sdch_manager.h +++ b/net/base/sdch_manager.h @@ -159,6 +159,7 @@ class SdchManager { const std::string& text() const { return text_; } private: + friend class base::RefCounted<Dictionary>; friend class SdchManager; // Only manager can construct an instance. FRIEND_TEST(SdchFilterTest, PathMatch); @@ -169,6 +170,7 @@ class SdchManager { const std::string& client_hash, const GURL& url, const std::string& domain, const std::string& path, const base::Time& expiration, const std::set<int> ports); + ~Dictionary() {} const GURL& url() const { return url_; } const std::string& client_hash() const { return client_hash_; } diff --git a/net/base/ssl_cert_request_info.h b/net/base/ssl_cert_request_info.h index 913a219..7946e17 100644 --- a/net/base/ssl_cert_request_info.h +++ b/net/base/ssl_cert_request_info.h @@ -37,6 +37,11 @@ class SSLCertRequestInfo // DistinguishedName certificate_authorities<3..2^16-1>; // } CertificateRequest; std::vector<scoped_refptr<X509Certificate> > client_certs; + + private: + friend class base::RefCountedThreadSafe<SSLCertRequestInfo>; + + ~SSLCertRequestInfo() {} }; } // namespace net diff --git a/net/base/ssl_config_service.h b/net/base/ssl_config_service.h index c8c0638..a4d3cb4 100644 --- a/net/base/ssl_config_service.h +++ b/net/base/ssl_config_service.h @@ -66,8 +66,6 @@ struct SSLConfig { // live longer than the configuration preferences. class SSLConfigService : public base::RefCountedThreadSafe<SSLConfigService> { public: - virtual ~SSLConfigService() {} - // Create an instance of SSLConfigService which retrieves the configuration // from the system SSL configuration, or an instance of // SSLConfigServiceDefaults if the current system does not have a system SSL @@ -77,6 +75,11 @@ class SSLConfigService : public base::RefCountedThreadSafe<SSLConfigService> { // May not be thread-safe, should only be called on the IO thread. virtual void GetSSLConfig(SSLConfig* config) = 0; + + protected: + friend class base::RefCountedThreadSafe<SSLConfigService>; + + virtual ~SSLConfigService() {} }; } // namespace net diff --git a/net/base/ssl_config_service_defaults.h b/net/base/ssl_config_service_defaults.h index 9360020..5425b27 100644 --- a/net/base/ssl_config_service_defaults.h +++ b/net/base/ssl_config_service_defaults.h @@ -15,7 +15,6 @@ namespace net { class SSLConfigServiceDefaults : public SSLConfigService { public: SSLConfigServiceDefaults() {} - virtual ~SSLConfigServiceDefaults() {} // Store default SSL config settings in |config|. virtual void GetSSLConfig(SSLConfig* config) { @@ -23,6 +22,8 @@ class SSLConfigServiceDefaults : public SSLConfigService { } private: + virtual ~SSLConfigServiceDefaults() {} + // Default value of prefs. const SSLConfig default_config_; diff --git a/net/base/ssl_config_service_mac.h b/net/base/ssl_config_service_mac.h index 4741034..5a60803 100644 --- a/net/base/ssl_config_service_mac.h +++ b/net/base/ssl_config_service_mac.h @@ -16,7 +16,6 @@ class SSLConfigServiceMac : public SSLConfigService { public: SSLConfigServiceMac(); explicit SSLConfigServiceMac(base::TimeTicks now); // Used for testing. - virtual ~SSLConfigServiceMac() {} // Get the current SSL configuration settings. Can be called on any // thread. @@ -40,6 +39,8 @@ class SSLConfigServiceMac : public SSLConfigService { void GetSSLConfigAt(SSLConfig* config, base::TimeTicks now); private: + virtual ~SSLConfigServiceMac() {} + void UpdateConfig(base::TimeTicks now); // We store the system SSL config and the time that we fetched it. diff --git a/net/base/ssl_config_service_win.h b/net/base/ssl_config_service_win.h index ef3346e..e7b77c7 100644 --- a/net/base/ssl_config_service_win.h +++ b/net/base/ssl_config_service_win.h @@ -23,7 +23,6 @@ class SSLConfigServiceWin : public SSLConfigService { public: SSLConfigServiceWin(); explicit SSLConfigServiceWin(base::TimeTicks now); // Used for testing. - virtual ~SSLConfigServiceWin() {} // Get the current SSL configuration settings. Can be called on any // thread. @@ -45,6 +44,8 @@ class SSLConfigServiceWin : public SSLConfigService { void GetSSLConfigAt(SSLConfig* config, base::TimeTicks now); private: + virtual ~SSLConfigServiceWin() {} + void UpdateConfig(base::TimeTicks now); // We store the IE SSL config and the time that we fetched it. diff --git a/net/base/strict_transport_security_state.h b/net/base/strict_transport_security_state.h index 463382c..de7d2b1 100644 --- a/net/base/strict_transport_security_state.h +++ b/net/base/strict_transport_security_state.h @@ -66,6 +66,10 @@ class StrictTransportSecurityState : bool Deserialise(const std::string& state); private: + friend class base::RefCountedThreadSafe<StrictTransportSecurityState>; + + ~StrictTransportSecurityState() {} + // If we have a callback configured, call it to let our serialiser know that // our state is dirty. void DirtyNotify(); diff --git a/net/base/telnet_server.h b/net/base/telnet_server.h index e1c9344..d8d21e8 100644 --- a/net/base/telnet_server.h +++ b/net/base/telnet_server.h @@ -14,7 +14,6 @@ class TelnetServer : public ListenSocket { public: static TelnetServer* Listen(std::string ip, int port, ListenSocketDelegate *del); - virtual ~TelnetServer(); protected: void Listen() { ListenSocket::Listen(); } @@ -45,6 +44,7 @@ private: }; TelnetServer(SOCKET s, ListenSocketDelegate* del); + virtual ~TelnetServer(); // telnet commands void SendIAC(int command, int option); diff --git a/net/base/telnet_server_unittest.cc b/net/base/telnet_server_unittest.cc index 0d5853b..483309c 100644 --- a/net/base/telnet_server_unittest.cc +++ b/net/base/telnet_server_unittest.cc @@ -33,6 +33,9 @@ public: } return false; } + +private: + ~TelnetServerTester() {} }; class TelnetServerTest: public PlatformTest { diff --git a/net/base/test_completion_callback_unittest.cc b/net/base/test_completion_callback_unittest.cc index 1d333f7..c19aae0 100644 --- a/net/base/test_completion_callback_unittest.cc +++ b/net/base/test_completion_callback_unittest.cc @@ -47,6 +47,10 @@ class ExampleEmployer::ExampleWorker void DoWork(); void DoCallback(); private: + friend class base::RefCountedThreadSafe<ExampleWorker>; + + ~ExampleWorker() {} + // Only used on the origin thread (where DoSomething was called). ExampleEmployer* employer_; CompletionCallback* callback_; diff --git a/net/base/upload_data.h b/net/base/upload_data.h index f1d4369..02880d3 100644 --- a/net/base/upload_data.h +++ b/net/base/upload_data.h @@ -102,6 +102,10 @@ class UploadData : public base::RefCounted<UploadData> { int64 identifier() const { return identifier_; } private: + friend class base::RefCounted<UploadData>; + + ~UploadData() {} + std::vector<Element> elements_; int64 identifier_; }; diff --git a/net/disk_cache/file_posix.cc b/net/disk_cache/file_posix.cc index 3ffdb45..bfaad59 100644 --- a/net/disk_cache/file_posix.cc +++ b/net/disk_cache/file_posix.cc @@ -35,8 +35,6 @@ class BackgroundIO : public base::RefCountedThreadSafe<BackgroundIO> { buf_len_(buf_len), offset_(offset), controller_(controller), bytes_(0) {} - ~BackgroundIO() {} - // Read and Write are the operations that can be performed asynchronously. // The actual parameters for the operation are setup in the constructor of // the object, with the exception of |delete_buffer|, that allows a write @@ -75,6 +73,9 @@ class BackgroundIO : public base::RefCountedThreadSafe<BackgroundIO> { } private: + friend class base::RefCountedThreadSafe<BackgroundIO>; + ~BackgroundIO() {} + // An event to signal when the operation completes, and the user callback that // has to be invoked. These members are accessed directly by the controller. base::WaitableEvent io_completed_; diff --git a/net/disk_cache/mapped_file.h b/net/disk_cache/mapped_file.h index 7d58532..5b34141 100644 --- a/net/disk_cache/mapped_file.h +++ b/net/disk_cache/mapped_file.h @@ -38,10 +38,9 @@ class MappedFile : public File { bool Load(const FileBlock* block); bool Store(const FileBlock* block); - protected: + private: virtual ~MappedFile(); - private: bool init_; #if defined(OS_WIN) HANDLE section_; diff --git a/net/disk_cache/sparse_control.cc b/net/disk_cache/sparse_control.cc index fb304be..509ce78 100644 --- a/net/disk_cache/sparse_control.cc +++ b/net/disk_cache/sparse_control.cc @@ -60,6 +60,9 @@ class ChildrenDeleter void ReadData(disk_cache::Addr address, int len); private: + friend class base::RefCounted<ChildrenDeleter>; + ~ChildrenDeleter() {} + void DeleteChildren(); disk_cache::BackendImpl* backend_; diff --git a/net/flip/flip_session.h b/net/flip/flip_session.h index 176dd29..08160ea 100644 --- a/net/flip/flip_session.h +++ b/net/flip/flip_session.h @@ -90,8 +90,6 @@ class FlipDelegate { class FlipSession : public base::RefCounted<FlipSession>, public flip::FlipFramerVisitorInterface { public: - virtual ~FlipSession(); - // Get the domain for this FlipSession. const std::string& domain() const { return domain_; } @@ -138,6 +136,9 @@ class FlipSession : public base::RefCounted<FlipSession>, static void SetSSLMode(bool enable) { use_ssl_ = enable; } private: + friend class base::RefCounted<FlipSession>; + virtual ~FlipSession(); + // FlipFramerVisitorInterface virtual void OnError(flip::FlipFramer*); virtual void OnStreamFrameData(flip::FlipStreamId stream_id, diff --git a/net/flip/flip_session_pool.h b/net/flip/flip_session_pool.h index e9c01a3..76ffc0d 100644 --- a/net/flip/flip_session_pool.h +++ b/net/flip/flip_session_pool.h @@ -24,7 +24,6 @@ class HttpNetworkSession; class FlipSessionPool : public base::RefCounted<FlipSessionPool> { public: FlipSessionPool(); - virtual ~FlipSessionPool(); // Either returns an existing FlipSession or creates a new FlipSession for // use. @@ -49,8 +48,11 @@ class FlipSessionPool : public base::RefCounted<FlipSessionPool> { void CloseAllSessions(); private: + friend class base::RefCounted<FlipSessionPool>; friend class FlipSession; // Needed for Remove(). + virtual ~FlipSessionPool(); + typedef std::list<FlipSession*> FlipSessionList; typedef std::map<std::string, FlipSessionList*> FlipSessionsMap; diff --git a/net/ftp/ftp_network_session.h b/net/ftp/ftp_network_session.h index dcaacad..3c29a85 100644 --- a/net/ftp/ftp_network_session.h +++ b/net/ftp/ftp_network_session.h @@ -22,6 +22,10 @@ class FtpNetworkSession : public base::RefCounted<FtpNetworkSession> { FtpAuthCache* auth_cache() { return &auth_cache_; } private: + friend class base::RefCounted<FtpNetworkSession>; + + ~FtpNetworkSession() {} + scoped_refptr<HostResolver> host_resolver_; FtpAuthCache auth_cache_; }; diff --git a/net/http/http_auth_cache_unittest.cc b/net/http/http_auth_cache_unittest.cc index 28bde95..52fa5cd 100644 --- a/net/http/http_auth_cache_unittest.cc +++ b/net/http/http_auth_cache_unittest.cc @@ -34,6 +34,9 @@ class MockAuthHandler : public HttpAuthHandler { virtual bool Init(std::string::const_iterator, std::string::const_iterator) { return false; // Unused. } + + private: + ~MockAuthHandler() {} }; } // namespace diff --git a/net/http/http_auth_handler.h b/net/http/http_auth_handler.h index 1caf1a4..02a410e 100644 --- a/net/http/http_auth_handler.h +++ b/net/http/http_auth_handler.h @@ -21,8 +21,6 @@ class ProxyInfo; // HttpAuth::CreateAuthHandler(). class HttpAuthHandler : public base::RefCounted<HttpAuthHandler> { public: - virtual ~HttpAuthHandler() { } - // Initialize the handler by parsing a challenge string. bool InitFromChallenge(std::string::const_iterator begin, std::string::const_iterator end, @@ -86,6 +84,10 @@ class HttpAuthHandler : public base::RefCounted<HttpAuthHandler> { IS_CONNECTION_BASED = 1 << 1, }; + friend class base::RefCounted<HttpAuthHandler>; + + virtual ~HttpAuthHandler() { } + // Initialize the handler by parsing a challenge string. // Implementations are expcted to initialize the following members: // scheme_, realm_, score_, properties_ diff --git a/net/http/http_auth_handler_basic.h b/net/http/http_auth_handler_basic.h index 1424c8f..679c91a 100644 --- a/net/http/http_auth_handler_basic.h +++ b/net/http/http_auth_handler_basic.h @@ -20,6 +20,8 @@ class HttpAuthHandlerBasic : public HttpAuthHandler { virtual bool Init(std::string::const_iterator challenge_begin, std::string::const_iterator challenge_end); + private: + ~HttpAuthHandlerBasic() {} }; } // namespace net diff --git a/net/http/http_auth_handler_digest.h b/net/http/http_auth_handler_digest.h index 26d67f8..b4c8687 100644 --- a/net/http/http_auth_handler_digest.h +++ b/net/http/http_auth_handler_digest.h @@ -53,6 +53,8 @@ class HttpAuthHandlerDigest : public HttpAuthHandler { QOP_AUTH_INT = 1 << 1, }; + ~HttpAuthHandlerDigest() {} + // Parse the challenge, saving the results into this instance. // Returns true on success. bool ParseChallenge(std::string::const_iterator challenge_begin, diff --git a/net/http/http_auth_handler_ntlm.h b/net/http/http_auth_handler_ntlm.h index 27a6666..ca2b234 100644 --- a/net/http/http_auth_handler_ntlm.h +++ b/net/http/http_auth_handler_ntlm.h @@ -63,8 +63,6 @@ class HttpAuthHandlerNTLM : public HttpAuthHandler { HttpAuthHandlerNTLM(); - virtual ~HttpAuthHandlerNTLM(); - virtual bool NeedsIdentity(); virtual bool IsFinalRound(); @@ -85,6 +83,8 @@ class HttpAuthHandlerNTLM : public HttpAuthHandler { int InitializeBeforeFirstChallenge(); private: + ~HttpAuthHandlerNTLM(); + #if defined(NTLM_PORTABLE) // For unit tests to override the GenerateRandom and GetHostName functions. // Returns the old function. diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc index 6ba7188..fd66e79 100644 --- a/net/http/http_cache_unittest.cc +++ b/net/http/http_cache_unittest.cc @@ -61,9 +61,6 @@ class MockDiskEntry : public disk_cache::Entry, test_mode_ = t->test_mode; } - ~MockDiskEntry() { - } - bool is_doomed() const { return doomed_; } virtual void Doom() { @@ -254,6 +251,10 @@ class MockDiskEntry : public disk_cache::Entry, void set_fail_requests() { fail_requests_ = true; } private: + friend class base::RefCounted<MockDiskEntry>; + + ~MockDiskEntry() {} + // Unlike the callbacks for MockHttpTransaction, we want this one to run even // if the consumer called Close on the MockDiskEntry. We achieve that by // leveraging the fact that this class is reference counted. diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index b5786de..11e42f4 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -25,7 +25,6 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { ClientSocketFactory* client_socket_factory, SSLConfigService* ssl_config_service, FlipSessionPool* flip_session_pool); - ~HttpNetworkSession(); HttpAuthCache* auth_cache() { return &auth_cache_; } SSLClientAuthCache* ssl_client_auth_cache() { @@ -44,8 +43,11 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { static void set_max_sockets_per_group(int socket_count); private: + friend class base::RefCounted<HttpNetworkSession>; FRIEND_TEST(HttpNetworkTransactionTest, GroupNameForProxyConnections); + ~HttpNetworkSession(); + // Total limit of sockets. Not a constant to allow experiments. static int max_sockets_; diff --git a/net/ocsp/nss_ocsp.cc b/net/ocsp/nss_ocsp.cc index 64a446d..5521dc6 100644 --- a/net/ocsp/nss_ocsp.cc +++ b/net/ocsp/nss_ocsp.cc @@ -221,6 +221,12 @@ class OCSPRequestSession } private: + friend class base::RefCountedThreadSafe<OCSPRequestSession>; + + virtual ~OCSPRequestSession() { + DCHECK(!request_); + } + void StartURLRequest() { DCHECK(MessageLoopForIO::current() == io_loop_); DCHECK(!request_); diff --git a/net/proxy/mock_proxy_resolver.h b/net/proxy/mock_proxy_resolver.h index 4c56124..67eb925 100644 --- a/net/proxy/mock_proxy_resolver.h +++ b/net/proxy/mock_proxy_resolver.h @@ -46,6 +46,10 @@ class MockAsyncProxyResolverBase : public ProxyResolver { } private: + friend class base::RefCounted<Request>; + + ~Request() {} + MockAsyncProxyResolverBase* resolver_; const GURL url_; ProxyInfo* results_; diff --git a/net/proxy/proxy_config_service_linux.h b/net/proxy/proxy_config_service_linux.h index ef6519a..a55ba35 100644 --- a/net/proxy/proxy_config_service_linux.h +++ b/net/proxy/proxy_config_service_linux.h @@ -139,6 +139,10 @@ class ProxyConfigServiceLinux : public ProxyConfigService { void OnDestroy(); private: + friend class base::RefCountedThreadSafe<Delegate>; + + ~Delegate() {} + // Obtains an environment variable's value. Parses a proxy server // specification from it and puts it in result. Returns true if the // requested variable is defined and the value valid. diff --git a/net/proxy/proxy_resolver_js_bindings.cc b/net/proxy/proxy_resolver_js_bindings.cc index 077e5c6..1b01651 100644 --- a/net/proxy/proxy_resolver_js_bindings.cc +++ b/net/proxy/proxy_resolver_js_bindings.cc @@ -61,6 +61,10 @@ class SyncHostResolverBridge } private: + friend class base::RefCountedThreadSafe<SyncHostResolverBridge>; + + ~SyncHostResolverBridge() {} + // Called on host_resolver_loop_. void StartResolve(const HostResolver::RequestInfo& info, net::AddressList* addresses) { diff --git a/net/proxy/proxy_resolver_js_bindings_unittest.cc b/net/proxy/proxy_resolver_js_bindings_unittest.cc index 4e0f6a6..1a36d3d 100644 --- a/net/proxy/proxy_resolver_js_bindings_unittest.cc +++ b/net/proxy/proxy_resolver_js_bindings_unittest.cc @@ -48,6 +48,8 @@ class MockHostResolverWithMultipleResults : public HostResolver { virtual void Shutdown() {} private: + ~MockHostResolverWithMultipleResults() {} + // Resolves an IP literal to an address list. AddressList ResolveIPLiteral(const char* ip_literal) { AddressList result; diff --git a/net/proxy/proxy_script_fetcher_unittest.cc b/net/proxy/proxy_script_fetcher_unittest.cc index ad28c10..ff78e33 100644 --- a/net/proxy/proxy_script_fetcher_unittest.cc +++ b/net/proxy/proxy_script_fetcher_unittest.cc @@ -41,6 +41,8 @@ class RequestContext : public URLRequestContext { host_resolver_, proxy_service_, ssl_config_service_), disk_cache::CreateInMemoryCacheBackend(0)); } + + private: ~RequestContext() { delete http_transaction_factory_; } diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index c74f6de..91a6133 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -170,6 +170,10 @@ class ProxyService::PacRequest LoadLog* load_log() const { return load_log_; } private: + friend class base::RefCounted<ProxyService::PacRequest>; + + ~PacRequest() {} + // Callback for when the ProxyResolver request has completed. void QueryComplete(int result_code) { result_code = QueryDidComplete(result_code); diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index d7ed7ab..194ad7b 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -36,8 +36,6 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService> { // The instance takes ownership of |config_service| and |resolver|. ProxyService(ProxyConfigService* config_service, ProxyResolver* resolver); - ~ProxyService(); - // Used internally to handle PAC queries. // TODO(eroman): consider naming this simply "Request". class PacRequest; @@ -154,16 +152,20 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService> { MessageLoop* io_loop, MessageLoop* file_loop); private: + friend class base::RefCountedThreadSafe<ProxyService>; FRIEND_TEST(ProxyServiceTest, IsLocalName); FRIEND_TEST(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); FRIEND_TEST(ProxyServiceTest, UpdateConfigFromPACToDirect); friend class PacRequest; + // TODO(eroman): change this to a std::set. Note that this requires updating // some tests in proxy_service_unittest.cc such as: // ProxyServiceTest.InitialPACScriptDownload // which expects requests to finish in the order they were added. typedef std::vector<scoped_refptr<PacRequest> > PendingRequests; + ~ProxyService(); + // Creates a proxy resolver appropriate for this platform that doesn't rely // on V8. static ProxyResolver* CreateNonV8ProxyResolver(); @@ -283,6 +285,10 @@ class SyncProxyServiceHelper ProxyInfo* proxy_info, LoadLog* load_log); private: + friend class base::RefCountedThreadSafe<SyncProxyServiceHelper>; + + ~SyncProxyServiceHelper() {} + void StartAsyncResolve(const GURL& url, LoadLog* load_log); void StartAsyncReconsider(const GURL& url, LoadLog* load_log); diff --git a/net/proxy/single_threaded_proxy_resolver.cc b/net/proxy/single_threaded_proxy_resolver.cc index ab13fa1..ad5fdba 100644 --- a/net/proxy/single_threaded_proxy_resolver.cc +++ b/net/proxy/single_threaded_proxy_resolver.cc @@ -18,6 +18,8 @@ class PurgeMemoryTask : public base::RefCountedThreadSafe<PurgeMemoryTask> { explicit PurgeMemoryTask(ProxyResolver* resolver) : resolver_(resolver) {} void PurgeMemory() { resolver_->PurgeMemory(); } private: + friend class base::RefCountedThreadSafe<PurgeMemoryTask>; + ~PurgeMemoryTask() {} ProxyResolver* resolver_; }; @@ -60,6 +62,11 @@ class SingleThreadedProxyResolver::SetPacScriptTask bool was_cancelled() const { return callback_ == NULL; } private: + friend class base::RefCountedThreadSafe< + SingleThreadedProxyResolver::SetPacScriptTask>; + + ~SetPacScriptTask() {} + // Runs on the worker thread. void DoRequest(ProxyResolver* resolver) { int rv = resolver->expects_pac_bytes() ? @@ -137,6 +144,10 @@ class SingleThreadedProxyResolver::Job bool was_cancelled() const { return callback_ == NULL; } private: + friend class base::RefCountedThreadSafe<SingleThreadedProxyResolver::Job>; + + ~Job() {} + // Runs on the worker thread. void DoQuery(ProxyResolver* resolver) { LoadLog* worker_log = new LoadLog; diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h index 23c194c..b9c28e9 100644 --- a/net/socket/client_socket_pool_base.h +++ b/net/socket/client_socket_pool_base.h @@ -168,8 +168,6 @@ class ClientSocketPoolBaseHelper base::TimeDelta used_idle_socket_timeout, ConnectJobFactory* connect_job_factory); - ~ClientSocketPoolBaseHelper(); - // See ClientSocketPool::RequestSocket for documentation on this function. // Note that |request| must be heap allocated. If ERR_IO_PENDING is returned, // then ClientSocketPoolBaseHelper takes ownership of |request|. @@ -222,6 +220,10 @@ class ClientSocketPoolBaseHelper void CleanupIdleSockets(bool force); private: + friend class base::RefCounted<ClientSocketPoolBaseHelper>; + + ~ClientSocketPoolBaseHelper(); + // Entry for a persistent socket which became idle at time |start_time|. struct IdleSocket { IdleSocket() : socket(NULL), used(false) {} diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index 5f0695a..437db55 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -327,6 +327,8 @@ class TestClientSocketPool : public ClientSocketPool { void CleanupTimedOutIdleSockets() { base_.CleanupIdleSockets(false); } private: + ~TestClientSocketPool() {} + TestClientSocketPoolBase base_; DISALLOW_COPY_AND_ASSIGN(TestClientSocketPool); diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc index 199dccd..08d1b19 100644 --- a/net/socket/tcp_client_socket_win.cc +++ b/net/socket/tcp_client_socket_win.cc @@ -126,7 +126,6 @@ bool ShouldTryNextAddress(int err) { class TCPClientSocketWin::Core : public base::RefCounted<Core> { public: explicit Core(TCPClientSocketWin* socket); - ~Core(); // Start watching for the end of a read or write operation. void WatchForRead(); @@ -161,6 +160,8 @@ class TCPClientSocketWin::Core : public base::RefCounted<Core> { } private: + friend class base::RefCounted<Core>; + class ReadDelegate : public base::ObjectWatcher::Delegate { public: explicit ReadDelegate(Core* core) : core_(core) {} @@ -185,6 +186,8 @@ class TCPClientSocketWin::Core : public base::RefCounted<Core> { Core* const core_; }; + ~Core(); + // The socket that created this object. TCPClientSocketWin* socket_; diff --git a/net/socket/tcp_pinger.h b/net/socket/tcp_pinger.h index af9dc84..ae543c5 100644 --- a/net/socket/tcp_pinger.h +++ b/net/socket/tcp_pinger.h @@ -115,6 +115,10 @@ class TCPPinger { } private: + friend class base::RefCountedThreadSafe<Worker>; + + ~Worker() {} + base::WaitableEvent event_; int net_error_; net::AddressList addr_; diff --git a/net/socket_stream/socket_stream.h b/net/socket_stream/socket_stream.h index 14dfd36..84fa2bb 100644 --- a/net/socket_stream/socket_stream.h +++ b/net/socket_stream/socket_stream.h @@ -140,18 +140,20 @@ class SocketStream : public base::RefCountedThreadSafe<SocketStream> { class RequestHeaders : public IOBuffer { public: RequestHeaders() : IOBuffer() {} - ~RequestHeaders() { data_ = NULL; } void SetDataOffset(size_t offset) { data_ = const_cast<char*>(headers_.data()) + offset; } + std::string headers_; + + private: + ~RequestHeaders() { data_ = NULL; } }; class ResponseHeaders : public IOBuffer { public: ResponseHeaders() : IOBuffer() {} - ~ResponseHeaders() { data_ = NULL; } void SetDataOffset(size_t offset) { data_ = headers_.get() + offset; } char* headers() const { return headers_.get(); } @@ -159,6 +161,8 @@ class SocketStream : public base::RefCountedThreadSafe<SocketStream> { void Realloc(size_t new_size); private: + ~ResponseHeaders() { data_ = NULL; } + scoped_ptr_malloc<char> headers_; }; diff --git a/net/tools/fetch/fetch_client.cc b/net/tools/fetch/fetch_client.cc index 4c4ac46..f40c9e7 100644 --- a/net/tools/fetch/fetch_client.cc +++ b/net/tools/fetch/fetch_client.cc @@ -107,7 +107,7 @@ class Client { GURL url_; net::HttpRequestInfo request_info_; scoped_ptr<net::HttpTransaction> transaction_; - scoped_ptr<net::IOBuffer> buffer_; + scoped_refptr<net::IOBuffer> buffer_; net::CompletionCallbackImpl<Client> connect_callback_; net::CompletionCallbackImpl<Client> read_callback_; Singleton<Driver> driver_; diff --git a/net/tools/fetch/http_listen_socket.h b/net/tools/fetch/http_listen_socket.h index f31df20..bb6d383 100644 --- a/net/tools/fetch/http_listen_socket.h +++ b/net/tools/fetch/http_listen_socket.h @@ -14,16 +14,15 @@ class HttpServerResponseInfo; // Implements a simple HTTP listen socket on top of the raw socket interface. class HttpListenSocket : public ListenSocket, public ListenSocket::ListenSocketDelegate { -public: + public: class Delegate { public: - virtual void OnRequest(HttpListenSocket* connection, + virtual void OnRequest(HttpListenSocket* connection, HttpServerRequestInfo* info) = 0; }; static HttpListenSocket* Listen(const std::string& ip, int port, HttpListenSocket::Delegate* delegate); - virtual ~HttpListenSocket(); void Listen() { ListenSocket::Listen(); } virtual void Accept(); @@ -37,9 +36,12 @@ public: virtual void DidRead(ListenSocket* connection, const std::string& data); virtual void DidClose(ListenSocket* sock); -private: + private: + friend class base::RefCountedThreadSafe<ListenSocket>; + static const int kReadBufSize = 16 * 1024; HttpListenSocket(SOCKET s, HttpListenSocket::Delegate* del); + virtual ~HttpListenSocket(); // Expects the raw data to be stored in recv_data_. If parsing is successful, // will remove the data parsed from recv_data_, leaving only the unused diff --git a/net/tools/fetch/http_session.h b/net/tools/fetch/http_session.h index 2289b30..4d9e84b 100644 --- a/net/tools/fetch/http_session.h +++ b/net/tools/fetch/http_session.h @@ -1,27 +1,27 @@ -// Copyright (c) 2009 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 NET_BASE_TOOLS_HTTP_SESSION_H_
-#define NET_BASE_TOOLS_HTTP_SESSION_H_
-
-#include "base/basictypes.h"
-#include "net/http/http_request_info.h"
-#include "net/tools/fetch/http_listen_socket.h"
-
-// An HttpSession encapsulates a server-side HTTP listen socket.
-class HttpSession : HttpListenSocket::Delegate {
-public:
- HttpSession(const std::string& ip, int port);
- virtual ~HttpSession();
-
- virtual void OnRequest(HttpListenSocket* connection,
- HttpServerRequestInfo* info);
-
-private:
- scoped_ptr<HttpListenSocket> socket_;
- DISALLOW_EVIL_CONSTRUCTORS(HttpSession);
-};
-
-#endif // NET_BASE_TOOLS_HTTP_SESSION_H_
-
+// Copyright (c) 2009 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 NET_BASE_TOOLS_HTTP_SESSION_H_ +#define NET_BASE_TOOLS_HTTP_SESSION_H_ + +#include "base/basictypes.h" +#include "net/http/http_request_info.h" +#include "net/tools/fetch/http_listen_socket.h" + +// An HttpSession encapsulates a server-side HTTP listen socket. +class HttpSession : HttpListenSocket::Delegate { + public: + HttpSession(const std::string& ip, int port); + virtual ~HttpSession(); + + virtual void OnRequest(HttpListenSocket* connection, + HttpServerRequestInfo* info); + + private: + scoped_refptr<HttpListenSocket> socket_; + DISALLOW_EVIL_CONSTRUCTORS(HttpSession); +}; + +#endif // NET_BASE_TOOLS_HTTP_SESSION_H_ + diff --git a/net/url_request/url_request_about_job.h b/net/url_request/url_request_about_job.h index 651a053..70822d2 100644 --- a/net/url_request/url_request_about_job.h +++ b/net/url_request/url_request_about_job.h @@ -20,6 +20,8 @@ class URLRequestAboutJob : public URLRequestJob { static URLRequest::ProtocolFactory Factory; private: + ~URLRequestAboutJob() {} + void StartAsync(); }; diff --git a/net/url_request/url_request_data_job.h b/net/url_request/url_request_data_job.h index 44dc327..1c1dbaa 100644 --- a/net/url_request/url_request_data_job.h +++ b/net/url_request/url_request_data_job.h @@ -22,6 +22,9 @@ class URLRequestDataJob : public URLRequestSimpleJob { static URLRequest::ProtocolFactory Factory; + private: + ~URLRequestDataJob() {} + DISALLOW_COPY_AND_ASSIGN(URLRequestDataJob); }; diff --git a/net/url_request/url_request_error_job.h b/net/url_request/url_request_error_job.h index 1810bb2..396c38d 100644 --- a/net/url_request/url_request_error_job.h +++ b/net/url_request/url_request_error_job.h @@ -17,6 +17,8 @@ class URLRequestErrorJob : public URLRequestJob { virtual void Start(); private: + ~URLRequestErrorJob() {} + int error_; void StartAsync(); }; diff --git a/net/url_request/url_request_file_dir_job.h b/net/url_request/url_request_file_dir_job.h index 52a6d61..24a6c72 100644 --- a/net/url_request/url_request_file_dir_job.h +++ b/net/url_request/url_request_file_dir_job.h @@ -17,7 +17,6 @@ class URLRequestFileDirJob public net::DirectoryLister::DirectoryListerDelegate { public: URLRequestFileDirJob(URLRequest* request, const FilePath& dir_path); - virtual ~URLRequestFileDirJob(); // URLRequestJob methods: virtual void Start(); @@ -35,6 +34,8 @@ class URLRequestFileDirJob bool list_complete() const { return list_complete_; } private: + virtual ~URLRequestFileDirJob(); + void CloseLister(); // When we have data and a read has been pending, this function // will fill the response buffer and notify the request diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc index aa3ee56..8e1b7dc 100644 --- a/net/url_request/url_request_file_job.cc +++ b/net/url_request/url_request_file_job.cc @@ -60,6 +60,10 @@ class URLRequestFileJob::AsyncResolver : } private: + friend class base::RefCountedThreadSafe<URLRequestFileJob::AsyncResolver>; + + ~AsyncResolver() {} + void ReturnResults(bool exists, const file_util::FileInfo& file_info) { if (owner_) owner_->DidResolve(exists, file_info); diff --git a/net/url_request/url_request_file_job.h b/net/url_request/url_request_file_job.h index f7da8c1..8cb28bd 100644 --- a/net/url_request/url_request_file_job.h +++ b/net/url_request/url_request_file_job.h @@ -22,7 +22,6 @@ struct FileInfo; class URLRequestFileJob : public URLRequestJob { public: URLRequestFileJob(URLRequest* request, const FilePath& file_path); - virtual ~URLRequestFileJob(); virtual void Start(); virtual void Kill(); @@ -36,6 +35,8 @@ class URLRequestFileJob : public URLRequestJob { static URLRequest::ProtocolFactory Factory; protected: + virtual ~URLRequestFileJob(); + // The OS-specific full path name of the file FilePath file_path_; diff --git a/net/url_request/url_request_ftp_job.h b/net/url_request/url_request_ftp_job.h index b85a06d..a2b2aea 100644 --- a/net/url_request/url_request_ftp_job.h +++ b/net/url_request/url_request_ftp_job.h @@ -14,8 +14,6 @@ class URLRequestFtpJob : public URLRequestInetJob { public: static URLRequestJob* Factory(URLRequest* request, const std::string& scheme); - virtual ~URLRequestFtpJob(); - // URLRequestJob methods: virtual void Start(); virtual bool GetMimeType(std::string* mime_type) const; @@ -38,6 +36,8 @@ class URLRequestFtpJob : public URLRequestInetJob { virtual bool IsRedirectResponse(GURL* location, int* http_status_code); private: + virtual ~URLRequestFtpJob(); + // Called after InternetConnect successfully connects to server. void OnConnect(); diff --git a/net/url_request/url_request_http_job.h b/net/url_request/url_request_http_job.h index f8cc55e..b3ccbd1 100644 --- a/net/url_request/url_request_http_job.h +++ b/net/url_request/url_request_http_job.h @@ -27,8 +27,6 @@ class URLRequestHttpJob : public URLRequestJob { public: static URLRequestJob* Factory(URLRequest* request, const std::string& scheme); - virtual ~URLRequestHttpJob(); - protected: explicit URLRequestHttpJob(URLRequest* request); @@ -116,6 +114,9 @@ class URLRequestHttpJob : public URLRequestJob { // For recording of stats, we need to remember if this is cached content. bool is_cached_content_; + private: + virtual ~URLRequestHttpJob(); + DISALLOW_COPY_AND_ASSIGN(URLRequestHttpJob); }; diff --git a/net/url_request/url_request_inet_job.h b/net/url_request/url_request_inet_job.h index c5777ba..1870485 100644 --- a/net/url_request/url_request_inet_job.h +++ b/net/url_request/url_request_inet_job.h @@ -22,7 +22,6 @@ class MessageLoop; class URLRequestInetJob : public URLRequestJob { public: URLRequestInetJob(URLRequest* request); - virtual ~URLRequestInetJob(); virtual void SetExtraRequestHeaders(const std::string& headers) { extra_request_headers_ = headers; @@ -57,7 +56,9 @@ class URLRequestInetJob : public URLRequestJob { HINTERNET request_handle() const { return request_handle_; } -protected: + protected: + virtual ~URLRequestInetJob(); + // Called by this class and subclasses to send or resend this request. virtual void SendRequest() = 0; diff --git a/net/url_request/url_request_job.h b/net/url_request/url_request_job.h index 9a34f4a..4ee7953 100644 --- a/net/url_request/url_request_job.h +++ b/net/url_request/url_request_job.h @@ -41,7 +41,6 @@ class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, static const size_t kSdchPacketHistogramCount = 5; explicit URLRequestJob(URLRequest* request); - virtual ~URLRequestJob(); // Returns the request that owns this job. THIS POINTER MAY BE NULL if the // request was destroyed. @@ -218,6 +217,9 @@ class URLRequestJob : public base::RefCountedThreadSafe<URLRequestJob>, virtual void RecordPacketStats(StatisticSelector statistic) const; protected: + friend class base::RefCountedThreadSafe<URLRequestJob>; + virtual ~URLRequestJob(); + // Notifies the job that headers have been received. void NotifyHeadersComplete(); diff --git a/net/url_request/url_request_new_ftp_job.h b/net/url_request/url_request_new_ftp_job.h index 95b0a3b..9b7a1a8 100644 --- a/net/url_request/url_request_new_ftp_job.h +++ b/net/url_request/url_request_new_ftp_job.h @@ -26,14 +26,14 @@ class URLRequestNewFtpJob : public URLRequestJob { explicit URLRequestNewFtpJob(URLRequest* request); - virtual ~URLRequestNewFtpJob(); - static URLRequestJob* Factory(URLRequest* request, const std::string& scheme); // URLRequestJob methods: virtual bool GetMimeType(std::string* mime_type) const; private: + virtual ~URLRequestNewFtpJob(); + // URLRequestJob methods: virtual void Start(); virtual void Kill(); diff --git a/net/url_request/url_request_redirect_job.h b/net/url_request/url_request_redirect_job.h index d7395a7..8a13204 100644 --- a/net/url_request/url_request_redirect_job.h +++ b/net/url_request/url_request_redirect_job.h @@ -21,6 +21,8 @@ class URLRequestRedirectJob : public URLRequestJob { bool IsRedirectResponse(GURL* location, int* http_status_code); private: + ~URLRequestRedirectJob() {} + void StartAsync(); GURL redirect_destination_; diff --git a/net/url_request/url_request_simple_job.h b/net/url_request/url_request_simple_job.h index 88f54c2..786d2e4 100644 --- a/net/url_request/url_request_simple_job.h +++ b/net/url_request/url_request_simple_job.h @@ -21,6 +21,8 @@ class URLRequestSimpleJob : public URLRequestJob { virtual bool GetCharset(std::string* charset); protected: + ~URLRequestSimpleJob() {} + // subclasses must override the way response data is determined. virtual bool GetData(std::string* mime_type, std::string* charset, diff --git a/net/url_request/url_request_test_job.h b/net/url_request/url_request_test_job.h index bfde712a..4daabf6 100644 --- a/net/url_request/url_request_test_job.h +++ b/net/url_request/url_request_test_job.h @@ -50,8 +50,6 @@ class URLRequestTestJob : public URLRequestJob { const std::string& response_data, bool auto_advance); - virtual ~URLRequestTestJob(); - // The three canned URLs this handler will respond to without having been // explicitly initialized with response headers and data. // FIXME(brettw): we should probably also have a redirect one @@ -102,6 +100,8 @@ class URLRequestTestJob : public URLRequestJob { // When the stage is DONE, this job will not be put on the queue. enum Stage { WAITING, DATA_AVAILABLE, ALL_DATA, DONE }; + virtual ~URLRequestTestJob(); + // Call to process the next opeation, usually sending a notification, and // advancing the stage if necessary. THIS MAY DELETE THE OBJECT. void ProcessNextOperation(); diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index 6aee61a..a8b47d2 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -66,6 +66,7 @@ class URLRequestTestContext : public URLRequestContext { accept_charset_ = "iso-8859-1,*,utf-8"; } + private: virtual ~URLRequestTestContext() { delete ftp_transaction_factory_; delete http_transaction_factory_; @@ -1433,6 +1434,8 @@ class RestartTestJob : public URLRequestTestJob { virtual void StartAsync() { this->NotifyRestartRequired(); } + private: + ~RestartTestJob() {} }; class CancelTestJob : public URLRequestTestJob { @@ -1443,6 +1446,8 @@ class CancelTestJob : public URLRequestTestJob { virtual void StartAsync() { request_->Cancel(); } + private: + ~CancelTestJob() {} }; class CancelThenRestartTestJob : public URLRequestTestJob { @@ -1455,6 +1460,8 @@ class CancelThenRestartTestJob : public URLRequestTestJob { request_->Cancel(); this->NotifyRestartRequired(); } + private: + ~CancelThenRestartTestJob() {} }; // An Interceptor for use with interceptor tests diff --git a/net/url_request/url_request_unittest.h b/net/url_request/url_request_unittest.h index 362f5889..b4a17ca 100644 --- a/net/url_request/url_request_unittest.h +++ b/net/url_request/url_request_unittest.h @@ -63,7 +63,8 @@ class TestURLRequestContext : public URLRequestContext { proxy_service_, ssl_config_service_); } - virtual ~TestURLRequestContext() { + protected: + ~TestURLRequestContext() { delete http_transaction_factory_; } }; @@ -244,8 +245,6 @@ class BaseTestServer : public base::RefCounted<BaseTestServer> { : launcher_(connection_attempts, connection_timeout) { } public: - virtual ~BaseTestServer() { } - void set_forking(bool forking) { launcher_.set_forking(forking); } @@ -295,6 +294,9 @@ class BaseTestServer : public base::RefCounted<BaseTestServer> { } protected: + friend class base::RefCounted<BaseTestServer>; + virtual ~BaseTestServer() { } + bool Start(net::TestServerLauncher::Protocol protocol, const std::string& host_name, int port, const FilePath& document_root, @@ -356,6 +358,8 @@ class HTTPTestServer : public BaseTestServer { : BaseTestServer(connection_attempts, connection_timeout), loop_(NULL) { } + virtual ~HTTPTestServer() {} + public: // Creates and returns a new HTTPTestServer. If |loop| is non-null, requests // are serviced on it, otherwise a new thread and message loop are created. @@ -560,11 +564,11 @@ class HTTPSTestServer : public HTTPTestServer { return test_server; } - virtual ~HTTPSTestServer() { - } - protected: std::wstring cert_path_; + + private: + virtual ~HTTPSTestServer() {} }; @@ -600,6 +604,9 @@ class FTPTestServer : public BaseTestServer { return true; } + + private: + ~FTPTestServer() {} }; #endif // NET_URL_REQUEST_URL_REQUEST_UNITTEST_H_ diff --git a/net/url_request/url_request_view_net_internals_job.h b/net/url_request/url_request_view_net_internals_job.h index 967d20c..9f23f96 100644 --- a/net/url_request/url_request_view_net_internals_job.h +++ b/net/url_request/url_request_view_net_internals_job.h @@ -27,6 +27,8 @@ class URLRequestViewNetInternalsJob : public URLRequestSimpleJob { std::string* data) const; private: + ~URLRequestViewNetInternalsJob() {} + URLFormat* url_format_; }; diff --git a/net/websockets/websocket_throttle.cc b/net/websockets/websocket_throttle.cc index d47d2e8..49bd923 100644 --- a/net/websockets/websocket_throttle.cc +++ b/net/websockets/websocket_throttle.cc @@ -131,11 +131,14 @@ class WebSocketThrottle::WebSocketState : public SocketStream::UserData { : callback_(callback) { DCHECK(callback_); } - virtual ~CompletionCallbackRunner() {} void Run() { callback_->Run(OK); } private: + friend class base::RefCountedThreadSafe<CompletionCallbackRunner>; + + virtual ~CompletionCallbackRunner() {} + CompletionCallback* callback_; DISALLOW_COPY_AND_ASSIGN(CompletionCallbackRunner); |