cef/libcef/browser/net/crlset_file_util_impl.cc
Marshall Greenblatt 67b61c4af9 Remove the old network implementation (see issue #2622)
The `--disable-features=NetworkService` flag is no longer supported.
2019-07-29 17:41:45 -04:00

47 lines
1.3 KiB
C++

// Copyright 2017 The Chromium Embedded Framework 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 "include/cef_file_util.h"
#include "libcef/browser/context.h"
#include "libcef/browser/thread_util.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "content/public/browser/network_service_instance.h"
#include "services/network/network_service.h"
namespace {
void UpdateCRLSet(const std::string& crl_set_bytes) {
CEF_REQUIRE_UIT();
content::GetNetworkService()->UpdateCRLSet(
base::as_bytes(base::make_span(crl_set_bytes)));
}
void LoadFromDisk(const base::FilePath& path) {
CEF_REQUIRE_BLOCKING();
std::string crl_set_bytes;
if (!base::ReadFileToString(path, &crl_set_bytes)) {
LOG(WARNING) << "Failed to read CRL set from " << path.MaybeAsASCII();
return;
}
VLOG(1) << "Loading " << crl_set_bytes.size()
<< " bytes of CRL set from disk";
CEF_POST_TASK(CEF_UIT, base::BindOnce(&UpdateCRLSet, crl_set_bytes));
}
} // namespace
void CefLoadCRLSetsFile(const CefString& path) {
if (!CONTEXT_STATE_VALID()) {
NOTREACHED() << "context not valid";
return;
}
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(&LoadFromDisk, path));
}