diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 18:12:55 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 18:12:55 +0000 |
commit | 13f383ff5fc8ff095501794d4ce758f0067ff9b5 (patch) | |
tree | ceb1d08f38759bf8805ede009924a990bae496e5 /ipc | |
parent | f61f331824ac9c98684a886be0d918aefe69d3ce (diff) | |
download | chromium_src-13f383ff5fc8ff095501794d4ce758f0067ff9b5.zip chromium_src-13f383ff5fc8ff095501794d4ce758f0067ff9b5.tar.gz chromium_src-13f383ff5fc8ff095501794d4ce758f0067ff9b5.tar.bz2 |
Assert that thread-safe reference counting is used with
cross-thread NewRunnableMethod.
This assertion caught such an error in VisitedLinkMaster!
My approach, modify RunnableMethodTraits<T> to assert that
when ReleaseCallee happens on a different thread from
RetainCallee that the type supports thread-safe reference
counting. I do this by adding a static method to both
RefCounted<T> and RefCountedThreadSafe<T>.
This results in a little ugliness in cases where people
implement AddRef and Release by hand (to make the no-ops).
There may be a nicer way to deal with those few cases.
R=brettw
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/251012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/ipc_logging.cc | 4 | ||||
-rw-r--r-- | ipc/ipc_sync_channel_unittest.cc | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/ipc/ipc_logging.cc b/ipc/ipc_logging.cc index 9d4f4bb..e1684d7 100644 --- a/ipc/ipc_logging.cc +++ b/ipc/ipc_logging.cc @@ -36,8 +36,8 @@ using base::Time; // special retention program. template <> struct RunnableMethodTraits<IPC::Logging> { - static void RetainCallee(IPC::Logging*) {} - static void ReleaseCallee(IPC::Logging*) {} + void RetainCallee(IPC::Logging*) {} + void ReleaseCallee(IPC::Logging*) {} }; namespace IPC { diff --git a/ipc/ipc_sync_channel_unittest.cc b/ipc/ipc_sync_channel_unittest.cc index f20f788..f6bf10e 100644 --- a/ipc/ipc_sync_channel_unittest.cc +++ b/ipc/ipc_sync_channel_unittest.cc @@ -66,6 +66,7 @@ class Worker : public Channel::Listener, public Message::Sender { } void AddRef() { } void Release() { } + static bool ImplementsThreadSafeReferenceCounting() { return true; } bool Send(Message* msg) { return channel_->Send(msg); } bool SendWithTimeout(Message* msg, int timeout_ms) { return channel_->SendWithTimeout(msg, timeout_ms); |