From 45de676a514b6e217b9dee01a02ca6acf45c91f7 Mon Sep 17 00:00:00 2001 From: "ttuttle@chromium.org" Date: Tue, 18 Mar 2014 23:52:02 +0000 Subject: Domain Reliability / Navigation Error Logging, part 1 This is just the logging portion of Domain Reliability; the uploading and configuration parts will come later. BUG= Review URL: https://codereview.chromium.org/132283009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257815 0039d316-1c4b-4281-b951-d872f2087c98 --- components/domain_reliability/monitor.h | 74 +++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 components/domain_reliability/monitor.h (limited to 'components/domain_reliability/monitor.h') diff --git a/components/domain_reliability/monitor.h b/components/domain_reliability/monitor.h new file mode 100644 index 0000000..5d189dc --- /dev/null +++ b/components/domain_reliability/monitor.h @@ -0,0 +1,74 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_ +#define COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_ + +#include + +#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/domain_reliability_export.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; +} + +namespace domain_reliability { + +// The top-level per-profile object that measures requests and hands off the +// measurements to the proper |DomainReliabilityContext|. Referenced by the +// |ChromeNetworkDelegate|, which calls the On* methods. +class DOMAIN_RELIABILITY_EXPORT DomainReliabilityMonitor { + public: + // NB: We don't take a URLRequestContextGetter because we already live on the + // I/O thread. + DomainReliabilityMonitor(); + explicit DomainReliabilityMonitor(scoped_ptr time); + ~DomainReliabilityMonitor(); + + // Should be called from the profile's NetworkDelegate on the corresponding + // events: + void OnBeforeRedirect(net::URLRequest* request); + void OnCompleted(net::URLRequest* request, bool started); + + // Creates a context for testing, adds it to the monitor, and returns a + // pointer to it. (The pointer is only valid until the MOnitor is destroyed.) + DomainReliabilityContext* AddContextForTesting( + scoped_ptr 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 time_; + std::map contexts_; + + DISALLOW_COPY_AND_ASSIGN(DomainReliabilityMonitor); +}; + +} // namespace domain_reliability + +#endif // COMPONENTS_DOMAIN_RELIABILITY_MONITOR_H_ -- cgit v1.1