From 29ad53e466b5128c2f85d421fbddcdcd209c85cd Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Fri, 18 Mar 2022 14:46:48 +0100 Subject: [PATCH] Remove 'owned proxy' macros from proxy.h. This seems to be unused and also differs from other proxy implementations in that proxies are generally for reference counted interfaces whereas the 'owned proxy' macros are not. Bug: webrtc:13464, webrtc:12701 Change-Id: I2fc2c2f186bccab8388928d41610112c3b5f88ac Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256018 Reviewed-by: Harald Alvestrand Reviewed-by: Niels Moller Commit-Queue: Tomas Gunnarsson Cr-Commit-Position: refs/heads/main@{#36255} --- pc/proxy.h | 15 ------------- pc/proxy_unittest.cc | 50 -------------------------------------------- 2 files changed, 65 deletions(-) diff --git a/pc/proxy.h b/pc/proxy.h index e48f479183..feeb06338e 100644 --- a/pc/proxy.h +++ b/pc/proxy.h @@ -53,8 +53,6 @@ // The variant defined with BEGIN_PRIMARY_PROXY_MAP is unaware of // the secondary thread, and invokes all methods on the primary thread. // -// The variant defined with BEGIN_OWNED_PROXY_MAP does not use -// refcounting, and instead just takes ownership of the object being proxied. #ifndef PC_PROXY_H_ #define PC_PROXY_H_ @@ -309,19 +307,6 @@ class ConstMethodCall : public QueuedTask { primary_thread, secondary_thread, c); \ } -#define BEGIN_OWNED_PROXY_MAP(class_name) \ - PROXY_MAP_BOILERPLATE(class_name) \ - SECONDARY_PROXY_MAP_BOILERPLATE(class_name) \ - OWNED_PROXY_MAP_BOILERPLATE(class_name) \ - public: \ - static std::unique_ptr Create( \ - rtc::Thread* primary_thread, rtc::Thread* secondary_thread, \ - std::unique_ptr c) { \ - return std::unique_ptr( \ - new class_name##ProxyWithInternal(primary_thread, secondary_thread, \ - c.release())); \ - } - #define PROXY_PRIMARY_THREAD_DESTRUCTOR() \ private: \ rtc::Thread* destructor_thread() const { return primary_thread_; } \ diff --git a/pc/proxy_unittest.cc b/pc/proxy_unittest.cc index ef3d97eddc..ab02359d53 100644 --- a/pc/proxy_unittest.cc +++ b/pc/proxy_unittest.cc @@ -256,54 +256,4 @@ TEST_F(ProxyTest, WorkerMethod2) { EXPECT_EQ("Method2", fake_proxy_->Method2(arg1, arg2)); } -// Interface for testing OWNED_PROXY_MAP. -class FooInterface { - public: - virtual ~FooInterface() {} - virtual void Bar() = 0; -}; - -class Foo : public FooInterface { - public: - Foo() {} - MOCK_METHOD(void, Bar, (), (override)); -}; - -BEGIN_OWNED_PROXY_MAP(Foo) -PROXY_PRIMARY_THREAD_DESTRUCTOR() -PROXY_METHOD0(void, Bar) -END_PROXY_MAP(Foo) - -class OwnedProxyTest : public ::testing::Test { - public: - OwnedProxyTest() - : signaling_thread_(rtc::Thread::Create()), - worker_thread_(rtc::Thread::Create()), - foo_(new Foo()), - foo_proxy_(FooProxy::Create(signaling_thread_.get(), - worker_thread_.get(), - std::unique_ptr(foo_))) { - signaling_thread_->Start(); - worker_thread_->Start(); - } - - void CheckSignalingThread() { EXPECT_TRUE(signaling_thread_->IsCurrent()); } - void CheckWorkerThread() { EXPECT_TRUE(worker_thread_->IsCurrent()); } - - protected: - std::unique_ptr signaling_thread_; - std::unique_ptr worker_thread_; - Foo* foo_; // Owned by foo_proxy_, not this class. - std::unique_ptr foo_proxy_; -}; - -// Just tests that a method can be invoked using an "owned proxy" (as opposed -// to normal ref-counted version). -TEST_F(OwnedProxyTest, BasicTest) { - EXPECT_CALL(*foo_, Bar()) - .Times(Exactly(1)) - .WillOnce(InvokeWithoutArgs(this, &OwnedProxyTest::CheckSignalingThread)); - foo_proxy_->Bar(); -} - } // namespace webrtc