blob: 09d597307f6022966a4d1f9a4d06d8dab2c3e48b [file] [log] [blame]
// 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.
package org.chromium.chrome.browser.tab.state;
import java.util.HashMap;
import java.util.Map;
/**
* Contains configuration values such as data storage methods and unique identifiers
* for {@link PersistedTabData}
*/
public enum PersistedTabDataConfiguration {
// TODO(crbug.com/1059650) investigate should this go in the app code?
// Also investigate if the storage instance should be shared.
CRITICAL_PERSISTED_TAB_DATA("CPTD", new FilePersistedTabDataStorage());
private static final Map<Class<? extends PersistedTabData>, PersistedTabDataConfiguration>
sLookup = new HashMap<>();
static {
// TODO(crbug.com/1060187) remove static initializer and initialization lazy
sLookup.put(CriticalPersistedTabData.class, CRITICAL_PERSISTED_TAB_DATA);
}
public final String id;
public final PersistedTabDataStorage storage;
/**
* @param id identifier for {@link PersistedTabData}
* @param storage {@link PersistedTabDataStorage} associated with {@link PersistedTabData}
*/
PersistedTabDataConfiguration(String id, PersistedTabDataStorage storage) {
this.id = id;
this.storage = storage;
}
/**
* Acquire {@link PersistedTabDataConfiguration} for a given {@link PersistedTabData} class
*/
public static PersistedTabDataConfiguration get(Class<? extends PersistedTabData> clazz) {
return sLookup.get(clazz);
}
}