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

Side by Side Diff: chrome/browser/component_updater/cld_component_installer.cc

Issue 334783002: Componentize component_updater: Move some paths/constants to component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add component updater to common dependency list Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/component_updater/cld_component_installer.h" 5 #include "chrome/browser/component_updater/cld_component_installer.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/path_service.h" 15 #include "base/path_service.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/chrome_paths.h" 17 #include "components/component_updater/component_updater_paths.h"
18 #include "components/translate/content/browser/data_file_browser_cld_data_provid er.h" 18 #include "components/translate/content/browser/data_file_browser_cld_data_provid er.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "net/ssl/ssl_config_service.h" 20 #include "net/ssl/ssl_config_service.h"
21 21
22 using component_updater::ComponentUpdateService; 22 using component_updater::ComponentUpdateService;
23 using content::BrowserThread; 23 using content::BrowserThread;
24 24
25 namespace { 25 namespace {
26 // TODO(andrewhayden): Make the data file path into a gyp/gn define 26 // TODO(andrewhayden): Make the data file path into a gyp/gn define
27 // If you change this, also update component_cld_data_harness.cc 27 // If you change this, also update component_cld_data_harness.cc
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // not the headers are valid. So just check if the file exists. 82 // not the headers are valid. So just check if the file exists.
83 const base::FilePath expected_file = GetInstalledPath(install_dir); 83 const base::FilePath expected_file = GetInstalledPath(install_dir);
84 VLOG(1) << "Verifying install: " << expected_file.value(); 84 VLOG(1) << "Verifying install: " << expected_file.value();
85 const bool result = base::PathExists(expected_file); 85 const bool result = base::PathExists(expected_file);
86 VLOG(1) << "Verification result: " << (result ? "valid" : "invalid"); 86 VLOG(1) << "Verification result: " << (result ? "valid" : "invalid");
87 return result; 87 return result;
88 } 88 }
89 89
90 base::FilePath CldComponentInstallerTraits::GetBaseDirectory() const { 90 base::FilePath CldComponentInstallerTraits::GetBaseDirectory() const {
91 base::FilePath result; 91 base::FilePath result;
92 PathService::Get(chrome::DIR_COMPONENT_CLD2, &result); 92 PathService::Get(DIR_COMPONENT_CLD2, &result);
93 return result; 93 return result;
94 } 94 }
95 95
96 void CldComponentInstallerTraits::GetHash(std::vector<uint8>* hash) const { 96 void CldComponentInstallerTraits::GetHash(std::vector<uint8>* hash) const {
97 hash->assign(kPublicKeySHA256, 97 hash->assign(kPublicKeySHA256,
98 kPublicKeySHA256 + arraysize(kPublicKeySHA256)); 98 kPublicKeySHA256 + arraysize(kPublicKeySHA256));
99 } 99 }
100 100
101 std::string CldComponentInstallerTraits::GetName() const { 101 std::string CldComponentInstallerTraits::GetName() const {
102 return kCldManifestName; 102 return kCldManifestName;
103 } 103 }
104 104
105 void RegisterCldComponent(ComponentUpdateService* cus) { 105 void RegisterCldComponent(ComponentUpdateService* cus) {
106 scoped_ptr<ComponentInstallerTraits> traits( 106 scoped_ptr<ComponentInstallerTraits> traits(
107 new CldComponentInstallerTraits()); 107 new CldComponentInstallerTraits());
108 // |cus| will take ownership of |installer| during installer->Register(cus). 108 // |cus| will take ownership of |installer| during installer->Register(cus).
109 DefaultComponentInstaller* installer = 109 DefaultComponentInstaller* installer =
110 new DefaultComponentInstaller(traits.Pass()); 110 new DefaultComponentInstaller(traits.Pass());
111 installer->Register(cus); 111 installer->Register(cus);
112 } 112 }
113 113
114 void CldComponentInstallerTraits::SetLatestCldDataFile( 114 void CldComponentInstallerTraits::SetLatestCldDataFile(
115 const base::FilePath& path) { 115 const base::FilePath& path) {
116 VLOG(1) << "Setting CLD data file location: " << path.value(); 116 VLOG(1) << "Setting CLD data file location: " << path.value();
117 translate::DataFileBrowserCldDataProvider::SetCldDataFilePath(path); 117 translate::DataFileBrowserCldDataProvider::SetCldDataFilePath(path);
118 } 118 }
119 119
120 } // namespace component_updater 120 } // namespace component_updater
OLDNEW
« no previous file with comments | « chrome/browser/component_updater/DEPS ('k') | chrome/browser/component_updater/component_patcher_operation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698