// This file is generated by TypeBuilder_h.template.

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef protocol_Storage_h
#define protocol_Storage_h

#include "chrome/browser/devtools/protocol/protocol.h"
// For each imported domain we generate a ValueConversions struct instead of a full domain definition
// and include Domain::API version from there.
#include "chrome/browser/devtools/protocol/browser.h"

namespace protocol {
namespace Storage {
using SerializedStorageKey = String;
using StorageBucketsDurability = String;
class StorageBucket;
class StorageBucketInfo;
class RelatedWebsiteSet;

// ------------- Forward and enum declarations.

namespace StorageBucketsDurabilityEnum {
inline constexpr char Relaxed[] = "relaxed";
inline constexpr char Strict[] = "strict";
} // namespace StorageBucketsDurabilityEnum

// ------------- Type and builder declarations.

class  StorageBucket : public ::crdtp::ProtocolObject<StorageBucket> {
public:
    ~StorageBucket() override;  // Defined below

    String GetStorageKey() { return m_storageKey; }
    void SetStorageKey(const String& value);  // Defined below

    bool HasName() { return !!m_name; }
    String GetName(const String& defaultValue) const {
       return m_name.value_or(defaultValue);
    }
    const std::optional<String>& GetName() const {
       return m_name;
    }
    void SetName(const String& value);  // Defined below

    template<int STATE>
    class StorageBucketBuilder {
    public:
        enum {
            NoFieldsSet = 0,
            StorageKeySet = 1 << 1,
            AllFieldsSet = (StorageKeySet | 0)};


        StorageBucketBuilder<STATE | StorageKeySet>& SetStorageKey(const String& value);  // Defined below

        StorageBucketBuilder<STATE>& SetName(const String& value);  // Defined below

        std::unique_ptr<StorageBucket> Build()
        {
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
            return std::move(m_result);
        }

    private:
        friend class StorageBucket;
        StorageBucketBuilder() : m_result(new StorageBucket()) { }

        template<int STEP> StorageBucketBuilder<STATE | STEP>& castState()
        {
            return *reinterpret_cast<StorageBucketBuilder<STATE | STEP>*>(this);
        }

        std::unique_ptr<protocol::Storage::StorageBucket> m_result;
    };

    static StorageBucketBuilder<0> Create()
    {
        return StorageBucketBuilder<0>();
    }

private:
    DECLARE_SERIALIZATION_SUPPORT();

    StorageBucket();  // Defined below

    String m_storageKey;
    std::optional<String> m_name;
};


class  StorageBucketInfo : public ::crdtp::ProtocolObject<StorageBucketInfo> {
public:
    ~StorageBucketInfo() override;  // Defined below

    protocol::Storage::StorageBucket* GetBucket() { return m_bucket.get(); }
    void SetBucket(std::unique_ptr<protocol::Storage::StorageBucket> value);  // Defined below

    String GetId() { return m_id; }
    void SetId(const String& value);  // Defined below

    double GetExpiration() { return m_expiration; }
    void SetExpiration(double value);  // Defined below

    double GetQuota() { return m_quota; }
    void SetQuota(double value);  // Defined below

    bool GetPersistent() { return m_persistent; }
    void SetPersistent(bool value);  // Defined below

    String GetDurability() { return m_durability; }
    void SetDurability(const String& value);  // Defined below

    template<int STATE>
    class StorageBucketInfoBuilder {
    public:
        enum {
            NoFieldsSet = 0,
            BucketSet = 1 << 1,
            IdSet = 1 << 2,
            ExpirationSet = 1 << 3,
            QuotaSet = 1 << 4,
            PersistentSet = 1 << 5,
            DurabilitySet = 1 << 6,
            AllFieldsSet = (BucketSet | IdSet | ExpirationSet | QuotaSet | PersistentSet | DurabilitySet | 0)};


        StorageBucketInfoBuilder<STATE | BucketSet>& SetBucket(std::unique_ptr<protocol::Storage::StorageBucket> value);  // Defined below

        StorageBucketInfoBuilder<STATE | IdSet>& SetId(const String& value);  // Defined below

        StorageBucketInfoBuilder<STATE | ExpirationSet>& SetExpiration(double value);  // Defined below

        StorageBucketInfoBuilder<STATE | QuotaSet>& SetQuota(double value);  // Defined below

        StorageBucketInfoBuilder<STATE | PersistentSet>& SetPersistent(bool value);  // Defined below

        StorageBucketInfoBuilder<STATE | DurabilitySet>& SetDurability(const String& value);  // Defined below

        std::unique_ptr<StorageBucketInfo> Build()
        {
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
            return std::move(m_result);
        }

    private:
        friend class StorageBucketInfo;
        StorageBucketInfoBuilder() : m_result(new StorageBucketInfo()) { }

        template<int STEP> StorageBucketInfoBuilder<STATE | STEP>& castState()
        {
            return *reinterpret_cast<StorageBucketInfoBuilder<STATE | STEP>*>(this);
        }

        std::unique_ptr<protocol::Storage::StorageBucketInfo> m_result;
    };

    static StorageBucketInfoBuilder<0> Create()
    {
        return StorageBucketInfoBuilder<0>();
    }

private:
    DECLARE_SERIALIZATION_SUPPORT();

    StorageBucketInfo();  // Defined below

    std::unique_ptr<protocol::Storage::StorageBucket> m_bucket;
    String m_id;
    double m_expiration;
    double m_quota;
    bool m_persistent;
    String m_durability;
};


class  RelatedWebsiteSet : public ::crdtp::ProtocolObject<RelatedWebsiteSet> {
public:
    ~RelatedWebsiteSet() override;  // Defined below

    protocol::Array<String>* GetPrimarySites() { return m_primarySites.get(); }
    void SetPrimarySites(std::unique_ptr<protocol::Array<String>> value);  // Defined below

    protocol::Array<String>* GetAssociatedSites() { return m_associatedSites.get(); }
    void SetAssociatedSites(std::unique_ptr<protocol::Array<String>> value);  // Defined below

    protocol::Array<String>* GetServiceSites() { return m_serviceSites.get(); }
    void SetServiceSites(std::unique_ptr<protocol::Array<String>> value);  // Defined below

    template<int STATE>
    class RelatedWebsiteSetBuilder {
    public:
        enum {
            NoFieldsSet = 0,
            PrimarySitesSet = 1 << 1,
            AssociatedSitesSet = 1 << 2,
            ServiceSitesSet = 1 << 3,
            AllFieldsSet = (PrimarySitesSet | AssociatedSitesSet | ServiceSitesSet | 0)};


        RelatedWebsiteSetBuilder<STATE | PrimarySitesSet>& SetPrimarySites(std::unique_ptr<protocol::Array<String>> value);  // Defined below

        RelatedWebsiteSetBuilder<STATE | AssociatedSitesSet>& SetAssociatedSites(std::unique_ptr<protocol::Array<String>> value);  // Defined below

        RelatedWebsiteSetBuilder<STATE | ServiceSitesSet>& SetServiceSites(std::unique_ptr<protocol::Array<String>> value);  // Defined below

        std::unique_ptr<RelatedWebsiteSet> Build()
        {
            static_assert(STATE == AllFieldsSet, "state should be AllFieldsSet");
            return std::move(m_result);
        }

    private:
        friend class RelatedWebsiteSet;
        RelatedWebsiteSetBuilder() : m_result(new RelatedWebsiteSet()) { }

        template<int STEP> RelatedWebsiteSetBuilder<STATE | STEP>& castState()
        {
            return *reinterpret_cast<RelatedWebsiteSetBuilder<STATE | STEP>*>(this);
        }

        std::unique_ptr<protocol::Storage::RelatedWebsiteSet> m_result;
    };

    static RelatedWebsiteSetBuilder<0> Create()
    {
        return RelatedWebsiteSetBuilder<0>();
    }

private:
    DECLARE_SERIALIZATION_SUPPORT();

    RelatedWebsiteSet();  // Defined below

    std::unique_ptr<protocol::Array<String>> m_primarySites;
    std::unique_ptr<protocol::Array<String>> m_associatedSites;
    std::unique_ptr<protocol::Array<String>> m_serviceSites;
};


// ------------- Type and builder method definitions.
//
// These methods separate from the type declaration because of
// https://github.com/llvm/llvm-project/issues/59966. The DevTools protocol has
// mutually recursive types, so we cannot simply reorder the types.
inline StorageBucket::~StorageBucket() = default;
inline void StorageBucket::SetStorageKey(const String& value) { m_storageKey = value; }
inline void StorageBucket::SetName(const String& value) { m_name = value; }

template<int STATE>
inline StorageBucket::StorageBucketBuilder<STATE | StorageBucket::StorageBucketBuilder<STATE>::StorageKeySet>&
StorageBucket::StorageBucketBuilder<STATE>::SetStorageKey(const String& value) {
  static_assert(!(STATE & StorageKeySet), "property storageKey should not be set yet");
  m_result->SetStorageKey(value);
  return castState<StorageKeySet>();
}
template<int STATE>
inline StorageBucket::StorageBucketBuilder<STATE>& StorageBucket::StorageBucketBuilder<STATE>::SetName(const String& value) {
  m_result->SetName(value);
  return *this;
}

inline StorageBucket::StorageBucket() {
}
inline StorageBucketInfo::~StorageBucketInfo() = default;
inline void StorageBucketInfo::SetBucket(std::unique_ptr<protocol::Storage::StorageBucket> value) { m_bucket = std::move(value); }
inline void StorageBucketInfo::SetId(const String& value) { m_id = value; }
inline void StorageBucketInfo::SetExpiration(double value) { m_expiration = value; }
inline void StorageBucketInfo::SetQuota(double value) { m_quota = value; }
inline void StorageBucketInfo::SetPersistent(bool value) { m_persistent = value; }
inline void StorageBucketInfo::SetDurability(const String& value) { m_durability = value; }

template<int STATE>
inline StorageBucketInfo::StorageBucketInfoBuilder<STATE | StorageBucketInfo::StorageBucketInfoBuilder<STATE>::BucketSet>&
StorageBucketInfo::StorageBucketInfoBuilder<STATE>::SetBucket(std::unique_ptr<protocol::Storage::StorageBucket> value) {
  static_assert(!(STATE & BucketSet), "property bucket should not be set yet");
  m_result->SetBucket(std::move(value));
  return castState<BucketSet>();
}
template<int STATE>
inline StorageBucketInfo::StorageBucketInfoBuilder<STATE | StorageBucketInfo::StorageBucketInfoBuilder<STATE>::IdSet>&
StorageBucketInfo::StorageBucketInfoBuilder<STATE>::SetId(const String& value) {
  static_assert(!(STATE & IdSet), "property id should not be set yet");
  m_result->SetId(value);
  return castState<IdSet>();
}
template<int STATE>
inline StorageBucketInfo::StorageBucketInfoBuilder<STATE | StorageBucketInfo::StorageBucketInfoBuilder<STATE>::ExpirationSet>&
StorageBucketInfo::StorageBucketInfoBuilder<STATE>::SetExpiration(double value) {
  static_assert(!(STATE & ExpirationSet), "property expiration should not be set yet");
  m_result->SetExpiration(value);
  return castState<ExpirationSet>();
}
template<int STATE>
inline StorageBucketInfo::StorageBucketInfoBuilder<STATE | StorageBucketInfo::StorageBucketInfoBuilder<STATE>::QuotaSet>&
StorageBucketInfo::StorageBucketInfoBuilder<STATE>::SetQuota(double value) {
  static_assert(!(STATE & QuotaSet), "property quota should not be set yet");
  m_result->SetQuota(value);
  return castState<QuotaSet>();
}
template<int STATE>
inline StorageBucketInfo::StorageBucketInfoBuilder<STATE | StorageBucketInfo::StorageBucketInfoBuilder<STATE>::PersistentSet>&
StorageBucketInfo::StorageBucketInfoBuilder<STATE>::SetPersistent(bool value) {
  static_assert(!(STATE & PersistentSet), "property persistent should not be set yet");
  m_result->SetPersistent(value);
  return castState<PersistentSet>();
}
template<int STATE>
inline StorageBucketInfo::StorageBucketInfoBuilder<STATE | StorageBucketInfo::StorageBucketInfoBuilder<STATE>::DurabilitySet>&
StorageBucketInfo::StorageBucketInfoBuilder<STATE>::SetDurability(const String& value) {
  static_assert(!(STATE & DurabilitySet), "property durability should not be set yet");
  m_result->SetDurability(value);
  return castState<DurabilitySet>();
}

inline StorageBucketInfo::StorageBucketInfo() {
  m_expiration = 0;
  m_quota = 0;
  m_persistent = false;
}
inline RelatedWebsiteSet::~RelatedWebsiteSet() = default;
inline void RelatedWebsiteSet::SetPrimarySites(std::unique_ptr<protocol::Array<String>> value) { m_primarySites = std::move(value); }
inline void RelatedWebsiteSet::SetAssociatedSites(std::unique_ptr<protocol::Array<String>> value) { m_associatedSites = std::move(value); }
inline void RelatedWebsiteSet::SetServiceSites(std::unique_ptr<protocol::Array<String>> value) { m_serviceSites = std::move(value); }

template<int STATE>
inline RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE | RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE>::PrimarySitesSet>&
RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE>::SetPrimarySites(std::unique_ptr<protocol::Array<String>> value) {
  static_assert(!(STATE & PrimarySitesSet), "property primarySites should not be set yet");
  m_result->SetPrimarySites(std::move(value));
  return castState<PrimarySitesSet>();
}
template<int STATE>
inline RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE | RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE>::AssociatedSitesSet>&
RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE>::SetAssociatedSites(std::unique_ptr<protocol::Array<String>> value) {
  static_assert(!(STATE & AssociatedSitesSet), "property associatedSites should not be set yet");
  m_result->SetAssociatedSites(std::move(value));
  return castState<AssociatedSitesSet>();
}
template<int STATE>
inline RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE | RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE>::ServiceSitesSet>&
RelatedWebsiteSet::RelatedWebsiteSetBuilder<STATE>::SetServiceSites(std::unique_ptr<protocol::Array<String>> value) {
  static_assert(!(STATE & ServiceSitesSet), "property serviceSites should not be set yet");
  m_result->SetServiceSites(std::move(value));
  return castState<ServiceSitesSet>();
}

inline RelatedWebsiteSet::RelatedWebsiteSet() {
}

// ------------- Backend interface.

class  Backend {
public:
    virtual ~Backend() { }

    class  RunBounceTrackingMitigationsCallback {
    public:
        virtual void sendSuccess(std::unique_ptr<protocol::Array<String>> deletedSites) = 0;
        virtual void sendFailure(const DispatchResponse&) = 0;
        virtual void fallThrough() = 0;
        virtual ~RunBounceTrackingMitigationsCallback() { }
    };
    virtual void RunBounceTrackingMitigations(std::unique_ptr<RunBounceTrackingMitigationsCallback> callback) = 0;
    class  GetRelatedWebsiteSetsCallback {
    public:
        virtual void sendSuccess(std::unique_ptr<protocol::Array<protocol::Storage::RelatedWebsiteSet>> sets) = 0;
        virtual void sendFailure(const DispatchResponse&) = 0;
        virtual void fallThrough() = 0;
        virtual ~GetRelatedWebsiteSetsCallback() { }
    };
    virtual void GetRelatedWebsiteSets(std::unique_ptr<GetRelatedWebsiteSetsCallback> callback) = 0;

    virtual DispatchResponse Disable()
    {
        return DispatchResponse::Success();
    }
};

// ------------- Frontend interface.

class  Frontend {
public:
  explicit Frontend(FrontendChannel* frontend_channel) : frontend_channel_(frontend_channel) {}
    void CacheStorageContentUpdated(const String& origin, const String& storageKey, const String& bucketId, const String& cacheName);
    void CacheStorageListUpdated(const String& origin, const String& storageKey, const String& bucketId);
    void IndexedDBContentUpdated(const String& origin, const String& storageKey, const String& bucketId, const String& databaseName, const String& objectStoreName);
    void IndexedDBListUpdated(const String& origin, const String& storageKey, const String& bucketId);
    void StorageBucketCreatedOrUpdated(std::unique_ptr<protocol::Storage::StorageBucketInfo> bucketInfo);
    void StorageBucketDeleted(const String& bucketId);

  void flush();
  void sendRawNotification(std::unique_ptr<Serializable>);
 private:
  FrontendChannel* frontend_channel_;
};

// ------------- Dispatcher.

class  Dispatcher {
public:
    static void wire(UberDispatcher*, Backend*);

private:
    Dispatcher() { }
};

// ------------- Metainfo.

class  Metainfo {
public:
    using BackendClass = Backend;
    using FrontendClass = Frontend;
    using DispatcherClass = Dispatcher;
    static const char domainName[];
    static const char commandPrefix[];
    static const char version[];
};

} // namespace Storage
} // namespace protocol

#endif // !defined(protocol_Storage_h)
