Commit be942038 authored by Nancy Wang's avatar Nancy Wang Committed by Chromium LUCI CQ

Add FullRestoreSavehandler for the restore data saving function.

This CL adds FullRestoreSavehandler class and the SaveAppLaunchInfo
interface to prepare for the restore data writing implementation.

There will be separate CL to implement the restore data and the
FullRestoreFileHandler class to  run the actual writing with a
background task runner.

BUG=1146900

Change-Id: I2ff73b40d6441e0f581b7f4a5b035cf6156241c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580922
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836560}
parent 2fcd789e
...@@ -11,6 +11,8 @@ component("full_restore") { ...@@ -11,6 +11,8 @@ component("full_restore") {
"app_restore_data.h", "app_restore_data.h",
"full_restore_file_handler.cc", "full_restore_file_handler.cc",
"full_restore_file_handler.h", "full_restore_file_handler.h",
"full_restore_save_handler.cc",
"full_restore_save_handler.h",
"full_restore_utils.cc", "full_restore_utils.cc",
"full_restore_utils.h", "full_restore_utils.h",
"restore_data.cc", "restore_data.cc",
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include "base/component_export.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/optional.h" #include "base/optional.h"
#include "components/services/app_service/public/mojom/types.mojom.h" #include "components/services/app_service/public/mojom/types.mojom.h"
......
// Copyright 2020 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.
#include "components/full_restore/full_restore_save_handler.h"
#include "base/files/file_path.h"
#include "base/no_destructor.h"
#include "components/full_restore/app_launch_info.h"
namespace full_restore {
FullRestoreSaveHandler* FullRestoreSaveHandler::GetInstance() {
static base::NoDestructor<FullRestoreSaveHandler> full_restore_save_handler;
return full_restore_save_handler.get();
}
FullRestoreSaveHandler::FullRestoreSaveHandler() = default;
FullRestoreSaveHandler::~FullRestoreSaveHandler() = default;
void FullRestoreSaveHandler::SaveAppLaunchInfo(
const base::FilePath& profile_dir,
std::unique_ptr<AppLaunchInfo> app_launch_info) {
// TODO(crbug.com/1146900): Save the app launch parameters to the full restore
// file.
}
} // namespace full_restore
// Copyright 2020 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 COMPONENTS_FULL_RESTORE_FULL_RESTORE_SAVE_HANDLER_H_
#define COMPONENTS_FULL_RESTORE_FULL_RESTORE_SAVE_HANDLER_H_
#include <memory>
#include "base/component_export.h"
namespace base {
class FilePath;
}
namespace full_restore {
struct AppLaunchInfo;
// FullRestoreSaveHandler is responsible for writing both the app launch
// information and the app window information to disk. FullRestoreSaveHandler
// runs on the main thread and creates FullRestoreFileHandler (which runs on a
// background task runner) for the actual writing. To minimize IO,
// FullRestoreSaveHandler starts a timer that invokes restore data saving at a
// later time.
//
// TODO(crbug.com/1146900):
// 1. Implement the restore data writing function.
// 2. Add a timer to delay the restore data saving.
class COMPONENT_EXPORT(FULL_RESTORE) FullRestoreSaveHandler {
public:
static FullRestoreSaveHandler* GetInstance();
FullRestoreSaveHandler();
virtual ~FullRestoreSaveHandler();
FullRestoreSaveHandler(const FullRestoreSaveHandler&) = delete;
FullRestoreSaveHandler& operator=(const FullRestoreSaveHandler&) = delete;
void SaveAppLaunchInfo(const base::FilePath& profile_dir,
std::unique_ptr<AppLaunchInfo> app_launch_info);
};
} // namespace full_restore
#endif // COMPONENTS_FULL_RESTORE_FULL_RESTORE_SAVE_HANDLER_H_
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "ash/public/cpp/ash_features.h" #include "ash/public/cpp/ash_features.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "components/full_restore/app_launch_info.h" #include "components/full_restore/app_launch_info.h"
#include "components/full_restore/full_restore_save_handler.h"
namespace { namespace {
...@@ -20,11 +21,11 @@ namespace full_restore { ...@@ -20,11 +21,11 @@ namespace full_restore {
void SaveAppLaunchInfo(const base::FilePath& profile_dir, void SaveAppLaunchInfo(const base::FilePath& profile_dir,
std::unique_ptr<AppLaunchInfo> app_launch_info) { std::unique_ptr<AppLaunchInfo> app_launch_info) {
if (!ash::features::IsFullRestoreEnabled()) if (!ash::features::IsFullRestoreEnabled() || !app_launch_info)
return; return;
// TODO(crbug.com/1146900): Save the app launch parameters to the full restore FullRestoreSaveHandler::GetInstance()->SaveAppLaunchInfo(
// file. profile_dir, std::move(app_launch_info));
} }
bool ShouldRestore() { bool ShouldRestore() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment