-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vadym Struts <[email protected]>
- Loading branch information
1 parent
76cfba8
commit fa79b0c
Showing
11 changed files
with
179 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#include "brave/components/ipfs/ipfs_component_cleaner.h" | ||
|
||
#include "base/files/file_util.h" | ||
#include "base/path_service.h" | ||
#include "base/task/thread_pool.h" | ||
#include "build/build_config.h" | ||
#include "chrome/common/chrome_paths.h" | ||
|
||
namespace { | ||
#if BUILDFLAG(IS_WIN) | ||
static const base::FilePath::StringPieceType kIpfsClientComponentId = | ||
FILE_PATH_LITERAL("lnbclahgobmjphilkalbhebakmblnbij"); | ||
#elif BUILDFLAG(IS_MAC) | ||
#if defined(ARCH_CPU_ARM64) | ||
static const base::FilePath::StringPieceType kIpfsClientComponentId = | ||
FILE_PATH_LITERAL("lejaflgbgglfaomemffoaappaihfligf"); | ||
#else | ||
static const base::FilePath::StringPieceType kIpfsClientComponentId = | ||
FILE_PATH_LITERAL("nljcddpbnaianmglkpkneakjaapinabi"); | ||
#endif | ||
#elif BUILDFLAG(IS_LINUX) | ||
#if defined(ARCH_CPU_ARM64) | ||
static const base::FilePath::StringPieceType kIpfsClientComponentId = | ||
FILE_PATH_LITERAL("fmmldihckdnognaabhligdpckkeancng"); | ||
#else | ||
static const base::FilePath::StringPieceType kIpfsClientComponentId = | ||
FILE_PATH_LITERAL("oecghfpdmkjlhnfpmmjegjacfimiafjp"); | ||
#endif | ||
#else | ||
// Not used yet for Android/iOS | ||
static const base::FilePath::StringPieceType kIpfsClientComponentId = | ||
FILE_PATH_LITERAL(""); | ||
#endif | ||
} // namespace | ||
|
||
namespace ipfs { | ||
|
||
base::FilePath::StringPieceType GetIpfsClientComponentId() { | ||
return kIpfsClientComponentId; | ||
} | ||
|
||
base::FilePath GetIpfsClientComponentPath() { | ||
base::FilePath user_data_dir; | ||
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | ||
return user_data_dir.Append(GetIpfsClientComponentId()); | ||
} | ||
|
||
void DeleteIpfsComponent(const base::FilePath& component_path) { | ||
if (component_path.empty()) { | ||
return; | ||
} | ||
// Remove IPFS component | ||
base::ThreadPool::PostTask( | ||
FROM_HERE, {base::TaskPriority::BEST_EFFORT, base::MayBlock()}, | ||
base::BindOnce(IgnoreResult(&base::DeletePathRecursively), | ||
component_path)); | ||
} | ||
|
||
} // namespace ipfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#ifndef BRAVE_COMPONENTS_IPFS_IPFS_COMPONENT_CLEANER_H_ | ||
#define BRAVE_COMPONENTS_IPFS_IPFS_COMPONENT_CLEANER_H_ | ||
|
||
#include "base/files/file_path.h" | ||
|
||
namespace ipfs { | ||
|
||
base::FilePath::StringPieceType GetIpfsClientComponentId(); | ||
|
||
base::FilePath GetIpfsClientComponentPath(); | ||
|
||
void DeleteIpfsComponent(const base::FilePath& component_path); | ||
} // namespace ipfs | ||
|
||
#endif // BRAVE_COMPONENTS_IPFS_IPFS_COMPONENT_CLEANER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#import("//brave/build/config.gni") | ||
#import("//brave/components/ipfs/buildflags/buildflags.gni") | ||
import("//testing/test.gni") | ||
source_set("brave_ipfs_unit_tests") { | ||
testonly = true | ||
|
||
sources = [ "//brave/components/ipfs/ipfs_utils_unittest.cc" ] | ||
|
||
deps = [ | ||
"//base/test:test_support", | ||
"//brave/components/ipfs", | ||
"//chrome/browser:browser", | ||
"//chrome/browser/sync:factories", | ||
"//chrome/browser/sync:sync", | ||
"//chrome/test:test_support", | ||
"//components/sync_preferences:test_support", | ||
"//content/test:test_support", | ||
"//net", | ||
] | ||
} # source_set("brave_ipfs_unit_tests") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.