Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(627)

Unified Diff: chrome/browser/translate/component_cld_data_harness.cc

Issue 2034413003: Delete the non-static CLD data source logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to latest master Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/translate/component_cld_data_harness.cc
diff --git a/chrome/browser/translate/component_cld_data_harness.cc b/chrome/browser/translate/component_cld_data_harness.cc
deleted file mode 100644
index dc5f1bd3175da84e6d153edf36b27cfd22c662b3..0000000000000000000000000000000000000000
--- a/chrome/browser/translate/component_cld_data_harness.cc
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2014 The Chromium 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 "chrome/browser/translate/component_cld_data_harness.h"
-
-#include "base/base_paths.h"
-#include "base/files/file_util.h"
-#include "base/logging.h"
-#include "base/path_service.h"
-#include "chrome/browser/component_updater/cld_component_installer.h"
-#include "chrome/common/chrome_paths.h"
-#include "components/component_updater/component_updater_paths.h"
-#include "components/translate/content/common/cld_data_source.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-// This has to match what's in cld_component_installer.cc.
-const base::FilePath::CharType kComponentDataFileName[] =
- FILE_PATH_LITERAL("cld2_data.bin");
-
-} // namespace
-
-namespace test {
-
-ComponentCldDataHarness::~ComponentCldDataHarness() {
- DVLOG(1) << "Tearing down CLD data harness";
- // Dynamic data mode is enabled and we are using the component updater.
- component_updater::CldComponentInstallerTraits::SetLatestCldDataFile(
- base::FilePath());
- ClearComponentDataFileState();
- DeleteComponentTree();
-}
-
-void ComponentCldDataHarness::Init() {
- DVLOG(1) << "Initializing CLD data harness";
- // Dynamic data mode is enabled and we are using the component updater.
- translate::CldDataSource::Set(
- translate::CldDataSource::GetComponentDataSource());
- ASSERT_NO_FATAL_FAILURE(CopyComponentTree());
- base::FilePath data_file;
- GetComponentDataFileDestination(&data_file);
- component_updater::CldComponentInstallerTraits::SetLatestCldDataFile(
- data_file);
-}
-
-void ComponentCldDataHarness::ClearComponentDataFileState() {
- DVLOG(1) << "Clearing component CLD data file state";
- base::FilePath nothing;
- component_updater::CldComponentInstallerTraits::SetLatestCldDataFile(nothing);
-}
-
-// DIR_COMPONENT_CLD2 is also defined as being relative to USER_DATA_DIR, so
-// like GetStandaloneDataFileDestination, this is safe to run in multiple
-// parallel test processes.
-void ComponentCldDataHarness::GetExtractedComponentDestination(
- base::FilePath* out_path) {
- ASSERT_TRUE(PathService::Get(component_updater::DIR_COMPONENT_CLD2,
- out_path));
-}
-
-void ComponentCldDataHarness::GetComponentDataFileDestination(
- base::FilePath* out_path) {
- GetExtractedComponentDestination(out_path);
- *out_path = out_path->Append(CldDataHarness::GetTestDataSourceCrxVersion())
- .Append(FILE_PATH_LITERAL("_platform_specific"))
- .Append(FILE_PATH_LITERAL("all"))
- .Append(kComponentDataFileName);
-}
-
-void ComponentCldDataHarness::DeleteComponentTree() {
- base::FilePath tree_path;
- ASSERT_NO_FATAL_FAILURE(GetExtractedComponentDestination(&tree_path));
- DVLOG(1) << "Deleting CLD component test files from " << tree_path.value();
- base::DeleteFile(tree_path, true);
-}
-
-void ComponentCldDataHarness::CopyComponentTree() {
- DeleteComponentTree(); // sanity: blow away any old copies.
- base::FilePath target_dir;
- GetExtractedComponentDestination(&target_dir);
- base::FilePath source_dir;
- CldDataHarness::GetTestDataSourceDirectory(&source_dir);
- DVLOG(1) << "Copying CLD component test files from " << source_dir.value()
- << " to " << target_dir.value();
- ASSERT_TRUE(base::CreateDirectoryAndGetError(target_dir, NULL));
- ASSERT_TRUE(base::CopyDirectory(source_dir, target_dir, true));
- ASSERT_TRUE(base::PathExists(target_dir));
- base::FilePath check_path;
- GetComponentDataFileDestination(&check_path);
- ASSERT_TRUE(base::PathExists(check_path));
-}
-
-} // namespace test
« no previous file with comments | « chrome/browser/translate/component_cld_data_harness.h ('k') | chrome/browser/translate/standalone_cld_data_harness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698