Skip to content

Commit

Permalink
rm TestContext
Browse files Browse the repository at this point in the history
  • Loading branch information
John-LittleBearLabs committed Feb 13, 2024
1 parent 48c219c commit 8c1c76b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion cmake/chromium.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
44 changes: 44 additions & 0 deletions library/include/ipfs_client/opinionated_context.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef IPFS_OPINIONATED_CONTEXT_H_
#define IPFS_OPINIONATED_CONTEXT_H_

#include <ipfs_client/crypto/openssl_signature_verifier.h>
#include <ipfs_client/ctx/ares_dns_txt_lookup.h>
#include <ipfs_client/ctx/boost_beast_http.h>

#include <ipfs_client/context_api.h>
#include <ipfs_client/orchestrator.h>

#include <memory>

#if HAS_BOOST_BEAST && HAS_ARES && HAS_OPENSSL_EVP

#define HAS_OPINIONATED_CONTEXT 1

#include <google/protobuf/stubs/logging.h>

namespace boost::asio {
class io_context;
}

namespace google::protobuf {
constexpr LogLevel LOGLEVEL_DEBUG = static_cast<LogLevel>(-1);
constexpr LogLevel LOGLEVEL_TRACE = static_cast<LogLevel>(-2);
} // namespace google::protobuf

class HttpSession;

namespace ipfs {

std::pair<std::shared_ptr<ContextApi>, std::shared_ptr<Orchestrator>>
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_
74 changes: 0 additions & 74 deletions library/include/ipfs_client/test_context.h

This file was deleted.

22 changes: 22 additions & 0 deletions library/src/ipfs_client/opinionated_context.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <ipfs_client/opinionated_context.h>

#include <ipfs_client/gw/default_requestor.h>

#if HAS_OPINIONATED_CONTEXT

auto ipfs::start_default(boost::asio::io_context& io)
-> std::pair<std::shared_ptr<ContextApi>, std::shared_ptr<Orchestrator>> {
auto api = std::make_shared<ContextApi>();
using SKT = crypto::SigningKeyType;
api->with(std::make_unique<ctx::BoostBeastHttp>(io))
.with(std::make_unique<ctx::AresDnsTxtLookup>(&io))
.with(SKT::RSA,
std::make_unique<crypto::OpensslSignatureVerifier>(EVP_PKEY_RSA))
.with(SKT::Ed25519, std::make_unique<crypto::OpensslSignatureVerifier>(
EVP_PKEY_ED25519));
auto rtor = gw::default_requestor({}, api);
auto orc = std::make_shared<Orchestrator>(rtor, api);
return {api, orc};
}

#endif // HAS_OPINIONATED_CONTEXT
14 changes: 0 additions & 14 deletions library/src/ipfs_client/test_context.cc

This file was deleted.

0 comments on commit 8c1c76b

Please sign in to comment.