#ifndef COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_
#define COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_
#include <map>
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "components/domain_reliability/beacon.h"
#include "components/domain_reliability/config.h"
#include "components/domain_reliability/context.h"
#include "components/domain_reliability/dispatcher.h"
#include "components/domain_reliability/domain_reliability_export.h"
#include "components/domain_reliability/scheduler.h"
#include "components/domain_reliability/uploader.h"
#include "components/domain_reliability/util.h"
#include "net/base/host_port_pair.h"
#include "net/base/load_timing_info.h"
#include "net/url_request/url_request_status.h"
namespace net {
class URLRequest;
class URLRequestContext;
class URLRequestContextGetter;
}
namespace domain_reliability {
class DOMAIN_RELIABILITY_EXPORT DomainReliabilityMonitor {
public:
explicit DomainReliabilityMonitor(
net::URLRequestContext* url_request_context);
DomainReliabilityMonitor(
net::URLRequestContext* url_request_context,
scoped_ptr<MockableTime> time);
~DomainReliabilityMonitor();
void OnBeforeRedirect(net::URLRequest* request);
void OnCompleted(net::URLRequest* request, bool started);
DomainReliabilityContext* AddContextForTesting(
scoped_ptr<const DomainReliabilityConfig> config);
private:
friend class DomainReliabilityMonitorTest;
struct DOMAIN_RELIABILITY_EXPORT RequestInfo {
RequestInfo();
RequestInfo(const net::URLRequest& request);
~RequestInfo();
GURL url;
net::URLRequestStatus status;
int response_code;
net::HostPortPair socket_address;
net::LoadTimingInfo load_timing_info;
bool was_cached;
};
void OnRequestLegComplete(const RequestInfo& info);
scoped_ptr<MockableTime> time_;
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
DomainReliabilityScheduler::Params scheduler_params_;
DomainReliabilityDispatcher dispatcher_;
scoped_ptr<DomainReliabilityUploader> uploader_;
std::map<std::string, DomainReliabilityContext*> contexts_;
DISALLOW_COPY_AND_ASSIGN(DomainReliabilityMonitor);
};
}
#endif