blob: 77978eff7539517e63fe760eaa0a3df6ffa5f8b6 [file] [log] [blame]
James Hawkinsabd73e62016-01-19 15:10:38 -08001/*
2 * Copyright (C) 2016 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#ifndef BOOT_EVENT_RECORD_STORE_H_
18#define BOOT_EVENT_RECORD_STORE_H_
19
20#include <cstdint>
21#include <string>
22#include <utility>
23#include <vector>
James Hawkinseabe08b2016-01-19 16:54:35 -080024#include <android-base/macros.h>
James Hawkinsabd73e62016-01-19 15:10:38 -080025#include <gtest/gtest_prod.h>
26
27// BootEventRecordStore manages the persistence of boot events to the record
28// store and the retrieval of all boot event records from the store.
29class BootEventRecordStore {
30 public:
31 // A BootEventRecord consists of the event name and the timestamp the event
32 // occurred.
33 typedef std::pair<std::string, int32_t> BootEventRecord;
34
35 BootEventRecordStore();
36
37 // Persists the boot event named |name| in the record store.
38 void AddBootEvent(const std::string& name);
39
40 // Returns a list of all of the boot events persisted in the record store.
41 std::vector<BootEventRecord> GetAllBootEvents() const;
42
43 private:
44 // The tests call SetStorePath to override the default store location with a
45 // more test-friendly path.
46 FRIEND_TEST(BootEventRecordStoreTest, AddSingleBootEvent);
47 FRIEND_TEST(BootEventRecordStoreTest, AddMultipleBootEvents);
48
49 // Sets the filesystem path of the record store.
50 void SetStorePath(const std::string& path);
51
52 // Constructs the full path of the given boot |event|.
53 std::string GetBootEventPath(const std::string& event) const;
54
55 // The filesystem path of the record store.
56 std::string store_path_;
57
58 DISALLOW_COPY_AND_ASSIGN(BootEventRecordStore);
59};
60
61#endif // BOOT_EVENT_RECORD_STORE_H_