1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "StatsPullerManagerImpl.h"
20 
21 namespace android {
22 namespace os {
23 namespace statsd {
24 
25 class StatsPullerManager {
26  public:
~StatsPullerManager()27     virtual ~StatsPullerManager() {}
28 
RegisterReceiver(int tagId,wp<PullDataReceiver> receiver,int64_t nextPullTimeNs,int64_t intervalNs)29     virtual void RegisterReceiver(int tagId, wp<PullDataReceiver> receiver, int64_t nextPullTimeNs,
30                                   int64_t intervalNs) {
31         mPullerManager.RegisterReceiver(tagId, receiver, nextPullTimeNs, intervalNs);
32     };
33 
UnRegisterReceiver(int tagId,wp<PullDataReceiver> receiver)34     virtual void UnRegisterReceiver(int tagId, wp <PullDataReceiver> receiver) {
35         mPullerManager.UnRegisterReceiver(tagId, receiver);
36     };
37 
38     // Verify if we know how to pull for this matcher
PullerForMatcherExists(int tagId)39     bool PullerForMatcherExists(int tagId) {
40         return mPullerManager.PullerForMatcherExists(tagId);
41     }
42 
OnAlarmFired(const int64_t currentTimeNs)43     void OnAlarmFired(const int64_t currentTimeNs) {
44         mPullerManager.OnAlarmFired(currentTimeNs);
45     }
46 
Pull(const int tagId,const int64_t timesNs,vector<std::shared_ptr<LogEvent>> * data)47     virtual bool Pull(const int tagId, const int64_t timesNs,
48                       vector<std::shared_ptr<LogEvent>>* data) {
49         return mPullerManager.Pull(tagId, timesNs, data);
50     }
51 
ForceClearPullerCache()52     int ForceClearPullerCache() {
53         return mPullerManager.ForceClearPullerCache();
54     }
55 
SetStatsCompanionService(sp<IStatsCompanionService> statsCompanionService)56     void SetStatsCompanionService(sp<IStatsCompanionService> statsCompanionService) {
57         mPullerManager.SetStatsCompanionService(statsCompanionService);
58     }
59 
ClearPullerCacheIfNecessary(int64_t timestampNs)60     int ClearPullerCacheIfNecessary(int64_t timestampNs) {
61         return mPullerManager.ClearPullerCacheIfNecessary(timestampNs);
62     }
63 
64  private:
65     StatsPullerManagerImpl
66         & mPullerManager = StatsPullerManagerImpl::GetInstance();
67 };
68 
69 }  // namespace statsd
70 }  // namespace os
71 }  // namespace android
72