dpwa: Serialize WebAppInstallManager error log.
WebAppInstallManager error log may contain critical errors.
If the user has kRecordWebAppDebugInfo flag enabled, critical
errors must survive chrome binary relaunches.
Example path to output file:
/user-data-dir/<ProfileDir>/Web Applications/Logs/WebAppInstallManager.log
This UI exposition is useful on ChromeOS devices where bug reporters
don't have access to the underlying filesystem.
Bug: 1238622
Change-Id: I40d49dcea8096b70b990307127e3452bb76680c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3245151
Commit-Queue: Alexey Baskakov <[email protected]>
Reviewed-by: Alan Cutter <[email protected]>
Cr-Commit-Position: refs/heads/main@{#943409}
diff --git a/chrome/browser/web_applications/web_app_internals_utils.h b/chrome/browser/web_applications/web_app_internals_utils.h
new file mode 100644
index 0000000..d734814
--- /dev/null
+++ b/chrome/browser/web_applications/web_app_internals_utils.h
@@ -0,0 +1,39 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_INTERNALS_UTILS_H_
+#define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_INTERNALS_UTILS_H_
+
+#include "base/callback_forward.h"
+#include "base/strings/string_piece_forward.h"
+#include "chrome/browser/web_applications/web_app_constants.h"
+
+namespace base {
+class FilePath;
+class Value;
+} // namespace base
+
+namespace web_app {
+
+using ReadErrorLogCallback =
+ base::OnceCallback<void(Result, base::Value error_log)>;
+
+void ReadErrorLog(const base::FilePath& web_apps_directory,
+ base::StringPiece subsystem_name,
+ ReadErrorLogCallback callback);
+
+using FileIoCallback = base::OnceCallback<void(Result)>;
+
+void WriteErrorLog(const base::FilePath& web_apps_directory,
+ base::StringPiece subsystem_name,
+ base::Value error_log,
+ FileIoCallback callback);
+
+void ClearErrorLog(const base::FilePath& web_apps_directory,
+ base::StringPiece subsystem_name,
+ FileIoCallback callback);
+
+} // namespace web_app
+
+#endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_INTERNALS_UTILS_H_