Commit 472098df authored by Julia Tuttle's avatar Julia Tuttle Committed by Commit Bot

Network Error Logging: Create stub Delegate.

This will eventually be used to parse JSON using data_decoder.

Bug: 810142
Change-Id: Ie0395104c64c24eee2df568be337bb251f500241
Reviewed-on: https://chromium-review.googlesource.com/919621
Commit-Queue: Julia Tuttle <juliatuttle@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539945}
parent 3457fe6c
......@@ -47,6 +47,7 @@
#endif
#if BUILDFLAG(ENABLE_REPORTING)
#include "net/network_error_logging/network_error_logging_delegate.h"
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/reporting/reporting_policy.h"
#include "net/reporting/reporting_service.h"
......@@ -298,7 +299,8 @@ net::URLRequestContext* OffTheRecordProfileIOData::InitializeAppRequestContext(
}
if (context->network_error_logging_service()) {
context->SetNetworkErrorLoggingService(
net::NetworkErrorLoggingService::Create());
net::NetworkErrorLoggingService::Create(
net::NetworkErrorLoggingDelegate::Create()));
context->network_error_logging_service()->SetReportingService(
context->reporting_service());
}
......
......@@ -81,6 +81,7 @@
#endif
#if BUILDFLAG(ENABLE_REPORTING)
#include "net/network_error_logging/network_error_logging_delegate.h"
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/reporting/reporting_policy.h"
#include "net/reporting/reporting_service.h"
......@@ -631,7 +632,8 @@ net::URLRequestContext* ProfileImplIOData::InitializeAppRequestContext(
if (context->network_error_logging_service()) {
context->SetNetworkErrorLoggingService(
net::NetworkErrorLoggingService::Create());
net::NetworkErrorLoggingService::Create(
net::NetworkErrorLoggingDelegate::Create()));
context->network_error_logging_service()->SetReportingService(
context->reporting_service());
}
......
......@@ -1806,6 +1806,8 @@ component("net") {
if (enable_reporting) {
sources += [
"network_error_logging/network_error_logging_delegate.cc",
"network_error_logging/network_error_logging_delegate.h",
"network_error_logging/network_error_logging_service.cc",
"network_error_logging/network_error_logging_service.h",
"reporting/reporting_browsing_data_remover.cc",
......
// Copyright 2018 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.
#include "net/network_error_logging/network_error_logging_delegate.h"
#include <memory>
namespace net {
namespace {
class NetworkErrorLoggingDelegateImpl : public NetworkErrorLoggingDelegate {
public:
NetworkErrorLoggingDelegateImpl() = default;
~NetworkErrorLoggingDelegateImpl() override = default;
private:
DISALLOW_COPY_AND_ASSIGN(NetworkErrorLoggingDelegateImpl);
};
} // namespace
NetworkErrorLoggingDelegate::~NetworkErrorLoggingDelegate() = default;
// static
std::unique_ptr<NetworkErrorLoggingDelegate>
NetworkErrorLoggingDelegate::Create() {
return std::make_unique<NetworkErrorLoggingDelegateImpl>();
}
NetworkErrorLoggingDelegate::NetworkErrorLoggingDelegate() = default;
} // namespace net
// Copyright 2018 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 NET_NETWORK_ERROR_LOGGING_NETWORK_ERROR_LOGGING_DELEGATE_H_
#define NET_NETWORK_ERROR_LOGGING_NETWORK_ERROR_LOGGING_DELEGATE_H_
#include <memory>
#include "base/macros.h"
#include "net/base/net_export.h"
namespace net {
class NET_EXPORT NetworkErrorLoggingDelegate {
public:
virtual ~NetworkErrorLoggingDelegate();
static std::unique_ptr<NetworkErrorLoggingDelegate> Create();
protected:
NetworkErrorLoggingDelegate();
private:
DISALLOW_COPY_AND_ASSIGN(NetworkErrorLoggingDelegate);
};
} // namespace net
#endif // NET_NETWORK_ERROR_LOGGING_NETWORK_ERROR_LOGGING_DELEGATE_H_
......@@ -18,6 +18,7 @@
#include "base/values.h"
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
#include "net/network_error_logging/network_error_logging_delegate.h"
#include "net/reporting/reporting_service.h"
#include "net/socket/next_proto.h"
#include "url/gurl.h"
......@@ -120,7 +121,11 @@ bool RequestWasSuccessful(
class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {
public:
NetworkErrorLoggingServiceImpl() = default;
explicit NetworkErrorLoggingServiceImpl(
std::unique_ptr<NetworkErrorLoggingDelegate> delegate)
: delegate_(std::move(delegate)) {
DCHECK(delegate_);
}
// NetworkErrorLoggingService implementation:
......@@ -242,6 +247,8 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {
using WildcardPolicyMap =
std::map<std::string, std::set<const OriginPolicy*>>;
std::unique_ptr<NetworkErrorLoggingDelegate> delegate_;
PolicyMap policies_;
WildcardPolicyMap wildcard_policies_;
......@@ -413,9 +420,9 @@ const char NetworkErrorLoggingService::kElapsedTimeKey[] = "elapsed-time";
const char NetworkErrorLoggingService::kTypeKey[] = "type";
// static
std::unique_ptr<NetworkErrorLoggingService>
NetworkErrorLoggingService::Create() {
return std::make_unique<NetworkErrorLoggingServiceImpl>();
std::unique_ptr<NetworkErrorLoggingService> NetworkErrorLoggingService::Create(
std::unique_ptr<NetworkErrorLoggingDelegate> delegate) {
return std::make_unique<NetworkErrorLoggingServiceImpl>(std::move(delegate));
}
NetworkErrorLoggingService::~NetworkErrorLoggingService() = default;
......
......@@ -35,6 +35,8 @@ extern const base::Feature NET_EXPORT kNetworkErrorLogging;
namespace net {
class NetworkErrorLoggingDelegate;
class NET_EXPORT NetworkErrorLoggingService {
public:
// The details of a network error that are included in an NEL report.
......@@ -72,7 +74,8 @@ class NET_EXPORT NetworkErrorLoggingService {
static const char kElapsedTimeKey[];
static const char kTypeKey[];
static std::unique_ptr<NetworkErrorLoggingService> Create();
static std::unique_ptr<NetworkErrorLoggingService> Create(
std::unique_ptr<NetworkErrorLoggingDelegate> delegate);
virtual ~NetworkErrorLoggingService();
......
......@@ -14,6 +14,7 @@
#include "base/values.h"
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
#include "net/network_error_logging/network_error_logging_delegate.h"
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/reporting/reporting_policy.h"
#include "net/reporting/reporting_service.h"
......@@ -99,7 +100,8 @@ class TestReportingService : public ReportingService {
class NetworkErrorLoggingServiceTest : public ::testing::Test {
protected:
NetworkErrorLoggingServiceTest() {
service_ = NetworkErrorLoggingService::Create();
service_ = NetworkErrorLoggingService::Create(
NetworkErrorLoggingDelegate::Create());
CreateReportingService();
}
......
......@@ -59,6 +59,7 @@
#endif
#if BUILDFLAG(ENABLE_REPORTING)
#include "net/network_error_logging/network_error_logging_delegate.h"
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/reporting/reporting_policy.h"
#include "net/reporting/reporting_service.h"
......@@ -641,7 +642,8 @@ std::unique_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
if (network_error_logging_enabled_) {
storage->set_network_error_logging_service(
NetworkErrorLoggingService::Create());
NetworkErrorLoggingService::Create(
NetworkErrorLoggingDelegate::Create()));
}
// If both Reporting and Network Error Logging are actually enabled, then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment