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
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS
index cf73450..294b410 100644
--- a/chrome/browser/DEPS
+++ b/chrome/browser/DEPS
@@ -14,6 +14,7 @@
"+components/autofill/core/common",
"+components/breakpad",
"+components/dom_distiller",
+ "+components/domain_reliability",
"+components/keyed_service",
"+components/language_usage_metrics",
"+components/nacl/browser",
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 6c99b19..d25f629b2 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -34,6 +34,7 @@
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "components/domain_reliability/monitor.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
@@ -347,6 +348,7 @@
enable_do_not_track_(NULL),
force_google_safe_search_(NULL),
url_blacklist_manager_(NULL),
+ domain_reliability_monitor_(NULL),
received_content_length_(0),
original_content_length_(0) {
DCHECK(event_router);
@@ -518,6 +520,8 @@
void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
const GURL& new_location) {
+ if (domain_reliability_monitor_)
+ domain_reliability_monitor_->OnBeforeRedirect(request);
ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRedirect(
profile_, extension_info_map_.get(), request, new_location);
}
@@ -612,6 +616,8 @@
} else {
NOTREACHED();
}
+ if (domain_reliability_monitor_)
+ domain_reliability_monitor_->OnCompleted(request, started);
ForwardProxyErrors(request, event_router_.get(), profile_);
ForwardRequestStatus(REQUEST_DONE, request, profile_);
diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h
index f6c8361..6adf283 100644
--- a/chrome/browser/net/chrome_network_delegate.h
+++ b/chrome/browser/net/chrome_network_delegate.h
@@ -32,6 +32,10 @@
class Predictor;
}
+namespace domain_reliability {
+class DomainReliabilityMonitor;
+} // namespace domain_reliability
+
namespace extensions {
class EventRouterForwarder;
class InfoMap;
@@ -96,6 +100,12 @@
force_google_safe_search_ = force_google_safe_search;
}
+ void set_domain_reliability_monitor(
+ domain_reliability::DomainReliabilityMonitor*
+ domain_reliability_monitor) {
+ domain_reliability_monitor_ = domain_reliability_monitor;
+ }
+
// Adds the Client Hints header to HTTP requests.
void SetEnableClientHints();
@@ -194,6 +204,7 @@
// Weak, owned by our owner.
const policy::URLBlacklistManager* url_blacklist_manager_;
+ domain_reliability::DomainReliabilityMonitor* domain_reliability_monitor_;
// When true, allow access to all file:// URLs.
static bool g_allow_file_access_;
diff --git a/chrome/browser/profiles/profile_impl_io_data.cc b/chrome/browser/profiles/profile_impl_io_data.cc
index 9649f41..dd51909 100644
--- a/chrome/browser/profiles/profile_impl_io_data.cc
+++ b/chrome/browser/profiles/profile_impl_io_data.cc
@@ -33,6 +33,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "components/domain_reliability/monitor.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cookie_store_factory.h"
#include "content/public/browser/notification_service.h"
@@ -80,6 +81,15 @@
#endif
}
+bool IsDomainReliabilityMonitoringEnabled() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kDisableDomainReliability))
+ return false;
+ if (command_line->HasSwitch(switches::kEnableDomainReliability))
+ return true;
+ return base::FieldTrialList::FindFullName("DomRel-Enable") == "enable";
+}
+
} // namespace
using content::BrowserThread;
@@ -495,6 +505,13 @@
media_request_context_.reset(InitializeMediaRequestContext(main_context,
details));
+ if (IsDomainReliabilityMonitoringEnabled()) {
+ domain_reliability_monitor_.reset(
+ new domain_reliability::DomainReliabilityMonitor());
+ network_delegate()->set_domain_reliability_monitor(
+ domain_reliability_monitor_.get());
+ }
+
lazy_params_.reset();
}
diff --git a/chrome/browser/profiles/profile_impl_io_data.h b/chrome/browser/profiles/profile_impl_io_data.h
index 94af627..e03754093 100644
--- a/chrome/browser/profiles/profile_impl_io_data.h
+++ b/chrome/browser/profiles/profile_impl_io_data.h
@@ -22,6 +22,10 @@
class CookieCryptoDelegate;
} // namespace content
+namespace domain_reliability {
+class DomainReliabilityMonitor;
+} // namespace domain_reliability
+
namespace net {
class FtpTransactionFactory;
class HttpServerProperties;
@@ -210,6 +214,9 @@
mutable scoped_ptr<net::URLRequestJobFactory> main_job_factory_;
mutable scoped_ptr<net::URLRequestJobFactory> extensions_job_factory_;
+ mutable scoped_ptr<domain_reliability::DomainReliabilityMonitor>
+ domain_reliability_monitor_;
+
// Parameters needed for isolated apps.
base::FilePath profile_path_;
int app_cache_max_size_;