#include "chrome/enterprise_companion/event_logger.h"
#include <algorithm>
#include <iterator>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/containers/span.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/platform_file.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/sequence_checker.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/sequence_bound.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/enterprise_companion/enterprise_companion_branding.h"
#include "chrome/enterprise_companion/global_constants.h"
#include "chrome/enterprise_companion/installer_paths.h"
#include "chrome/enterprise_companion/proto/enterprise_companion_event.pb.h"
#include "chrome/enterprise_companion/proto/log_request.pb.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "net/base/net_errors.h"
#include "net/cookies/cookie_access_result.h"
#include "net/cookies/site_for_cookies.h"
#include "net/http/http_request_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/cookie_manager.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace enterprise_companion {
namespace {
constexpr size_t kCookieValueBufferSize = …;
constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation = …;
class EventLoggerImpl : public EventLogger { … };
class EventLogUploaderImpl : public EventLogUploader { … };
class EventLoggerManagerImpl : public EventLoggerManager { … };
class EventLoggerCookieHandlerImpl : public EventLoggerCookieHandler,
network::mojom::CookieChangeListener { … };
}
const char kLoggingCookieName[] = …;
const char kLoggingCookieDefaultValue[] = …;
std::unique_ptr<EventLoggerManager> CreateEventLoggerManager(
std::unique_ptr<EventLogUploader> uploader,
const base::Clock* clock) { … }
std::unique_ptr<EventLogUploader> CreateEventLogUploader(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
std::optional<base::File> OpenDefaultEventLoggerCookieFile() { … }
base::SequenceBound<EventLoggerCookieHandler> CreateEventLoggerCookieHandler(
std::optional<base::File> logging_cookie_file) { … }
}