// Copyright (c) 2019 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. // GENERATED FROM THE API DEFINITION IN // extensions/common/api/storage.json // DO NOT EDIT. #ifndef EXTENSIONS_COMMON_API_STORAGE_H__ #define EXTENSIONS_COMMON_API_STORAGE_H__ #include #include #include #include #include #include "base/logging.h" #include "base/values.h" namespace extensions { namespace api { namespace storage { // // Properties // // Items in the sync storage area are synced using Chrome Sync. namespace sync { // The maximum total amount (in bytes) of data that can be stored in sync // storage, as measured by the JSON stringification of every value plus every // key's length. Updates that would cause this limit to be exceeded fail // immediately and set $(ref:runtime.lastError). extern const int QUOTA_BYTES; // The maximum size (in bytes) of each individual item in sync storage, as // measured by the JSON stringification of its value plus its key length. // Updates containing items larger than this limit will fail immediately and set // $(ref:runtime.lastError). extern const int QUOTA_BYTES_PER_ITEM; // The maximum number of items that can be stored in sync storage. Updates that // would cause this limit to be exceeded will fail immediately and set // $(ref:runtime.lastError). extern const int MAX_ITEMS; //

The maximum number of set, remove, or // clear operations that can be performed each hour. This is 1 // every 2 seconds, a lower ceiling than the short term higher writes-per-minute // limit.

Updates that would cause this limit to be exceeded fail // immediately and set $(ref:runtime.lastError).

extern const int MAX_WRITE_OPERATIONS_PER_HOUR; //

The maximum number of set, remove, or // clear operations that can be performed each minute. This is 2 // per second, providing higher throughput than writes-per-hour over a shorter // period of time.

Updates that would cause this limit to be exceeded fail // immediately and set $(ref:runtime.lastError).

extern const int MAX_WRITE_OPERATIONS_PER_MINUTE; // extern const int MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE; } // namespace sync // Items in the local storage area are local to each machine. namespace local { // The maximum amount (in bytes) of data that can be stored in local storage, as // measured by the JSON stringification of every value plus every key's length. // This value will be ignored if the extension has the // unlimitedStorage permission. Updates that would cause this limit // to be exceeded fail immediately and set $(ref:runtime.lastError). extern const int QUOTA_BYTES; } // namespace local // // Types // struct StorageChange { StorageChange(); ~StorageChange(); StorageChange(StorageChange&& rhs); StorageChange& operator=(StorageChange&& rhs); // Populates a StorageChange object from a base::Value. Returns whether |out| // was successfully populated. static bool Populate(const base::Value& value, StorageChange* out); // Creates a StorageChange object from a base::Value, or NULL on failure. static std::unique_ptr FromValue(const base::Value& value); // Returns a new base::DictionaryValue representing the serialized form of // this StorageChange object. std::unique_ptr ToValue() const; // The old value of the item, if there was an old value. std::unique_ptr old_value; // The new value of the item, if there is a new value. std::unique_ptr new_value; private: DISALLOW_COPY_AND_ASSIGN(StorageChange); }; namespace StorageArea { namespace Get { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // A single key to get, list of keys to get, or a dictionary specifying default // values (see description of the object). An empty list or object will return // an empty result object. Pass in null to get the entire contents // of storage. struct Keys { Keys(); ~Keys(); Keys(Keys&& rhs); Keys& operator=(Keys&& rhs); // Populates a Keys object from a base::Value. Returns whether |out| was // successfully populated. static bool Populate(const base::Value& value, Keys* out); // Storage items to return in the callback, where the values are replaced with // those from storage if they exist. struct Object { Object(); ~Object(); Object(Object&& rhs); Object& operator=(Object&& rhs); // Populates a Object object from a base::Value. Returns whether |out| was // successfully populated. static bool Populate(const base::Value& value, Object* out); base::DictionaryValue additional_properties; private: DISALLOW_COPY_AND_ASSIGN(Object); }; // Choices: std::unique_ptr as_string; std::unique_ptr> as_strings; std::unique_ptr as_object; private: DISALLOW_COPY_AND_ASSIGN(Keys); }; // A single key to get, list of keys to get, or a dictionary specifying default // values (see description of the object). An empty list or object will return // an empty result object. Pass in null to get the entire contents // of storage. std::unique_ptr keys; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { // Object with items in their key-value mappings. struct Items { Items(); ~Items(); Items(Items&& rhs); Items& operator=(Items&& rhs); // Returns a new base::DictionaryValue representing the serialized form of // this Items object. std::unique_ptr ToValue() const; base::DictionaryValue additional_properties; private: DISALLOW_COPY_AND_ASSIGN(Items); }; // Object with items in their key-value mappings. std::unique_ptr Create(const Items& items); } // namespace Results } // namespace Get namespace GetBytesInUse { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // A single key or list of keys to get the total usage for. An empty list will // return 0. Pass in null to get the total usage of all of storage. struct Keys { Keys(); ~Keys(); Keys(Keys&& rhs); Keys& operator=(Keys&& rhs); // Populates a Keys object from a base::Value. Returns whether |out| was // successfully populated. static bool Populate(const base::Value& value, Keys* out); // Choices: std::unique_ptr as_string; std::unique_ptr> as_strings; private: DISALLOW_COPY_AND_ASSIGN(Keys); }; // A single key or list of keys to get the total usage for. An empty list will // return 0. Pass in null to get the total usage of all of storage. std::unique_ptr keys; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { // Amount of space being used in storage, in bytes. std::unique_ptr Create(int bytes_in_use); } // namespace Results } // namespace GetBytesInUse namespace Set { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); //

An object which gives each key/value pair to update storage with. Any // other key/value pairs in storage will not be affected.

Primitive values // such as numbers will serialize as expected. Values with a typeof // "object" and "function" will typically serialize to // {}, with the exception of Array (serializes as // expected), Date, and Regex (serialize using their // String representation).

struct Items { Items(); ~Items(); Items(Items&& rhs); Items& operator=(Items&& rhs); // Populates a Items object from a base::Value. Returns whether |out| was // successfully populated. static bool Populate(const base::Value& value, Items* out); base::DictionaryValue additional_properties; private: DISALLOW_COPY_AND_ASSIGN(Items); }; //

An object which gives each key/value pair to update storage with. Any // other key/value pairs in storage will not be affected.

Primitive values // such as numbers will serialize as expected. Values with a typeof // "object" and "function" will typically serialize to // {}, with the exception of Array (serializes as // expected), Date, and Regex (serialize using their // String representation).

Items items; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(); } // namespace Results } // namespace Set namespace Remove { struct Params { static std::unique_ptr Create(const base::ListValue& args); ~Params(); // A single key or a list of keys for items to remove. struct Keys { Keys(); ~Keys(); Keys(Keys&& rhs); Keys& operator=(Keys&& rhs); // Populates a Keys object from a base::Value. Returns whether |out| was // successfully populated. static bool Populate(const base::Value& value, Keys* out); // Choices: std::unique_ptr as_string; std::unique_ptr> as_strings; private: DISALLOW_COPY_AND_ASSIGN(Keys); }; // A single key or a list of keys for items to remove. Keys keys; private: Params(); DISALLOW_COPY_AND_ASSIGN(Params); }; namespace Results { std::unique_ptr Create(); } // namespace Results } // namespace Remove namespace Clear { namespace Results { std::unique_ptr Create(); } // namespace Results } // namespace Clear } // namespace StorageArea // // Events // namespace OnChanged { extern const char kEventName[]; // "storage.onChanged" // Object mapping each key that changed to its corresponding // $(ref:storage.StorageChange) for that item. struct Changes { Changes(); ~Changes(); Changes(Changes&& rhs); Changes& operator=(Changes&& rhs); // Returns a new base::DictionaryValue representing the serialized form of // this Changes object. std::unique_ptr ToValue() const; std::map additional_properties; private: DISALLOW_COPY_AND_ASSIGN(Changes); }; // Object mapping each key that changed to its corresponding // $(ref:storage.StorageChange) for that item. // The name of the storage area ("sync", "local" or // "managed") the changes are for. std::unique_ptr Create(const Changes& changes, const std::string& area_name); } // namespace OnChanged } // namespace storage } // namespace api } // namespace extensions #endif // EXTENSIONS_COMMON_API_STORAGE_H__