blob: 5f449884b273df28e45f680b9a9ee8887a5d54fb [file] [log] [blame]
// Copyright 2017 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 <memory>
#include "base/macros.h"
#include "base/observer_list.h"
#include "components/download/internal/log_sink.h"
#include "components/download/public/download_params.h"
#include "components/download/public/logger.h"
namespace base {
class Value;
namespace download {
class LogSource;
struct Entry;
// The internal Logger implementation. Note that this Logger will not do any
// actual work in response to LogSink requests if there are no Observers
// registered. Any calls to the Logger API will still be honored though.
class LoggerImpl : public Logger, public LogSink {
~LoggerImpl() override;
void SetLogSource(LogSource* log_source);
// Logger implementation.
void AddObserver(Observer* observer) override;
void RemoveObserver(Observer* observer) override;
base::Value GetServiceStatus() override;
base::Value GetServiceDownloads() override;
// LogSink implementation.
void OnServiceStatusChanged() override;
void OnServiceDownloadsAvailable() override;
void OnServiceDownloadChanged(const std::string& guid) override;
void OnServiceDownloadFailed(CompletionType completion_type,
const Entry& entry) override;
void OnServiceRequestMade(DownloadClient client,
const std::string& guid,
DownloadParams::StartResult start_result) override;
LogSource* log_source_;
base::ObserverList<Observer> observers_;
} // namespace download