blob: 7ece50761ff867ae81dd78041509d3e8857fbc13 [file] [log] [blame]
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_UPDATER_UPDATE_USAGE_STATS_TASK_H_
#define CHROME_UPDATER_UPDATE_USAGE_STATS_TASK_H_
#include <string>
#include <vector>
#include "base/functional/callback_forward.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "base/sequence_checker.h"
#include "chrome/updater/updater_scope.h"
namespace updater {
bool OtherAppUsageStatsAllowed(const std::vector<std::string>& app_ids,
UpdaterScope scope);
// Reads usage stats for each app from the system instead of persisted data,
// specifically from the registry for Windows. `include_only_these_app_ids`
// allows for including only app ids that are both in the registry and in
// `include_only_these_app_ids`, and is used for unit tests.
bool AreRawUsageStatsEnabled(
UpdaterScope scope,
const std::vector<std::string>& include_only_these_app_ids = {});
class PersistedData;
class UpdateUsageStatsTask
: public base::RefCountedThreadSafe<UpdateUsageStatsTask> {
public:
UpdateUsageStatsTask(UpdaterScope scope,
scoped_refptr<PersistedData> persisted_data);
void Run(base::OnceClosure callback);
private:
friend class base::RefCountedThreadSafe<UpdateUsageStatsTask>;
FRIEND_TEST_ALL_PREFIXES(UpdateUsageStatsTaskTest, NoApps);
FRIEND_TEST_ALL_PREFIXES(UpdateUsageStatsTaskTest, OneAppEnabled);
FRIEND_TEST_ALL_PREFIXES(UpdateUsageStatsTaskTest, ZeroAppsEnabled);
virtual ~UpdateUsageStatsTask();
SEQUENCE_CHECKER(sequence_checker_);
const UpdaterScope scope_;
scoped_refptr<PersistedData> persisted_data_;
};
} // namespace updater
#endif // CHROME_UPDATER_UPDATE_USAGE_STATS_TASK_H_