forked from JumpingYang001/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AsyncResolverFactory interface and basic implementation.
The factory is plumbed down to P2PTransportChannel and will eventually be used to resolve hostnames. Uses of PacketSocketFacotry::CreateAsyncResolver will eventually be migrated to use this factory instead. Bug: webrtc:4165 Change-Id: I1c48b2ffb8649609a831eba291f67ce544bb10eb Reviewed-on: https://webrtc-review.googlesource.com/91300 Commit-Queue: Zach Stein <[email protected]> Reviewed-by: Emad Omara <[email protected]> Reviewed-by: Steve Anton <[email protected]> Reviewed-by: Qingsi Wang <[email protected]> Cr-Commit-Position: refs/heads/master@{#24176}
- Loading branch information
Zach Stein
authored and
Commit Bot
committed
Aug 2, 2018
1 parent
da2ec40
commit e20867f
Showing
15 changed files
with
166 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2018 The WebRTC Project Authors. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. An additional intellectual property rights grant can be found | ||
* in the file PATENTS. All contributing project authors may | ||
* be found in the AUTHORS file in the root of the source tree. | ||
*/ | ||
|
||
#ifndef API_ASYNCRESOLVERFACTORY_H_ | ||
#define API_ASYNCRESOLVERFACTORY_H_ | ||
|
||
#include "rtc_base/asyncresolverinterface.h" | ||
|
||
namespace webrtc { | ||
|
||
// An abstract factory for creating AsyncResolverInterfaces. This allows | ||
// client applications to provide WebRTC with their own mechanism for | ||
// performing DNS resolution. | ||
class AsyncResolverFactory { | ||
public: | ||
AsyncResolverFactory() = default; | ||
virtual ~AsyncResolverFactory() = default; | ||
|
||
// The returned object is responsible for deleting itself after address | ||
// resolution has completed. | ||
virtual rtc::AsyncResolverInterface* Create() = 0; | ||
}; | ||
|
||
} // namespace webrtc | ||
|
||
#endif // API_ASYNCRESOLVERFACTORY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright 2018 The WebRTC Project Authors. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. An additional intellectual property rights grant can be found | ||
* in the file PATENTS. All contributing project authors may | ||
* be found in the AUTHORS file in the root of the source tree. | ||
*/ | ||
|
||
#include "p2p/base/basicasyncresolverfactory.h" | ||
|
||
#include "rtc_base/nethelpers.h" | ||
|
||
namespace webrtc { | ||
|
||
rtc::AsyncResolverInterface* BasicAsyncResolverFactory::Create() { | ||
return new rtc::AsyncResolver(); | ||
} | ||
|
||
} // namespace webrtc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2018 The WebRTC Project Authors. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. An additional intellectual property rights grant can be found | ||
* in the file PATENTS. All contributing project authors may | ||
* be found in the AUTHORS file in the root of the source tree. | ||
*/ | ||
|
||
#ifndef P2P_BASE_BASICASYNCRESOLVERFACTORY_H_ | ||
#define P2P_BASE_BASICASYNCRESOLVERFACTORY_H_ | ||
|
||
#include "api/asyncresolverfactory.h" | ||
|
||
namespace webrtc { | ||
|
||
class BasicAsyncResolverFactory : public AsyncResolverFactory { | ||
public: | ||
rtc::AsyncResolverInterface* Create() override; | ||
}; | ||
|
||
} // namespace webrtc | ||
|
||
#endif // P2P_BASE_BASICASYNCRESOLVERFACTORY_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2018 The WebRTC Project Authors. All rights reserved. | ||
* | ||
* Use of this source code is governed by a BSD-style license | ||
* that can be found in the LICENSE file in the root of the source | ||
* tree. An additional intellectual property rights grant can be found | ||
* in the file PATENTS. All contributing project authors may | ||
* be found in the AUTHORS file in the root of the source tree. | ||
*/ | ||
|
||
#include "p2p/base/basicasyncresolverfactory.h" | ||
#include "rtc_base/gunit.h" | ||
|
||
namespace webrtc { | ||
|
||
class BasicAsyncResolverFactoryTest : public testing::Test, | ||
public sigslot::has_slots<> { | ||
public: | ||
void TestCreate() { | ||
BasicAsyncResolverFactory factory; | ||
rtc::AsyncResolverInterface* resolver = factory.Create(); | ||
ASSERT_TRUE(resolver); | ||
resolver->SignalDone.connect( | ||
this, &BasicAsyncResolverFactoryTest::SetAddressResolved); | ||
|
||
rtc::SocketAddress address("", 0); | ||
resolver->Start(address); | ||
ASSERT_TRUE_WAIT(address_resolved_, 10000 /*ms*/); | ||
} | ||
|
||
void SetAddressResolved(rtc::AsyncResolverInterface* resolver) { | ||
address_resolved_ = true; | ||
} | ||
|
||
private: | ||
bool address_resolved_ = false; | ||
}; | ||
|
||
// This test is primarily intended to let tools check that the created resolver | ||
// doesn't leak. | ||
TEST_F(BasicAsyncResolverFactoryTest, TestCreate) { | ||
TestCreate(); | ||
} | ||
|
||
} // namespace webrtc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters