1 /* 2 ** 3 ** Copyright 2023, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 18 #ifndef ANDROID_MEDIA_CLIENTIMPORTANCERECLAIMPOLICY_H_ 19 #define ANDROID_MEDIA_CLIENTIMPORTANCERECLAIMPOLICY_H_ 20 21 #include <media/MediaResource.h> 22 #include "IReclaimPolicy.h" 23 24 namespace android { 25 26 class ResourceTracker; 27 struct ClientInfo; 28 29 /* 30 * Implementation of Reclaim Policy based on the client's importance. 31 * 32 * Find the least important (other than that of requesting client) client from the 33 * same process (that is requesting for the resource). 34 * If there are multiple clients with least importance, then pick the biggest 35 * client among them. 36 * 37 */ 38 class ClientImportanceReclaimPolicy : public IReclaimPolicy { 39 public: 40 explicit ClientImportanceReclaimPolicy(const std::shared_ptr<ResourceTracker>& resourceTracker); 41 42 virtual ~ClientImportanceReclaimPolicy(); 43 44 /* 45 * Based on the client importance, identify and return the least important client of 46 * the requesting process from the list of given clients that satisfy the resource requested. 47 * 48 * @param[in] reclaimRequestInfo Information about the resource request 49 * @param[in] client List of clients to select from. 50 * @param[out] targetClients Upon success, this will have the list of identified client(s). 51 * 52 * @return true on success, false otherwise 53 */ 54 bool getClients(const ReclaimRequestInfo& reclaimRequestInfo, 55 const std::vector<ClientInfo>& clients, 56 std::vector<ClientInfo>& targetClients) override; 57 58 private: 59 std::shared_ptr<ResourceTracker> mResourceTracker; 60 }; 61 62 } // namespace android 63 64 #endif // ANDROID_MEDIA_CLIENTIMPORTANCERECLAIMPOLICY_H_ 65