diff options
author | Yuri Wiitala <miu@chromium.org> | 2019-12-03 16:59:40 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-04 23:02:45 +0000 |
commit | 2b02e3287584ed6582dcced9ec08b3acdece37e3 (patch) | |
tree | 2cb24943406c6f04a9085f0d09318a208d317ba3 /cast/sender | |
parent | 75ea15d1ed9e7a689ef43bdfbc44059d1c7beeab (diff) | |
download | openscreen-2b02e3287584ed6582dcced9ec08b3acdece37e3.tar.gz |
Flatten namespace for platform/ code: opescreen::platform → openscreen
Removes the nested "platform" namespace in the platform code. Fixes all
typenames (fixing/removing using namespace statements, removing
unnecessary namespace qualifiers, etc.).
Also, removed the "using UdpSocketUniquePtr = std::unique_ptr<>" since
the alias is no longer necessary (the smart pointer no longer does
anything special at delete time).
Bug: openscreen:90
Change-Id: I0e8589282b4e42530c8c1c95115078d83e3e5f16
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1948540
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Reviewed-by: mark a. foltz <mfoltz@chromium.org>
Commit-Queue: Yuri Wiitala <miu@chromium.org>
Diffstat (limited to 'cast/sender')
-rw-r--r-- | cast/sender/channel/cast_auth_util.cc | 8 | ||||
-rw-r--r-- | cast/sender/channel/cast_auth_util_unittest.cc | 6 | ||||
-rw-r--r-- | cast/sender/channel/sender_socket_factory.cc | 6 | ||||
-rw-r--r-- | cast/sender/channel/sender_socket_factory.h | 55 |
4 files changed, 39 insertions, 36 deletions
diff --git a/cast/sender/channel/cast_auth_util.cc b/cast/sender/channel/cast_auth_util.cc index 9f706259..90d63f77 100644 --- a/cast/sender/channel/cast_auth_util.cc +++ b/cast/sender/channel/cast_auth_util.cc @@ -84,11 +84,11 @@ class CastNonce { OSP_CHECK_EQ( RAND_bytes(reinterpret_cast<uint8_t*>(&nonce_[0]), kNonceSizeInBytes), 1); - nonce_generation_time_ = openscreen::platform::GetWallTimeSinceUnixEpoch(); + nonce_generation_time_ = openscreen::GetWallTimeSinceUnixEpoch(); } void EnsureNonceTimely() { - if (openscreen::platform::GetWallTimeSinceUnixEpoch() > + if (openscreen::GetWallTimeSinceUnixEpoch() > (nonce_generation_time_ + std::chrono::hours(kNonceExpirationTimeInHours))) { GenerateNonce(); @@ -233,7 +233,7 @@ ErrorOr<CastDeviceCertPolicy> AuthenticateChallengeReply( } result = VerifyTLSCertificateValidity( - peer_cert, openscreen::platform::GetWallTimeSinceUnixEpoch()); + peer_cert, openscreen::GetWallTimeSinceUnixEpoch()); if (!result.ok()) { return result; } @@ -354,7 +354,7 @@ ErrorOr<CastDeviceCertPolicy> VerifyCredentials( bool enforce_sha256_checking) { certificate::DateTime now = {}; OSP_CHECK(certificate::DateTimeFromSeconds( - openscreen::platform::GetWallTimeSinceUnixEpoch().count(), &now)); + openscreen::GetWallTimeSinceUnixEpoch().count(), &now)); certificate::CRLPolicy policy = (enforce_revocation_checking) ? certificate::CRLPolicy::kCrlRequired : certificate::CRLPolicy::kCrlOptional; diff --git a/cast/sender/channel/cast_auth_util_unittest.cc b/cast/sender/channel/cast_auth_util_unittest.cc index 6ea4ea6a..b8a8e90c 100644 --- a/cast/sender/channel/cast_auth_util_unittest.cc +++ b/cast/sender/channel/cast_auth_util_unittest.cc @@ -157,7 +157,7 @@ TEST_F(CastAuthUtilTest, VerifySuccess) { AuthResponse auth_response = CreateAuthResponse(&signed_data, SHA256); certificate::DateTime now = {}; ASSERT_TRUE(certificate::DateTimeFromSeconds( - openscreen::platform::GetWallTimeSinceUnixEpoch().count(), &now)); + openscreen::GetWallTimeSinceUnixEpoch().count(), &now)); ErrorOr<CastDeviceCertPolicy> result = VerifyCredentialsForTest( auth_response, signed_data, certificate::CRLPolicy::kCrlOptional, nullptr, nullptr, now); @@ -210,7 +210,7 @@ TEST_F(CastAuthUtilTest, VerifyUnsupportedDigest) { AuthResponse auth_response = CreateAuthResponse(&signed_data, SHA1); certificate::DateTime now = {}; ASSERT_TRUE(certificate::DateTimeFromSeconds( - openscreen::platform::GetWallTimeSinceUnixEpoch().count(), &now)); + openscreen::GetWallTimeSinceUnixEpoch().count(), &now)); ErrorOr<CastDeviceCertPolicy> result = VerifyCredentialsForTest( auth_response, signed_data, certificate::CRLPolicy::kCrlOptional, nullptr, nullptr, now, true); @@ -223,7 +223,7 @@ TEST_F(CastAuthUtilTest, VerifyBackwardsCompatibleDigest) { AuthResponse auth_response = CreateAuthResponse(&signed_data, SHA1); certificate::DateTime now = {}; ASSERT_TRUE(certificate::DateTimeFromSeconds( - openscreen::platform::GetWallTimeSinceUnixEpoch().count(), &now)); + openscreen::GetWallTimeSinceUnixEpoch().count(), &now)); ErrorOr<CastDeviceCertPolicy> result = VerifyCredentialsForTest( auth_response, signed_data, certificate::CRLPolicy::kCrlOptional, nullptr, nullptr, now); diff --git a/cast/sender/channel/sender_socket_factory.cc b/cast/sender/channel/sender_socket_factory.cc index 3e75c977..b185113d 100644 --- a/cast/sender/channel/sender_socket_factory.cc +++ b/cast/sender/channel/sender_socket_factory.cc @@ -12,7 +12,11 @@ namespace cast { namespace channel { -using openscreen::platform::TlsConnectOptions; +using openscreen::Error; +using openscreen::IPEndpoint; +using openscreen::TlsConnection; +using openscreen::TlsConnectionFactory; +using openscreen::TlsConnectOptions; bool operator<(const std::unique_ptr<SenderSocketFactory::PendingAuth>& a, uint32_t b) { diff --git a/cast/sender/channel/sender_socket_factory.h b/cast/sender/channel/sender_socket_factory.h index 63998674..c58b369a 100644 --- a/cast/sender/channel/sender_socket_factory.h +++ b/cast/sender/channel/sender_socket_factory.h @@ -20,23 +20,18 @@ namespace cast { namespace channel { -using openscreen::Error; -using openscreen::IPEndpoint; -using openscreen::IPEndpointComparator; -using openscreen::platform::TlsConnection; -using openscreen::platform::TlsConnectionFactory; - -class SenderSocketFactory final : public TlsConnectionFactory::Client, - public CastSocket::Client { +class SenderSocketFactory final + : public openscreen::TlsConnectionFactory::Client, + public CastSocket::Client { public: class Client { public: virtual void OnConnected(SenderSocketFactory* factory, - const IPEndpoint& endpoint, + const openscreen::IPEndpoint& endpoint, std::unique_ptr<CastSocket> socket) = 0; virtual void OnError(SenderSocketFactory* factory, - const IPEndpoint& endpoint, - Error error) = 0; + const openscreen::IPEndpoint& endpoint, + openscreen::Error error) = 0; }; enum class DeviceMediaPolicy { @@ -48,35 +43,39 @@ class SenderSocketFactory final : public TlsConnectionFactory::Client, explicit SenderSocketFactory(Client* client); ~SenderSocketFactory(); - void set_factory(TlsConnectionFactory* factory) { + void set_factory(openscreen::TlsConnectionFactory* factory) { OSP_DCHECK(factory); factory_ = factory; } - void Connect(const IPEndpoint& endpoint, + void Connect(const openscreen::IPEndpoint& endpoint, DeviceMediaPolicy media_policy, CastSocket::Client* client); - // TlsConnectionFactory::Client overrides. - void OnAccepted(TlsConnectionFactory* factory, - std::vector<uint8_t> der_x509_peer_cert, - std::unique_ptr<TlsConnection> connection) override; - void OnConnected(TlsConnectionFactory* factory, - std::vector<uint8_t> der_x509_peer_cert, - std::unique_ptr<TlsConnection> connection) override; - void OnConnectionFailed(TlsConnectionFactory* factory, - const IPEndpoint& remote_address) override; - void OnError(TlsConnectionFactory* factory, Error error) override; + // openscreen::TlsConnectionFactory::Client overrides. + void OnAccepted( + openscreen::TlsConnectionFactory* factory, + std::vector<uint8_t> der_x509_peer_cert, + std::unique_ptr<openscreen::TlsConnection> connection) override; + void OnConnected( + openscreen::TlsConnectionFactory* factory, + std::vector<uint8_t> der_x509_peer_cert, + std::unique_ptr<openscreen::TlsConnection> connection) override; + void OnConnectionFailed( + openscreen::TlsConnectionFactory* factory, + const openscreen::IPEndpoint& remote_address) override; + void OnError(openscreen::TlsConnectionFactory* factory, + openscreen::Error error) override; private: struct PendingConnection { - IPEndpoint endpoint; + openscreen::IPEndpoint endpoint; DeviceMediaPolicy media_policy; CastSocket::Client* client; }; struct PendingAuth { - IPEndpoint endpoint; + openscreen::IPEndpoint endpoint; DeviceMediaPolicy media_policy; std::unique_ptr<CastSocket> socket; CastSocket::Client* client; @@ -88,14 +87,14 @@ class SenderSocketFactory final : public TlsConnectionFactory::Client, friend bool operator<(uint32_t a, const std::unique_ptr<PendingAuth>& b); std::vector<PendingConnection>::iterator FindPendingConnection( - const IPEndpoint& endpoint); + const openscreen::IPEndpoint& endpoint); // CastSocket::Client overrides. - void OnError(CastSocket* socket, Error error) override; + void OnError(CastSocket* socket, openscreen::Error error) override; void OnMessage(CastSocket* socket, CastMessage message) override; Client* const client_; - TlsConnectionFactory* factory_ = nullptr; + openscreen::TlsConnectionFactory* factory_ = nullptr; std::vector<PendingConnection> pending_connections_; std::vector<std::unique_ptr<PendingAuth>> pending_auth_; }; |