| 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 specic language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
#ifndef ANDROID_LIBPERFMGR_FILENODE_H_ |
| 18 |
#define ANDROID_LIBPERFMGR_FILENODE_H_ |
| 19 |
|
| 20 |
#include <cstddef> |
| 21 |
#include <string> |
| 22 |
#include <vector> |
| 23 |
|
| 24 |
#include <android-base/unique_fd.h> |
| 25 |
|
| 26 |
#include "perfmgr/Node.h" |
| 27 |
|
| 28 |
namespace android { |
| 29 |
namespace perfmgr { |
| 30 |
|
| 31 |
// FileNode represents file |
| 32 |
class FileNode : public Node { |
| 33 |
public: |
| 34 |
FileNode(std::string name, std::string node_path, |
| 35 |
std::vector<RequestGroup> req_sorted, std::size_t default_val_index, |
| 36 |
bool reset_on_init, bool hold_fd = false); |
| 37 |
|
| 38 |
std::chrono::milliseconds Update(bool log_error) override; |
| 39 |
|
| 40 |
bool GetHoldFd() const; |
| 41 |
|
| 42 |
void DumpToFd(int fd) const override; |
| 43 |
|
| 44 |
private: |
| 45 |
FileNode(const Node& other) = delete; |
| 46 |
FileNode& operator=(Node const&) = delete; |
| 47 |
|
| 48 |
const bool hold_fd_; |
| 49 |
android::base::unique_fd fd_; |
| 50 |
}; |
| 51 |
|
| 52 |
} // namespace perfmgr |
| 53 |
} // namespace android |
| 54 |
|
| 55 |
#endif // ANDROID_LIBPERFMGR_FILENODE_H_ |