1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_CRASH_LINUX_CRASH_TESTING_UTILS_H_
6 #define CHROMECAST_CRASH_LINUX_CRASH_TESTING_UTILS_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h"
11 namespace chromecast
{
15 // Creates a DumpInfo object corresponding to the deserialization of
16 // |json_string|. Returned DumpInfo object maybe invalid if |json_string|
17 // doesn't correspond to a valid DumpInfo object.
18 scoped_ptr
<DumpInfo
> CreateDumpInfo(const std::string
& json_string
);
20 // Populates |dumps| with all the DumpInfo entries serialized in the lockfile at
21 // |lockfile_path|. Returns true on success, false on error.
22 bool FetchDumps(const std::string
& lockfile_path
,
23 ScopedVector
<DumpInfo
>* dumps
);
25 // Clear all dumps in the lockfile at |lockfile_path|.
26 // Returns true on success, false on error.
27 bool ClearDumps(const std::string
& lockfile_path
);
29 // Creates an empty lockfile at |lockfile_path|. Creates a default initialized
30 // metadata file at |metadata_path|. Returns true on success, false on error.
31 bool CreateFiles(const std::string
& lockfile_path
,
32 const std::string
& metadata_path
);
34 // Appends serialization of |dump| onto the lockfile at |lockfile_path|.
35 // Creates default initialized lockfile in |lockfile_path| and metadata file in
36 // |metadata_path| if they don't exist.
37 // Returns true on success, false on error.
38 bool AppendLockFile(const std::string
& lockfile_path
,
39 const std::string
& metadata_path
,
40 const DumpInfo
& dump
);
42 // Set the ratelimit period start in the metadata file at |metadata_path| to
43 // |start|. Returns true on success, false on error.
44 bool SetRatelimitPeriodStart(const std::string
& metadata_path
, time_t start
);
46 } // namespace chromecast
48 #endif // CHROMECAST_CRASH_LINUX_CRASH_TESTING_UTILS_H_