Update to Chromium version 95.0.4638.0 (#920003)

Known issues:
- Windows ARM64 builds are currently failing due to
  https://crbug.com/1242884#c31
This commit is contained in:
Marshall Greenblatt
2021-09-20 12:06:23 +03:00
parent 0a10fd4506
commit 5782fdca16
88 changed files with 597 additions and 645 deletions

View File

@@ -5,12 +5,14 @@
#include "libcef/browser/extensions/value_store/cef_value_store.h"
#include <memory>
#include <ostream>
#include <utility>
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/notreached.h"
namespace value_store {
namespace {
const char kGenericErrorMessage[] = "CefValueStore configured to error";
@@ -23,9 +25,8 @@ ValueStore::Status CreateStatusCopy(const ValueStore::Status& status) {
} // namespace
CefValueStore::CefValueStore() : read_count_(0), write_count_(0) {}
CefValueStore::~CefValueStore() {}
CefValueStore::CefValueStore() = default;
CefValueStore::~CefValueStore() = default;
void CefValueStore::set_status_code(StatusCode status_code) {
status_ = ValueStore::Status(status_code, kGenericErrorMessage);
@@ -33,19 +34,19 @@ void CefValueStore::set_status_code(StatusCode status_code) {
size_t CefValueStore::GetBytesInUse(const std::string& key) {
// Let SettingsStorageQuotaEnforcer implement this.
NOTREACHED();
NOTREACHED() << "Not implemented";
return 0;
}
size_t CefValueStore::GetBytesInUse(const std::vector<std::string>& keys) {
// Let SettingsStorageQuotaEnforcer implement this.
NOTREACHED();
NOTREACHED() << "Not implemented";
return 0;
}
size_t CefValueStore::GetBytesInUse() {
// Let SettingsStorageQuotaEnforcer implement this.
NOTREACHED();
NOTREACHED() << "Not implemented";
return 0;
}
@@ -80,7 +81,7 @@ ValueStore::WriteResult CefValueStore::Set(WriteOptions options,
const std::string& key,
const base::Value& value) {
base::DictionaryValue settings;
settings.SetWithoutPathExpansion(key, value.CreateDeepCopy());
settings.SetKey(key, value.Clone());
return Set(options, settings);
}
@@ -134,4 +135,6 @@ ValueStore::WriteResult CefValueStore::Clear() {
keys.push_back(it.key());
}
return Remove(keys);
}
}
} // namespace value_store

View File

@@ -15,25 +15,29 @@
#include "base/macros.h"
#include "extensions/browser/value_store/value_store.h"
// Implementation Based on TestingValueStore
// ValueStore with an in-memory storage but the ability to
// optionally fail all operations.
namespace value_store {
// Implementation Based on TestingValueStore.
// ValueStore with an in-memory storage but the ability to optionally fail all
// operations.
class CefValueStore : public ValueStore {
public:
CefValueStore();
~CefValueStore() override;
CefValueStore(const CefValueStore&) = delete;
CefValueStore& operator=(const CefValueStore&) = delete;
// Sets the error code for requests. If OK, errors won't be thrown.
// Defaults to OK.
void set_status_code(StatusCode status_code);
// Accessors for the number of reads/writes done by this value store. Each
// Get* operation (except for the BytesInUse ones) counts as one read, and
// each Set*/Remove/Clear operation counts as one write. This is useful in
// tests seeking to assert that some number of reads/writes to their
// underlying value store have (or have not) happened.
int read_count() const { return read_count_; }
int write_count() const { return write_count_; }
// Sets the error code for requests. If OK, errors won't be thrown.
// Defaults to OK.
void set_status_code(StatusCode status_code);
int read_count() { return read_count_; }
int write_count() { return write_count_; }
// ValueStore implementation.
size_t GetBytesInUse(const std::string& key) override;
@@ -53,11 +57,11 @@ class CefValueStore : public ValueStore {
private:
base::DictionaryValue storage_;
int read_count_;
int write_count_;
int read_count_ = 0;
int write_count_ = 0;
ValueStore::Status status_;
DISALLOW_COPY_AND_ASSIGN(CefValueStore);
};
} // namespace value_store
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_VALUE_STORE_CEF_VALUE_STORE_H_

View File

@@ -5,9 +5,11 @@
#include "libcef/browser/extensions/value_store/cef_value_store_factory.h"
#include "libcef/browser/extensions/value_store/cef_value_store.h"
#include "base/containers/contains.h"
#include "base/memory/ptr_util.h"
#include "extensions/browser/value_store/leveldb_value_store.h"
#include "libcef/browser/extensions/value_store/cef_value_store.h"
namespace {
@@ -15,177 +17,58 @@ const char kUMAClientName[] = "Cef";
} // namespace
namespace extensions {
using SettingsNamespace = settings_namespace::Namespace;
CefValueStoreFactory::StorageHelper::StorageHelper() = default;
CefValueStoreFactory::StorageHelper::~StorageHelper() = default;
std::set<ExtensionId> CefValueStoreFactory::StorageHelper::GetKnownExtensionIDs(
ModelType model_type) const {
std::set<ExtensionId> ids;
switch (model_type) {
case ValueStoreFactory::ModelType::APP:
for (const auto& key : app_stores_)
ids.insert(key.first);
break;
case ValueStoreFactory::ModelType::EXTENSION:
for (const auto& key : extension_stores_)
ids.insert(key.first);
break;
}
return ids;
}
void CefValueStoreFactory::StorageHelper::Reset() {
app_stores_.clear();
extension_stores_.clear();
}
ValueStore* CefValueStoreFactory::StorageHelper::AddValueStore(
const ExtensionId& extension_id,
ValueStore* value_store,
ModelType model_type) {
if (model_type == ValueStoreFactory::ModelType::APP) {
DCHECK(app_stores_.find(extension_id) == app_stores_.end());
app_stores_[extension_id] = value_store;
} else {
DCHECK(extension_stores_.find(extension_id) == extension_stores_.end());
extension_stores_[extension_id] = value_store;
}
return value_store;
}
void CefValueStoreFactory::StorageHelper::DeleteSettings(
const ExtensionId& extension_id,
ModelType model_type) {
switch (model_type) {
case ValueStoreFactory::ModelType::APP:
app_stores_.erase(extension_id);
break;
case ValueStoreFactory::ModelType::EXTENSION:
extension_stores_.erase(extension_id);
break;
}
}
bool CefValueStoreFactory::StorageHelper::HasSettings(
const ExtensionId& extension_id,
ModelType model_type) const {
switch (model_type) {
case ValueStoreFactory::ModelType::APP:
return app_stores_.find(extension_id) != app_stores_.end();
case ValueStoreFactory::ModelType::EXTENSION:
return extension_stores_.find(extension_id) != extension_stores_.end();
}
NOTREACHED();
return false;
}
ValueStore* CefValueStoreFactory::StorageHelper::GetExisting(
const ExtensionId& extension_id) const {
auto it = app_stores_.find(extension_id);
if (it != app_stores_.end())
return it->second;
it = extension_stores_.find(extension_id);
if (it != extension_stores_.end())
return it->second;
return nullptr;
}
namespace value_store {
CefValueStoreFactory::CefValueStoreFactory() = default;
CefValueStoreFactory::CefValueStoreFactory(const base::FilePath& db_path)
: db_path_(db_path) {}
CefValueStoreFactory::~CefValueStoreFactory() {}
CefValueStoreFactory::~CefValueStoreFactory() = default;
std::unique_ptr<ValueStore> CefValueStoreFactory::CreateRulesStore() {
if (db_path_.empty())
last_created_store_ = new CefValueStore();
else
last_created_store_ = new LeveldbValueStore(kUMAClientName, db_path_);
return base::WrapUnique(last_created_store_);
}
std::unique_ptr<ValueStore> CefValueStoreFactory::CreateStateStore() {
return CreateRulesStore();
}
CefValueStoreFactory::StorageHelper& CefValueStoreFactory::GetStorageHelper(
SettingsNamespace settings_namespace) {
switch (settings_namespace) {
case settings_namespace::LOCAL:
return local_helper_;
case settings_namespace::SYNC:
return sync_helper_;
case settings_namespace::MANAGED:
return managed_helper_;
case settings_namespace::INVALID:
break;
}
NOTREACHED();
return local_helper_;
}
std::unique_ptr<ValueStore> CefValueStoreFactory::CreateSettingsStore(
SettingsNamespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) {
std::unique_ptr<ValueStore> settings_store(CreateRulesStore());
// Note: This factory is purposely keeping the raw pointers to each ValueStore
// created. Tests using CefValueStoreFactory must be careful to keep
// those ValueStore's alive for the duration of their test.
GetStorageHelper(settings_namespace)
.AddValueStore(extension_id, settings_store.get(), model_type);
return settings_store;
std::unique_ptr<ValueStore> CefValueStoreFactory::CreateValueStore(
const base::FilePath& directory,
const std::string& uma_client_name) {
std::unique_ptr<ValueStore> value_store(CreateStore());
// This factory is purposely keeping the raw pointers to each ValueStore
// created. Cefs using CefValueStoreFactory must be careful to keep
// those ValueStore's alive for the duration of their test.
value_store_map_[directory] = value_store.get();
return value_store;
}
ValueStore* CefValueStoreFactory::LastCreatedStore() const {
return last_created_store_;
}
void CefValueStoreFactory::DeleteSettings(SettingsNamespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) {
GetStorageHelper(settings_namespace).DeleteSettings(extension_id, model_type);
void CefValueStoreFactory::DeleteValueStore(const base::FilePath& directory) {
value_store_map_.erase(directory);
}
bool CefValueStoreFactory::HasSettings(SettingsNamespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) {
return GetStorageHelper(settings_namespace)
.HasSettings(extension_id, model_type);
}
std::set<ExtensionId> CefValueStoreFactory::GetKnownExtensionIDs(
SettingsNamespace settings_namespace,
ModelType model_type) const {
return const_cast<CefValueStoreFactory*>(this)
->GetStorageHelper(settings_namespace)
.GetKnownExtensionIDs(model_type);
bool CefValueStoreFactory::HasValueStore(const base::FilePath& directory) {
return base::Contains(value_store_map_, directory);
}
ValueStore* CefValueStoreFactory::GetExisting(
const ExtensionId& extension_id) const {
ValueStore* existing_store = local_helper_.GetExisting(extension_id);
if (existing_store)
return existing_store;
existing_store = sync_helper_.GetExisting(extension_id);
if (existing_store)
return existing_store;
existing_store = managed_helper_.GetExisting(extension_id);
DCHECK(existing_store != nullptr);
return existing_store;
const base::FilePath& directory) const {
auto it = value_store_map_.find(directory);
DCHECK(it != value_store_map_.end());
return it->second;
}
void CefValueStoreFactory::Reset() {
last_created_store_ = nullptr;
local_helper_.Reset();
sync_helper_.Reset();
managed_helper_.Reset();
value_store_map_.clear();
}
} // namespace extensions
std::unique_ptr<ValueStore> CefValueStoreFactory::CreateStore() {
std::unique_ptr<ValueStore> store;
if (db_path_.empty())
store = std::make_unique<CefValueStore>();
else
store = std::make_unique<LeveldbValueStore>(kUMAClientName, db_path_);
last_created_store_ = store.get();
return store;
}
} // namespace value_store

View File

@@ -8,90 +8,54 @@
#include <map>
#include <memory>
#include <set>
#include "base/files/file_path.h"
#include "extensions/browser/value_store/value_store_factory.h"
#include "extensions/common/extension_id.h"
namespace value_store {
class ValueStore;
namespace extensions {
// Will either open a database on disk (if path provided) returning a
// |LeveldbValueStore|. Otherwise a new |CefValueStore| instance will be
// returned.
// Based on TestValueStoreFactory. Will either open a database on disk (if path
// provided) returning a |LeveldbValueStore|. Otherwise a new |CefingValueStore|
// instance will be returned.
class CefValueStoreFactory : public ValueStoreFactory {
public:
CefValueStoreFactory();
explicit CefValueStoreFactory(const base::FilePath& db_path);
CefValueStoreFactory(const CefValueStoreFactory&) = delete;
CefValueStoreFactory& operator=(const CefValueStoreFactory&) = delete;
// ValueStoreFactory
std::unique_ptr<ValueStore> CreateRulesStore() override;
std::unique_ptr<ValueStore> CreateStateStore() override;
std::unique_ptr<ValueStore> CreateSettingsStore(
settings_namespace::Namespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) override;
void DeleteSettings(settings_namespace::Namespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) override;
bool HasSettings(settings_namespace::Namespace settings_namespace,
ModelType model_type,
const ExtensionId& extension_id) override;
std::set<ExtensionId> GetKnownExtensionIDs(
settings_namespace::Namespace settings_namespace,
ModelType model_type) const override;
std::unique_ptr<ValueStore> CreateValueStore(
const base::FilePath& directory,
const std::string& uma_client_name) override;
void DeleteValueStore(const base::FilePath& directory) override;
bool HasValueStore(const base::FilePath& directory) override;
// Return the last created |ValueStore|. Use with caution as this may return
// a dangling pointer since the creator now owns the ValueStore which can be
// deleted at any time.
ValueStore* LastCreatedStore() const;
// Return a previously created |ValueStore| for an extension.
ValueStore* GetExisting(const ExtensionId& extension_id) const;
// Return the previously created |ValueStore| in the given directory.
ValueStore* GetExisting(const base::FilePath& directory) const;
// Reset this class (as if just created).
void Reset();
private:
// Manages a collection of |ValueStore|'s created for an app/extension.
// One of these exists for each setting type.
class StorageHelper {
public:
StorageHelper();
~StorageHelper();
std::set<ExtensionId> GetKnownExtensionIDs(ModelType model_type) const;
ValueStore* AddValueStore(const ExtensionId& extension_id,
ValueStore* value_store,
ModelType model_type);
void DeleteSettings(const ExtensionId& extension_id, ModelType model_type);
bool HasSettings(const ExtensionId& extension_id,
ModelType model_type) const;
void Reset();
ValueStore* GetExisting(const ExtensionId& extension_id) const;
private:
std::map<ExtensionId, ValueStore*> app_stores_;
std::map<ExtensionId, ValueStore*> extension_stores_;
DISALLOW_COPY_AND_ASSIGN(StorageHelper);
};
StorageHelper& GetStorageHelper(
settings_namespace::Namespace settings_namespace);
~CefValueStoreFactory() override;
std::unique_ptr<ValueStore> CreateStore();
base::FilePath db_path_;
ValueStore* last_created_store_ = nullptr;
// None of these value stores are owned by this factory, so care must be
// taken when calling GetExisting.
StorageHelper local_helper_;
StorageHelper sync_helper_;
StorageHelper managed_helper_;
DISALLOW_COPY_AND_ASSIGN(CefValueStoreFactory);
// A mapping from directories to their ValueStore. None of these value
// stores are owned by this factory, so care must be taken when calling
// GetExisting.
std::map<base::FilePath, ValueStore*> value_store_map_;
};
} // namespace extensions
} // namespace value_store
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_VALUE_STORE_CEF_VALUE_STORE_FACTORY_H_