blob: 8e4c9a88cf4c2b3bf1751c9c2c72e62a2ff34c56 [file] [log] [blame]
// Copyright 2020 The Chromium OS 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 CROSLOG_FILE_CHANGE_WATCHER_H_
#define CROSLOG_FILE_CHANGE_WATCHER_H_
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/memory/singleton.h"
#include "base/observer_list_types.h"
namespace croslog {
class InotifyReader;
class FileChangeWatcher {
public:
static FileChangeWatcher* GetInstance();
class Observer : public base::CheckedObserver {
public:
virtual void OnFileContentMaybeChanged() = 0;
virtual void OnFileNameMaybeChanged() = 0;
};
// Add a handler to retrieve file change events.
virtual bool AddWatch(const base::FilePath& path, Observer* observer) = 0;
// Remove a handler to retrieve file change events.
virtual void RemoveWatch(const base::FilePath& path) = 0;
protected:
FileChangeWatcher();
FileChangeWatcher(const FileChangeWatcher&) = delete;
FileChangeWatcher& operator=(const FileChangeWatcher&) = delete;
};
} // namespace croslog
#endif // CROSLOG_FILE_CHANGE_WATCHER_H_