Skip to content

Commit

Permalink
added ipfs common header
Browse files Browse the repository at this point in the history
Signed-off-by: Vadym Struts <vstruts@brave.com>
  • Loading branch information
vadimstruts committed Sep 5, 2024
1 parent da21ed0 commit 61ed0ff
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 32 deletions.
4 changes: 1 addition & 3 deletions browser/brave_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@

#if !BUILDFLAG(IS_ANDROID)
#include "base/path_service.h"
#include "brave/browser/ipfs/ipfs_common.h"
#include "brave/components/ipfs/ipfs_component_cleaner.h"
#include "chrome/common/chrome_paths.h"
#endif // !BUILDFLAG(IS_ANDROID)
Expand Down Expand Up @@ -169,8 +168,7 @@ void BraveBrowserMainParts::PostBrowserStart() {

#if !BUILDFLAG(IS_ANDROID)
ipfs::CleanupIpfsComponent(
base::PathService::CheckedGet(chrome::DIR_USER_DATA)
.Append(kIpfsClientComponentId));
base::PathService::CheckedGet(chrome::DIR_USER_DATA));
#endif // !BUILDFLAG(IS_ANDROID)
}

Expand Down
17 changes: 0 additions & 17 deletions browser/ipfs/sources.gni

This file was deleted.

3 changes: 0 additions & 3 deletions browser/sources.gni
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import("//brave/browser/gcm_driver/sources.gni")
import("//brave/browser/greaselion/sources.gni")
import("//brave/browser/importer/sources.gni")
import("//brave/browser/infobars/sources.gni")
import("//brave/browser/ipfs/sources.gni")
import("//brave/browser/misc_metrics/sources.gni")
import("//brave/browser/net/sources.gni")
import("//brave/browser/new_tab/sources.gni")
Expand Down Expand Up @@ -501,7 +500,6 @@ brave_chrome_browser_sources += brave_browser_themes_sources
brave_chrome_browser_sources += brave_browser_tor_sources
brave_chrome_browser_sources += brave_browser_url_sanitizer_sources
brave_chrome_browser_sources += brave_browser_web_discovery_sources
brave_chrome_browser_sources += brave_browser_ipfs_sources

brave_chrome_browser_deps += brave_browser_autocomplete_deps
brave_chrome_browser_deps += brave_browser_brave_adaptive_captcha_deps
Expand Down Expand Up @@ -541,6 +539,5 @@ brave_chrome_browser_deps += brave_browser_url_sanitizer_deps
brave_chrome_browser_deps += brave_browser_web_discovery_deps
brave_chrome_browser_deps += brave_chromium_src_chrome_browser_deps
brave_chrome_browser_deps += brave_chromium_src_chrome_browser_prefs_deps
brave_chrome_browser_deps += brave_browser_ipfs_deps

brave_chrome_browser_allow_circular_includes_from = [ "//brave/browser/ui" ]
1 change: 1 addition & 0 deletions components/ipfs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static_library("ipfs") {

if (!is_android) {
sources += [
"ipfs_common.h",
"ipfs_component_cleaner.cc",
"ipfs_component_cleaner.h",
]
Expand Down
6 changes: 3 additions & 3 deletions browser/ipfs/ipfs_common.h → components/ipfs/ipfs_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// 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_BROWSER_IPFS_IPFS_COMMON_H_
#define BRAVE_BROWSER_IPFS_IPFS_COMMON_H_
#ifndef BRAVE_COMPONENTS_IPFS_IPFS_COMMON_H_
#define BRAVE_COMPONENTS_IPFS_IPFS_COMMON_H_

#include "base/files/file_path.h"
#include "build/build_config.h"
Expand All @@ -30,4 +30,4 @@ static const base::FilePath::StringPieceType kIpfsClientComponentId =
#endif
#endif

#endif // BRAVE_BROWSER_IPFS_IPFS_COMMON_H_
#endif // BRAVE_COMPONENTS_IPFS_IPFS_COMMON_H_
6 changes: 4 additions & 2 deletions components/ipfs/ipfs_component_cleaner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
#include "base/files/file_util.h"
#include "base/path_service.h"
#include "base/task/thread_pool.h"
#include "brave/components/ipfs/ipfs_common.h"
#include "build/build_config.h"

namespace ipfs {
void CleanupIpfsComponent(const base::FilePath& component_path) {
void CleanupIpfsComponent(const base::FilePath& user_data_dir) {
// Remove IPFS component
base::ThreadPool::PostTask(
FROM_HERE, {base::TaskPriority::BEST_EFFORT, base::MayBlock()},
base::GetDeletePathRecursivelyCallback(component_path));
base::GetDeletePathRecursivelyCallback(
user_data_dir.Append(kIpfsClientComponentId)));
}
} // namespace ipfs
2 changes: 1 addition & 1 deletion components/ipfs/ipfs_component_cleaner.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "base/files/file_path.h"

namespace ipfs {
void CleanupIpfsComponent(const base::FilePath& component_path);
void CleanupIpfsComponent(const base::FilePath& user_data_dir);
} // namespace ipfs

#endif // BRAVE_COMPONENTS_IPFS_IPFS_COMPONENT_CLEANER_H_
5 changes: 2 additions & 3 deletions components/ipfs/ipfs_component_cleaner_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "brave/browser/ipfs/ipfs_common.h"
#include "brave/components/ipfs/ipfs_common.h"
#include "build/build_config.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/common/chrome_paths.h"
Expand Down Expand Up @@ -68,8 +68,7 @@ TEST_F(IpfsComponentCleanerUnitTest, CleanIpfsComponent) {
base::WriteFile(component_id_folde_subdir_file_01, "12345678901234567890");

ipfs::CleanupIpfsComponent(
base::PathService::CheckedGet(chrome::DIR_USER_DATA)
.Append(kIpfsClientComponentId));
base::PathService::CheckedGet(chrome::DIR_USER_DATA));
task_environment_.RunUntilIdle();
EXPECT_TRUE(base::PathExists(cache_folder));
EXPECT_FALSE(base::PathExists(component_id_folder));
Expand Down

0 comments on commit 61ed0ff

Please sign in to comment.