Files
platform-external-webrtc/webrtc/base/autodetectproxy.h
kwiberg@webrtc.org 67186fe00c Fix clang style warnings in webrtc/base
Mostly this consists of marking functions with override when
applicable, and moving function bodies from .h to .cc files.

Not inlining virtual functions with simple bodies such as

  { return false; }

strikes me as probably losing more in readability than we gain in
binary size and compilation time, but I guess it's just like any other
case where enabling a generally good warning forces us to write
slightly worse code in a couple of places.

BUG=163
R=kjellander@webrtc.org, tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/47429004

Cr-Commit-Position: refs/heads/master@{#8656}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8656 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-03-09 22:24:25 +00:00

90 lines
2.5 KiB
C++

/*
* Copyright 2004 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 WEBRTC_BASE_AUTODETECTPROXY_H_
#define WEBRTC_BASE_AUTODETECTPROXY_H_
#include <string>
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/cryptstring.h"
#include "webrtc/base/proxydetect.h"
#include "webrtc/base/proxyinfo.h"
#include "webrtc/base/signalthread.h"
namespace rtc {
///////////////////////////////////////////////////////////////////////////////
// AutoDetectProxy
///////////////////////////////////////////////////////////////////////////////
class AsyncResolverInterface;
class AsyncSocket;
class AutoDetectProxy : public SignalThread {
public:
explicit AutoDetectProxy(const std::string& user_agent);
const ProxyInfo& proxy() const { return proxy_; }
void set_server_url(const std::string& url) {
server_url_ = url;
}
void set_proxy(const SocketAddress& proxy) {
proxy_.type = PROXY_UNKNOWN;
proxy_.address = proxy;
}
void set_auth_info(bool use_auth, const std::string& username,
const CryptString& password) {
if (use_auth) {
proxy_.username = username;
proxy_.password = password;
}
}
// Default implementation of GetProxySettingsForUrl. Override for special
// implementation.
virtual bool GetProxyForUrl(const char* agent,
const char* url,
rtc::ProxyInfo* proxy);
enum { MSG_TIMEOUT = SignalThread::ST_MSG_FIRST_AVAILABLE,
MSG_UNRESOLVABLE,
ADP_MSG_FIRST_AVAILABLE};
protected:
~AutoDetectProxy() override;
// SignalThread Interface
void DoWork() override;
void OnMessage(Message* msg) override;
void Next();
void Complete(ProxyType type);
void OnConnectEvent(AsyncSocket * socket);
void OnReadEvent(AsyncSocket * socket);
void OnCloseEvent(AsyncSocket * socket, int error);
void OnResolveResult(AsyncResolverInterface* resolver);
bool DoConnect();
private:
std::string agent_;
std::string server_url_;
ProxyInfo proxy_;
AsyncResolverInterface* resolver_;
AsyncSocket* socket_;
int next_;
DISALLOW_IMPLICIT_CONSTRUCTORS(AutoDetectProxy);
};
} // namespace rtc
#endif // WEBRTC_BASE_AUTODETECTPROXY_H_