forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloc_blocklist_service.h
59 lines (42 loc) · 1.7 KB
/
floc_blocklist_service.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2020 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 COMPONENTS_FEDERATED_LEARNING_FLOC_BLOCKLIST_SERVICE_H_
#define COMPONENTS_FEDERATED_LEARNING_FLOC_BLOCKLIST_SERVICE_H_
#include <stdint.h>
#include <unordered_set>
#include "base/memory/scoped_refptr.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
namespace base {
class FilePath;
class SequencedTaskRunner;
} // namespace base
namespace federated_learning {
// Responsible for loading the blocklist of flocs that are downloaded through
// the component updater.
//
// File reading and parsing is posted to |background_task_runner_|.
class FlocBlocklistService
: public base::SupportsWeakPtr<FlocBlocklistService> {
public:
using LoadedBlocklist = base::Optional<std::unordered_set<uint64_t>>;
FlocBlocklistService();
virtual ~FlocBlocklistService();
FlocBlocklistService(const FlocBlocklistService&) = delete;
FlocBlocklistService& operator=(const FlocBlocklistService&) = delete;
// Virtual for testing.
virtual void OnBlocklistFileReady(const base::FilePath& file_path);
void SetBackgroundTaskRunnerForTesting(
scoped_refptr<base::SequencedTaskRunner> background_task_runner);
protected:
// Virtual for testing.
virtual void OnBlocklistLoadResult(LoadedBlocklist blocklist);
private:
friend class MockFlocBlocklistService;
// Runner for tasks that do not influence user experience.
scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
LoadedBlocklist loaded_blocklist_;
};
} // namespace federated_learning
#endif // COMPONENTS_FEDERATED_LEARNING_FLOC_BLOCKLIST_SERVICE_H_