From 8c1c76ba1e4bcd0fed2daaf9a9e3bc69bcc2faf1 Mon Sep 17 00:00:00 2001 From: John Turpish Date: Tue, 13 Feb 2024 13:01:32 -0500 Subject: [PATCH] rm TestContext --- .../chrome_content_browser_client.cc.patch | 3 +- cmake/chromium.py | 2 +- .../include/ipfs_client/opinionated_context.h | 44 +++++++++++ library/include/ipfs_client/test_context.h | 74 ------------------- .../src/ipfs_client/opinionated_context.cc | 22 ++++++ library/src/ipfs_client/test_context.cc | 14 ---- 6 files changed, 69 insertions(+), 90 deletions(-) create mode 100644 library/include/ipfs_client/opinionated_context.h delete mode 100644 library/include/ipfs_client/test_context.h create mode 100644 library/src/ipfs_client/opinionated_context.cc delete mode 100644 library/src/ipfs_client/test_context.cc diff --git a/chromium_edits/122.0.6236.2/chrome/browser/chrome_content_browser_client.cc.patch b/chromium_edits/122.0.6236.2/chrome/browser/chrome_content_browser_client.cc.patch index a991fd2e..2ba498b0 100644 --- a/chromium_edits/122.0.6236.2/chrome/browser/chrome_content_browser_client.cc.patch +++ b/chromium_edits/122.0.6236.2/chrome/browser/chrome_content_browser_client.cc.patch @@ -46,7 +46,8 @@ index a9f0eb5ab9151..8956d3ca5519e 100644 RenderFrameHost::FromID(render_process_id, render_frame_id); WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host); #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ - // !BUILDFLAG(IS_ANDROID) +- // !BUILDFLAG(IS_ANDROID) ++ // !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS) +#if BUILDFLAG(ENABLE_IPFS) + if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { + network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory(); diff --git a/cmake/chromium.py b/cmake/chromium.py index cb1b3d7e..16f861bf 100755 --- a/cmake/chromium.py +++ b/cmake/chromium.py @@ -157,7 +157,7 @@ def copy_missing_and_changed_files(source, target): if not isdir(t): makedirs(t) continue - if s.endswith('_unittest.cc') or basename(s).startswith('test_'): + if s.endswith('_unittest.cc') or basename(s).startswith('opinionated_'): continue ext = splitext(s)[-1] if ext in ignore_exts: diff --git a/library/include/ipfs_client/opinionated_context.h b/library/include/ipfs_client/opinionated_context.h new file mode 100644 index 00000000..f81787b1 --- /dev/null +++ b/library/include/ipfs_client/opinionated_context.h @@ -0,0 +1,44 @@ +#ifndef IPFS_OPINIONATED_CONTEXT_H_ +#define IPFS_OPINIONATED_CONTEXT_H_ + +#include +#include +#include + +#include +#include + +#include + +#if HAS_BOOST_BEAST && HAS_ARES && HAS_OPENSSL_EVP + +#define HAS_OPINIONATED_CONTEXT 1 + +#include + +namespace boost::asio { +class io_context; +} + +namespace google::protobuf { +constexpr LogLevel LOGLEVEL_DEBUG = static_cast(-1); +constexpr LogLevel LOGLEVEL_TRACE = static_cast(-2); +} // namespace google::protobuf + +class HttpSession; + +namespace ipfs { + +std::pair, std::shared_ptr> +start_default(boost::asio::io_context& io); + +} // namespace ipfs + +#else + +#warning \ + "You are missing dependencies necessary for using the opinionated context." + +#endif // HAS_BOOST_BEAST && HAS_ARES && HAS_OPENSSL_EVP + +#endif // IPFS_OPINIONATED_CONTEXT_H_ diff --git a/library/include/ipfs_client/test_context.h b/library/include/ipfs_client/test_context.h deleted file mode 100644 index f9ad7352..00000000 --- a/library/include/ipfs_client/test_context.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef IPFS_ALL_INCLUSIVE_CONTEXT_H_ -#define IPFS_ALL_INCLUSIVE_CONTEXT_H_ - -#ifdef _MSC_VER -// #warning "AllInclusiveContext has not been ported to Windows." -#else - -#include "gw/default_requestor.h" - -#include "context_api.h" -#include "crypto/openssl_signature_verifier.h" -#include "ctx/ares_dns_txt_lookup.h" -#include "ctx/boost_beast_http.h" -#include "dag_cbor_value.h" -#include "json_cbor_adapter.h" -#include "orchestrator.h" - -#include - -#include - -#include - -#if ! __has_include() -#warning "One needs access to Boost to use this header" -#elif !HAS_JSON_CBOR_ADAPTER -#warning "One needs access to nlohmann/json to use this header" -#else - -#define HAS_ALL_INCLUSIVE 1 - -namespace boost::asio { -class io_context; -} - -namespace google::protobuf { -constexpr LogLevel LOGLEVEL_DEBUG = static_cast(-1); -constexpr LogLevel LOGLEVEL_TRACE = static_cast(-2); -} // namespace google::protobuf - -class HttpSession; - -namespace ipfs { - -// LCOV_EXCL_START - -class TestContext final : public ContextApi { - boost::asio::io_context& io_; - - public: - TestContext(boost::asio::io_context& io); - ~TestContext() noexcept override; -}; -inline std::pair, std::shared_ptr> -start_default(boost::asio::io_context& io) { - auto api = std::make_shared(io); - using SKT = crypto::SigningKeyType; - api->with(std::make_unique(io)) - .with(std::make_unique(&io)) - .with(SKT::RSA, - std::make_unique(EVP_PKEY_RSA)) - .with(SKT::Ed25519, std::make_unique( - EVP_PKEY_ED25519)); - auto rtor = gw::default_requestor({}, api); - auto orc = std::make_shared(rtor, api); - return {api, orc}; -} - -} // namespace ipfs - -#endif // boost - -#endif //_MSC_VER -#endif // IPFS_ALL_INCLUSIVE_CONTEXT_H_ diff --git a/library/src/ipfs_client/opinionated_context.cc b/library/src/ipfs_client/opinionated_context.cc new file mode 100644 index 00000000..c45f3f9f --- /dev/null +++ b/library/src/ipfs_client/opinionated_context.cc @@ -0,0 +1,22 @@ +#include + +#include + +#if HAS_OPINIONATED_CONTEXT + +auto ipfs::start_default(boost::asio::io_context& io) + -> std::pair, std::shared_ptr> { + auto api = std::make_shared(); + using SKT = crypto::SigningKeyType; + api->with(std::make_unique(io)) + .with(std::make_unique(&io)) + .with(SKT::RSA, + std::make_unique(EVP_PKEY_RSA)) + .with(SKT::Ed25519, std::make_unique( + EVP_PKEY_ED25519)); + auto rtor = gw::default_requestor({}, api); + auto orc = std::make_shared(rtor, api); + return {api, orc}; +} + +#endif // HAS_OPINIONATED_CONTEXT \ No newline at end of file diff --git a/library/src/ipfs_client/test_context.cc b/library/src/ipfs_client/test_context.cc deleted file mode 100644 index ffbf8122..00000000 --- a/library/src/ipfs_client/test_context.cc +++ /dev/null @@ -1,14 +0,0 @@ -#include - -#if HAS_ALL_INCLUSIVE - -#include "log_macros.h" - -using Self = ipfs::TestContext; - -// LCOV_EXCL_START - -Self::TestContext(boost::asio::io_context& io) : io_{io} {} -Self::~TestContext() {} - -#endif