#ifndef CHROMECAST_MEDIA_AUDIO_MIXER_SERVICE_MIXER_CONNECTION_H_
#define CHROMECAST_MEDIA_AUDIO_MIXER_SERVICE_MIXER_CONNECTION_H_
#include <memory>
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/timer/timer.h"
namespace net {
class StreamSocket;
}
namespace chromecast {
namespace media {
namespace mixer_service {
class MixerSocket;
class MixerConnection {
public:
MixerConnection();
MixerConnection(const MixerConnection&) = delete;
MixerConnection& operator=(const MixerConnection&) = delete;
virtual ~MixerConnection();
void Connect();
protected:
virtual void OnConnected(std::unique_ptr<MixerSocket> socket) = 0;
private:
void ConnectCallback(int result);
void ConnectTimeout();
std::unique_ptr<net::StreamSocket> connecting_socket_;
base::OneShotTimer connection_timeout_;
bool log_connection_failure_ = true;
bool log_timeout_ = true;
base::WeakPtrFactory<MixerConnection> weak_factory_;
};
}
}
}
#endif