diff options
29 files changed, 59 insertions, 54 deletions
diff --git a/base/message_loop.h b/base/message_loop.h index 94e0096..37e4b81 100644 --- a/base/message_loop.h +++ b/base/message_loop.h @@ -146,7 +146,7 @@ class MessageLoop : public base::MessagePump::Delegate { // as the thread that calls PostDelayedTask(FROM_HERE, ), then T MUST inherit // from RefCountedThreadSafe<T>! template <class T> - void DeleteSoon(const tracked_objects::Location& from_here, T* object) { + void DeleteSoon(const tracked_objects::Location& from_here, const T* object) { PostNonNestableTask(from_here, new DeleteTask<T>(object)); } @@ -161,7 +161,8 @@ class MessageLoop : public base::MessagePump::Delegate { // PostDelayedTask(FROM_HERE, ), then T MUST inherit from // RefCountedThreadSafe<T>! template <class T> - void ReleaseSoon(const tracked_objects::Location& from_here, T* object) { + void ReleaseSoon(const tracked_objects::Location& from_here, + const T* object) { PostNonNestableTask(from_here, new ReleaseTask<T>(object)); } diff --git a/base/message_loop_proxy.cc b/base/message_loop_proxy.cc index bc7088d..a38db39 100644 --- a/base/message_loop_proxy.cc +++ b/base/message_loop_proxy.cc @@ -12,7 +12,7 @@ MessageLoopProxy::MessageLoopProxy() { MessageLoopProxy::~MessageLoopProxy() { } -void MessageLoopProxy::OnDestruct() { +void MessageLoopProxy::OnDestruct() const { delete this; } diff --git a/base/message_loop_proxy.h b/base/message_loop_proxy.h index 5d6708e..4d38155 100644 --- a/base/message_loop_proxy.h +++ b/base/message_loop_proxy.h @@ -64,11 +64,11 @@ class MessageLoopProxy // Called when the proxy is about to be deleted. Subclasses can override this // to provide deletion on specific threads. - virtual void OnDestruct(); + virtual void OnDestruct() const; }; struct MessageLoopProxyTraits { - static void Destruct(MessageLoopProxy* proxy) { + static void Destruct(const MessageLoopProxy* proxy) { proxy->OnDestruct(); } }; diff --git a/base/message_loop_proxy_impl.cc b/base/message_loop_proxy_impl.cc index 983a406..761cc71 100644 --- a/base/message_loop_proxy_impl.cc +++ b/base/message_loop_proxy_impl.cc @@ -71,7 +71,7 @@ bool MessageLoopProxyImpl::PostTaskHelper( return ret; } -void MessageLoopProxyImpl::OnDestruct() { +void MessageLoopProxyImpl::OnDestruct() const { bool delete_later = false; { AutoLock lock(message_loop_lock_); diff --git a/base/message_loop_proxy_impl.h b/base/message_loop_proxy_impl.h index b93bb64..87ae70a 100644 --- a/base/message_loop_proxy_impl.h +++ b/base/message_loop_proxy_impl.h @@ -39,7 +39,7 @@ class MessageLoopProxyImpl : public MessageLoopProxy, protected: // Override OnDestruct so that we can delete the object on the target message // loop if it still exists. - virtual void OnDestruct(); + virtual void OnDestruct() const; private: MessageLoopProxyImpl(); @@ -50,7 +50,7 @@ class MessageLoopProxyImpl : public MessageLoopProxy, friend class MessageLoopProxy; // The lock that protects access to target_message_loop_. - Lock message_loop_lock_; + mutable Lock message_loop_lock_; MessageLoop* target_message_loop_; DISALLOW_COPY_AND_ASSIGN(MessageLoopProxyImpl); diff --git a/base/message_loop_proxy_impl_unittest.cc b/base/message_loop_proxy_impl_unittest.cc index a3cb800..8d8ef4e 100644 --- a/base/message_loop_proxy_impl_unittest.cc +++ b/base/message_loop_proxy_impl_unittest.cc @@ -12,20 +12,20 @@ class MessageLoopProxyImplTest : public testing::Test { public: - void Release() { + void Release() const { AssertOnIOThread(); Quit(); } - void Quit() { + void Quit() const { loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); } - void AssertOnIOThread() { + void AssertOnIOThread() const { ASSERT_TRUE(io_thread_->message_loop_proxy()->BelongsToCurrentThread()); } - void AssertOnFileThread() { + void AssertOnFileThread() const { ASSERT_TRUE(file_thread_->message_loop_proxy()->BelongsToCurrentThread()); } @@ -79,7 +79,7 @@ class MessageLoopProxyImplTest : public testing::Test { scoped_ptr<base::Thread> file_thread_; private: - MessageLoop loop_; + mutable MessageLoop loop_; }; diff --git a/base/ref_counted.h b/base/ref_counted.h index 2cc4029..9c84efa 100644 --- a/base/ref_counted.h +++ b/base/ref_counted.h @@ -106,7 +106,7 @@ template <class T, typename Traits> class RefCountedThreadSafe; // count reaches 0. Overload to delete it on a different thread etc. template<typename T> struct DefaultRefCountedThreadSafeTraits { - static void Destruct(T* x) { + static void Destruct(const T* x) { // Delete through RefCountedThreadSafe to make child classes only need to be // friend with RefCountedThreadSafe instead of this struct, which is an // implementation detail. @@ -133,19 +133,19 @@ class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase { RefCountedThreadSafe() { } ~RefCountedThreadSafe() { } - void AddRef() { + void AddRef() const { subtle::RefCountedThreadSafeBase::AddRef(); } - void Release() { + void Release() const { if (subtle::RefCountedThreadSafeBase::Release()) { - Traits::Destruct(static_cast<T*>(this)); + Traits::Destruct(static_cast<const T*>(this)); } } private: friend struct DefaultRefCountedThreadSafeTraits<T>; - static void DeleteInternal(T* x) { delete x; } + static void DeleteInternal(const T* x) { delete x; } DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe); }; diff --git a/base/task.h b/base/task.h index e6ac33c..28d15fc 100644 --- a/base/task.h +++ b/base/task.h @@ -180,7 +180,7 @@ class ScopedRunnableMethodFactory { template<class T> class DeleteTask : public CancelableTask { public: - explicit DeleteTask(T* obj) : obj_(obj) { + explicit DeleteTask(const T* obj) : obj_(obj) { } virtual void Run() { delete obj_; @@ -190,14 +190,14 @@ class DeleteTask : public CancelableTask { } private: - T* obj_; + const T* obj_; }; // Task to Release() an object template<class T> class ReleaseTask : public CancelableTask { public: - explicit ReleaseTask(T* obj) : obj_(obj) { + explicit ReleaseTask(const T* obj) : obj_(obj) { } virtual void Run() { if (obj_) @@ -208,7 +208,7 @@ class ReleaseTask : public CancelableTask { } private: - T* obj_; + const T* obj_; }; // RunnableMethodTraits -------------------------------------------------------- diff --git a/chrome/browser/browser_thread.h b/chrome/browser/browser_thread.h index c034851..f6a022e 100644 --- a/chrome/browser/browser_thread.h +++ b/chrome/browser/browser_thread.h @@ -109,7 +109,7 @@ class BrowserThread : public base::Thread { template <class T> static bool DeleteSoon(ID identifier, const tracked_objects::Location& from_here, - T* object) { + const T* object) { return PostNonNestableTask( identifier, from_here, new DeleteTask<T>(object)); } @@ -117,7 +117,7 @@ class BrowserThread : public base::Thread { template <class T> static bool ReleaseSoon(ID identifier, const tracked_objects::Location& from_here, - T* object) { + const T* object) { return PostNonNestableTask( identifier, from_here, new ReleaseTask<T>(object)); } @@ -154,7 +154,7 @@ class BrowserThread : public base::Thread { template<ID thread> struct DeleteOnThread { template<typename T> - static void Destruct(T* x) { + static void Destruct(const T* x) { if (CurrentlyOn(thread)) { delete x; } else { diff --git a/chrome/browser/browser_thread_unittest.cc b/chrome/browser/browser_thread_unittest.cc index d2c19d8..948709a 100644 --- a/chrome/browser/browser_thread_unittest.cc +++ b/chrome/browser/browser_thread_unittest.cc @@ -11,7 +11,7 @@ class BrowserThreadTest : public testing::Test { public: - void Release() { + void Release() const { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask); } @@ -77,7 +77,9 @@ class BrowserThreadTest : public testing::Test { private: scoped_ptr<BrowserThread> ui_thread_; scoped_ptr<BrowserThread> file_thread_; - MessageLoop loop_; + // It's kind of ugly to make this mutable - solely so we can post the Quit + // Task from Release(). This should be fixed. + mutable MessageLoop loop_; }; TEST_F(BrowserThreadTest, PostTask) { diff --git a/chrome/browser/chrome_plugin_unittest.cc b/chrome/browser/chrome_plugin_unittest.cc index 38b4bd5..a7eee5b 100644 --- a/chrome/browser/chrome_plugin_unittest.cc +++ b/chrome/browser/chrome_plugin_unittest.cc @@ -33,7 +33,7 @@ class TestURLRequestContextGetter : public URLRequestContextGetter { context_ = new TestURLRequestContext(); return context_; } - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc index e59e00e..0abe211 100644 --- a/chrome/browser/net/chrome_url_request_context.cc +++ b/chrome/browser/net/chrome_url_request_context.cc @@ -609,7 +609,7 @@ net::CookieStore* ChromeURLRequestContextGetter::GetCookieStore() { } scoped_refptr<base::MessageLoopProxy> -ChromeURLRequestContextGetter::GetIOMessageLoopProxy() { +ChromeURLRequestContextGetter::GetIOMessageLoopProxy() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/chrome/browser/net/chrome_url_request_context.h b/chrome/browser/net/chrome_url_request_context.h index a580282..43b1b21 100644 --- a/chrome/browser/net/chrome_url_request_context.h +++ b/chrome/browser/net/chrome_url_request_context.h @@ -240,7 +240,7 @@ class ChromeURLRequestContextGetter : public URLRequestContextGetter, // URLRequestContextGetter implementation. virtual URLRequestContext* GetURLRequestContext(); virtual net::CookieStore* GetCookieStore(); - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy(); + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; // Convenience overload of GetURLRequestContext() that returns a // ChromeURLRequestContext* rather than a URLRequestContext*. diff --git a/chrome/browser/renderer_host/pepper_file_message_filter.cc b/chrome/browser/renderer_host/pepper_file_message_filter.cc index e7b331b..cbd09af 100644 --- a/chrome/browser/renderer_host/pepper_file_message_filter.cc +++ b/chrome/browser/renderer_host/pepper_file_message_filter.cc @@ -104,7 +104,7 @@ void PepperFileMessageFilter::OnMessageReceivedFileThread( } } -void PepperFileMessageFilter::OnDestruct() { +void PepperFileMessageFilter::OnDestruct() const { BrowserThread::DeleteOnIOThread::Destruct(this); } diff --git a/chrome/browser/renderer_host/pepper_file_message_filter.h b/chrome/browser/renderer_host/pepper_file_message_filter.h index 37e57f6..003d258 100644 --- a/chrome/browser/renderer_host/pepper_file_message_filter.h +++ b/chrome/browser/renderer_host/pepper_file_message_filter.h @@ -37,7 +37,7 @@ class PepperFileMessageFilter : public IPC::ChannelProxy::MessageFilter { virtual void OnChannelError(); virtual void OnChannelClosing(); virtual bool OnMessageReceived(const IPC::Message& message); - virtual void OnDestruct(); + virtual void OnDestruct() const; // Called from the FILE thread. void Send(IPC::Message* message); diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index a5f4f5e..5c853e9 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -524,7 +524,7 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) { return handled; } -void ResourceMessageFilter::OnDestruct() { +void ResourceMessageFilter::OnDestruct() const { BrowserThread::DeleteOnIOThread::Destruct(this); } diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index fa1932e..399a122 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -107,7 +107,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, virtual void OnChannelError(); virtual void OnChannelClosing(); virtual bool OnMessageReceived(const IPC::Message& message); - virtual void OnDestruct(); + virtual void OnDestruct() const; // ResourceDispatcherHost::Receiver methods: virtual bool Send(IPC::Message* message); diff --git a/chrome/browser/sync/glue/http_bridge.cc b/chrome/browser/sync/glue/http_bridge.cc index 3adaaf0..044cc75 100644 --- a/chrome/browser/sync/glue/http_bridge.cc +++ b/chrome/browser/sync/glue/http_bridge.cc @@ -44,7 +44,7 @@ URLRequestContext* HttpBridge::RequestContextGetter::GetURLRequestContext() { } scoped_refptr<base::MessageLoopProxy> -HttpBridge::RequestContextGetter::GetIOMessageLoopProxy() { +HttpBridge::RequestContextGetter::GetIOMessageLoopProxy() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/chrome/browser/sync/glue/http_bridge.h b/chrome/browser/sync/glue/http_bridge.h index 1951ce5..5b9d4b2 100644 --- a/chrome/browser/sync/glue/http_bridge.h +++ b/chrome/browser/sync/glue/http_bridge.h @@ -85,7 +85,7 @@ class HttpBridge : public base::RefCountedThreadSafe<HttpBridge>, // URLRequestContextGetter implementation. virtual URLRequestContext* GetURLRequestContext(); - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy(); + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; private: ~RequestContextGetter() {} diff --git a/chrome/browser/sync/glue/http_bridge_unittest.cc b/chrome/browser/sync/glue/http_bridge_unittest.cc index dc4948d..eac7c32 100644 --- a/chrome/browser/sync/glue/http_bridge_unittest.cc +++ b/chrome/browser/sync/glue/http_bridge_unittest.cc @@ -26,7 +26,7 @@ class TestURLRequestContextGetter : public URLRequestContextGetter { context_ = new TestURLRequestContext; return context_; } - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/chrome/common/net/url_fetcher_unittest.cc b/chrome/common/net/url_fetcher_unittest.cc index 3fc8469..512f38b 100644 --- a/chrome/common/net/url_fetcher_unittest.cc +++ b/chrome/common/net/url_fetcher_unittest.cc @@ -34,7 +34,7 @@ class TestURLRequestContextGetter : public URLRequestContextGetter { context_ = new TestURLRequestContext(); return context_; } - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { return io_message_loop_proxy_; } @@ -199,7 +199,7 @@ class CancelTestURLRequestContextGetter : public URLRequestContextGetter { } return context_; } - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { return io_message_loop_proxy_; } void WaitForContextCreation() { diff --git a/chrome/common/net/url_request_context_getter.cc b/chrome/common/net/url_request_context_getter.cc index 57feb0e..08b5368 100644 --- a/chrome/common/net/url_request_context_getter.cc +++ b/chrome/common/net/url_request_context_getter.cc @@ -14,7 +14,7 @@ URLRequestContextGetter::URLRequestContextGetter() : is_main_(false) {} URLRequestContextGetter::~URLRequestContextGetter() {} -void URLRequestContextGetter::OnDestruct() { +void URLRequestContextGetter::OnDestruct() const { scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy = GetIOMessageLoopProxy(); DCHECK(io_message_loop_proxy); diff --git a/chrome/common/net/url_request_context_getter.h b/chrome/common/net/url_request_context_getter.h index 2b6ea82..ade5e1a 100644 --- a/chrome/common/net/url_request_context_getter.h +++ b/chrome/common/net/url_request_context_getter.h @@ -33,7 +33,8 @@ class URLRequestContextGetter // Returns a MessageLoopProxy corresponding to the thread on which the // request IO happens (the thread on which the returned URLRequestContext // may be used). - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() = 0; + virtual scoped_refptr<base::MessageLoopProxy> + GetIOMessageLoopProxy() const = 0; // Controls whether or not the URLRequestContextGetter considers itself to be // the the "main" URLRequestContextGetter. Note that each Profile will have a @@ -44,7 +45,7 @@ class URLRequestContextGetter void set_is_main(bool is_main) { is_main_ = is_main; } protected: - friend class DeleteTask<URLRequestContextGetter>; + friend class DeleteTask<const URLRequestContextGetter>; friend struct URLRequestContextGetterTraits; URLRequestContextGetter(); @@ -55,7 +56,7 @@ class URLRequestContextGetter private: // OnDestruct is meant to ensure deletion on the thread on which the request // IO happens. - void OnDestruct(); + void OnDestruct() const; // Indicates whether or not this is the default URLRequestContextGetter for // the main Profile. @@ -63,7 +64,7 @@ class URLRequestContextGetter }; struct URLRequestContextGetterTraits { - static void Destruct(URLRequestContextGetter* context_getter) { + static void Destruct(const URLRequestContextGetter* context_getter) { context_getter->OnDestruct(); } }; diff --git a/chrome/service/net/service_url_request_context.cc b/chrome/service/net/service_url_request_context.cc index 3f264a4..8e5ae02 100644 --- a/chrome/service/net/service_url_request_context.cc +++ b/chrome/service/net/service_url_request_context.cc @@ -64,14 +64,15 @@ ServiceURLRequestContextGetter::ServiceURLRequestContextGetter() g_service_process->io_thread()->message_loop_proxy()) { } -URLRequestContext* ServiceURLRequestContextGetter::GetURLRequestContext() { +URLRequestContext* +ServiceURLRequestContextGetter::GetURLRequestContext() { if (!url_request_context_) url_request_context_ = new ServiceURLRequestContext(); return url_request_context_; } scoped_refptr<base::MessageLoopProxy> -ServiceURLRequestContextGetter::GetIOMessageLoopProxy() { +ServiceURLRequestContextGetter::GetIOMessageLoopProxy() const { return io_message_loop_proxy_; } diff --git a/chrome/service/net/service_url_request_context.h b/chrome/service/net/service_url_request_context.h index 379371f..46a8b2a 100644 --- a/chrome/service/net/service_url_request_context.h +++ b/chrome/service/net/service_url_request_context.h @@ -59,7 +59,7 @@ class ServiceURLRequestContextGetter : public URLRequestContextGetter { ServiceURLRequestContextGetter(); virtual URLRequestContext* GetURLRequestContext(); - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy(); + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; void set_user_agent(const std::string& ua) { user_agent_ = ua; diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index 4de6143..829fcc9 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -122,7 +122,7 @@ class TestURLRequestContextGetter : public URLRequestContextGetter { context_ = new TestURLRequestContext(); return context_.get(); } - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } @@ -147,7 +147,7 @@ class TestExtensionURLRequestContextGetter : public URLRequestContextGetter { context_ = new TestExtensionURLRequestContext(); return context_.get(); } - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); } diff --git a/chrome_frame/metrics_service.cc b/chrome_frame/metrics_service.cc index 659cd36..cb30b94 100644 --- a/chrome_frame/metrics_service.cc +++ b/chrome_frame/metrics_service.cc @@ -206,7 +206,7 @@ class ChromeFrameUploadRequestContextGetter : public URLRequestContextGetter { return context_; } - virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() { + virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { if (!io_message_loop_proxy_.get()) { io_message_loop_proxy_ = base::MessageLoopProxy::CreateForCurrentThread(); } @@ -219,7 +219,7 @@ class ChromeFrameUploadRequestContextGetter : public URLRequestContextGetter { } scoped_refptr<URLRequestContext> context_; - scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; + mutable scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; MessageLoop* io_loop_; }; diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index feca4eb..dcc66aad 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -54,7 +54,7 @@ bool ChannelProxy::MessageFilter::OnMessageReceived(const Message& message) { return false; } -void ChannelProxy::MessageFilter::OnDestruct() { +void ChannelProxy::MessageFilter::OnDestruct() const { delete this; } diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h index 1ce9986..53a39b4 100644 --- a/ipc/ipc_channel_proxy.h +++ b/ipc/ipc_channel_proxy.h @@ -87,11 +87,11 @@ class ChannelProxy : public Message::Sender { // Called when the message filter is about to be deleted. This gives // derived classes the option of controlling which thread they're deleted // on etc. - virtual void OnDestruct(); + virtual void OnDestruct() const; }; struct MessageFilterTraits { - static void Destruct(MessageFilter* filter) { + static void Destruct(const MessageFilter* filter) { filter->OnDestruct(); } }; |