1 // Copyright 2018 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.
4 
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_SINGLE_ARC_APP_INSTALL_EVENT_LOG_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_SINGLE_ARC_APP_INSTALL_EVENT_LOG_H_
7 
8 #include <string>
9 
10 #include "chrome/browser/chromeos/policy/single_install_event_log.h"
11 #include "components/policy/proto/device_management_backend.pb.h"
12 
13 namespace base {
14 class File;
15 }
16 
17 namespace policy {
18 
19 // An event log for a single ARC++ app's push-install process.
20 class SingleArcAppInstallEventLog
21     : public SingleInstallEventLog<
22           enterprise_management::AppInstallReportLogEvent> {
23  public:
24   explicit SingleArcAppInstallEventLog(const std::string& package);
25   ~SingleArcAppInstallEventLog();
26 
27   // Restores the event log from |file| into |log|. Returns |true| if the
28   // self-delimiting format of the log was parsed successfully and further logs
29   // stored in the file may be loaded.
30   // |InstallEventLog::incomplete_| is set to |true| if it was set when storing
31   // the log to the file, the buffer wraps around or any log entries cannot be
32   // fully parsed. If not even the app name can be parsed, |log| is set to
33   // |nullptr|.
34   static bool Load(base::File* file,
35                    std::unique_ptr<SingleArcAppInstallEventLog>* log);
36 
37   // Serializes the log to a protobuf for upload to a server. Records which
38   // entries were serialized so that they may be cleared after successful
39   // upload.
40   void Serialize(enterprise_management::AppInstallReport* report);
41 };
42 
43 }  // namespace policy
44 
45 #endif  // CHROME_BROWSER_CHROMEOS_POLICY_SINGLE_ARC_APP_INSTALL_EVENT_LOG_H_
46