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

Add the RestoreData class and the AppRestoreData struct.

The RestoreData class is the full restore data in memory to be written
to the FullRestoreData file.

There will be some separate CLs to convert RestoreData to JSON format,
and write the full restore data to a file.

BUG=1146900

Change-Id: I7b51b0ba6e1cbe4f7a4b763a52e81f273a74c8d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2581702Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836523}
parent f38203af
......@@ -7,8 +7,12 @@ component("full_restore") {
sources = [
"app_launch_info.cc",
"app_launch_info.h",
"app_restore_data.cc",
"app_restore_data.h",
"full_restore_utils.cc",
"full_restore_utils.h",
"restore_data.cc",
"restore_data.h",
]
defines = [ "IS_FULL_RESTORE_IMPL" ]
......
// 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/app_restore_data.h"
namespace full_restore {
AppRestoreData::AppRestoreData() = default;
AppRestoreData::~AppRestoreData() = default;
} // 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_APP_RESTORE_DATA_H_
#define COMPONENTS_FULL_RESTORE_APP_RESTORE_DATA_H_
#include <vector>
#include "base/component_export.h"
#include "base/optional.h"
#include "components/services/app_service/public/mojom/types.mojom.h"
#include "ui/gfx/geometry/rect.h"
#include "url/gurl.h"
namespace full_restore {
// This is the struct used by RestoreData to save both app launch parameters and
// app window information. This struct can be converted to JSON format to be
// written to the FullRestoreData file.
//
// TODO(crbug.com/1146900): Add the interface to convert this struct to JSON
// format.
struct COMPONENT_EXPORT(FULL_RESTORE) AppRestoreData {
AppRestoreData();
~AppRestoreData();
AppRestoreData(const AppRestoreData&) = delete;
AppRestoreData& operator=(const AppRestoreData&) = delete;
// App launch parameters.
base::Optional<int32_t> event_flag;
base::Optional<int32_t> container;
base::Optional<int32_t> disposition;
base::Optional<int64_t> display_id;
base::Optional<GURL> url;
base::Optional<apps::mojom::IntentPtr> intent;
base::Optional<std::vector<base::FilePath>> file_paths;
// Window's information.
base::Optional<int32_t> activation_index;
base::Optional<int32_t> desk_id;
base::Optional<gfx::Rect> restored_bounds;
base::Optional<gfx::Rect> current_bounds;
base::Optional<int32_t> Window_state_type;
};
} // namespace full_restore
#endif // COMPONENTS_FULL_RESTORE_APP_RESTORE_DATA_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/restore_data.h"
namespace full_restore {
RestoreData::RestoreData() = default;
RestoreData::~RestoreData() = default;
} // 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_RESTORE_DATA_H_
#define COMPONENTS_FULL_RESTORE_RESTORE_DATA_H_
#include <map>
#include <memory>
#include "base/component_export.h"
#include "components/full_restore/app_restore_data.h"
namespace full_restore {
// This class is responsible for saving all app launch and app windows
// information. It can be converted to JSON format to be written to the
// FullRestoreData file.
//
// TODO(crbug.com/1146900):
// 1. Add the interface to convert this struct to JSON format.
// 2. Add the interface to add a LaunchAndWindowInfo with AppLaunchInfo.
// 3. Add the interface to modify LaunchAndWindowInfo when the window
// information is updated.
// 4. Add the interface to remove LaunchAndWindowInfo.
class COMPONENT_EXPORT(FULL_RESTORE) RestoreData {
public:
// Map from a window id to AppRestoreData.
using LaunchList = std::map<int, std::unique_ptr<AppRestoreData>>;
// Map from an app id to LaunchList.
using AppIdToLaunchList = std::map<std::string, LaunchList>;
RestoreData();
~RestoreData();
RestoreData(const RestoreData&) = delete;
RestoreData& operator=(const RestoreData&) = delete;
private:
AppIdToLaunchList app_id_to_launch_list_;
};
} // namespace full_restore
#endif // COMPONENTS_FULL_RESTORE_RESTORE_DATA_H_
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