Bug 1029478 - Remove dangerous public destructor of TransportFlow. r=abr

This commit is contained in:
Andrew McCreight 2014-07-31 10:05:58 -07:00
parent 944d92b89b
commit 6cc44b7ee7
2 changed files with 12 additions and 20 deletions

View File

@ -739,32 +739,32 @@ TEST_F(TransportTest, TestTransferIce) {
}
TEST(PushTests, LayerFail) {
TransportFlow flow;
mozilla::RefPtr<TransportFlow> flow = new TransportFlow();
nsresult rv;
bool destroyed1, destroyed2;
rv = flow.PushLayer(new TransportLayerDummy(true, &destroyed1));
rv = flow->PushLayer(new TransportLayerDummy(true, &destroyed1));
ASSERT_TRUE(NS_SUCCEEDED(rv));
rv = flow.PushLayer(new TransportLayerDummy(false, &destroyed2));
rv = flow->PushLayer(new TransportLayerDummy(false, &destroyed2));
ASSERT_TRUE(NS_FAILED(rv));
ASSERT_EQ(TransportLayer::TS_ERROR, flow.state());
ASSERT_EQ(TransportLayer::TS_ERROR, flow->state());
ASSERT_EQ(true, destroyed1);
ASSERT_EQ(true, destroyed2);
rv = flow.PushLayer(new TransportLayerDummy(true, &destroyed1));
rv = flow->PushLayer(new TransportLayerDummy(true, &destroyed1));
ASSERT_TRUE(NS_FAILED(rv));
ASSERT_EQ(true, destroyed1);
}
TEST(PushTests, LayersFail) {
TransportFlow flow;
mozilla::RefPtr<TransportFlow> flow = new TransportFlow();
nsresult rv;
bool destroyed1, destroyed2, destroyed3;
rv = flow.PushLayer(new TransportLayerDummy(true, &destroyed1));
rv = flow->PushLayer(new TransportLayerDummy(true, &destroyed1));
ASSERT_TRUE(NS_SUCCEEDED(rv));
nsAutoPtr<std::queue<TransportLayer *> > layers(
@ -773,10 +773,10 @@ TEST(PushTests, LayersFail) {
layers->push(new TransportLayerDummy(true, &destroyed2));
layers->push(new TransportLayerDummy(false, &destroyed3));
rv = flow.PushLayers(layers);
rv = flow->PushLayers(layers);
ASSERT_TRUE(NS_FAILED(rv));
ASSERT_EQ(TransportLayer::TS_ERROR, flow.state());
ASSERT_EQ(TransportLayer::TS_ERROR, flow->state());
ASSERT_EQ(true, destroyed1);
ASSERT_EQ(true, destroyed2);
ASSERT_EQ(true, destroyed3);
@ -784,7 +784,7 @@ TEST(PushTests, LayersFail) {
layers = new std::queue<TransportLayer *>();
layers->push(new TransportLayerDummy(true, &destroyed2));
layers->push(new TransportLayerDummy(true, &destroyed3));
rv = flow.PushLayers(layers);
rv = flow->PushLayers(layers);
ASSERT_TRUE(NS_FAILED(rv));
ASSERT_EQ(true, destroyed2);

View File

@ -61,8 +61,6 @@ class TransportFlow : public nsISupports,
state_(TransportLayer::TS_NONE),
layers_(new std::deque<TransportLayer *>) {}
~TransportFlow();
const std::string& id() const { return id_; }
// Layer management. Note PushLayer() is not thread protected, so
@ -102,6 +100,8 @@ class TransportFlow : public nsISupports,
NS_DECL_THREADSAFE_ISUPPORTS
private:
~TransportFlow();
DISALLOW_COPY_ASSIGN(TransportFlow);
// Check if we are on the right thread
@ -139,13 +139,5 @@ class TransportFlow : public nsISupports,
nsCOMPtr<nsIEventTarget> target_;
};
// Temporary whitelist for dangerous public destructors of reference-counted
// classes. See Bug 1029478 for this occurrence.
template<>
struct HasDangerousPublicDestructor<TransportFlow>
{
static const bool value = true;
};
} // close namespace
#endif