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

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

Issue 2483513002: Revert of Makes the component installers return a Result instead of a bool. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/swiftshader_component_installer.h" 5 #include "chrome/browser/component_updater/swiftshader_component_installer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/base_paths.h" 11 #include "base/base_paths.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h"
14 #include "base/files/file_enumerator.h" 13 #include "base/files/file_enumerator.h"
15 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
16 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
17 #include "base/logging.h" 16 #include "base/logging.h"
18 #include "base/path_service.h" 17 #include "base/path_service.h"
19 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
20 #include "base/values.h" 19 #include "base/values.h"
21 #include "build/build_config.h" 20 #include "build/build_config.h"
22 #include "components/component_updater/component_updater_paths.h" 21 #include "components/component_updater/component_updater_paths.h"
23 #include "components/component_updater/component_updater_service.h" 22 #include "components/component_updater/component_updater_service.h"
24 #include "components/update_client/update_client.h" 23 #include "components/update_client/update_client.h"
25 #include "components/update_client/utils.h"
26 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/gpu_data_manager.h" 25 #include "content/public/browser/gpu_data_manager.h"
28 #include "content/public/browser/gpu_data_manager_observer.h" 26 #include "content/public/browser/gpu_data_manager_observer.h"
29 #include "gpu/config/gpu_feature_type.h" 27 #include "gpu/config/gpu_feature_type.h"
30 #include "ui/gl/gl_features.h" 28 #include "ui/gl/gl_features.h"
31 29
32 using content::BrowserThread; 30 using content::BrowserThread;
33 using content::GpuDataManager; 31 using content::GpuDataManager;
34 32
35 namespace component_updater { 33 namespace component_updater {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 GpuDataManager::GetInstance()->RegisterSwiftShaderPath(path); 97 GpuDataManager::GetInstance()->RegisterSwiftShaderPath(path);
100 } 98 }
101 99
102 class SwiftShaderComponentInstaller : public update_client::CrxInstaller { 100 class SwiftShaderComponentInstaller : public update_client::CrxInstaller {
103 public: 101 public:
104 explicit SwiftShaderComponentInstaller(const base::Version& version); 102 explicit SwiftShaderComponentInstaller(const base::Version& version);
105 103
106 // ComponentInstaller implementation: 104 // ComponentInstaller implementation:
107 void OnUpdateError(int error) override; 105 void OnUpdateError(int error) override;
108 106
109 update_client::CrxInstaller::Result Install( 107 bool Install(const base::DictionaryValue& manifest,
110 const base::DictionaryValue& manifest, 108 const base::FilePath& unpack_path) override;
111 const base::FilePath& unpack_path) override;
112 109
113 bool GetInstalledFile(const std::string& file, 110 bool GetInstalledFile(const std::string& file,
114 base::FilePath* installed_file) override; 111 base::FilePath* installed_file) override;
115 112
116 bool Uninstall() override; 113 bool Uninstall() override;
117 114
118 private: 115 private:
119 ~SwiftShaderComponentInstaller() override {} 116 ~SwiftShaderComponentInstaller() override {}
120 117
121 bool DoInstall(const base::DictionaryValue& manifest,
122 const base::FilePath& unpack_path);
123
124 base::Version current_version_; 118 base::Version current_version_;
125 }; 119 };
126 120
127 SwiftShaderComponentInstaller::SwiftShaderComponentInstaller( 121 SwiftShaderComponentInstaller::SwiftShaderComponentInstaller(
128 const base::Version& version) 122 const base::Version& version)
129 : current_version_(version) { 123 : current_version_(version) {
130 DCHECK(version.IsValid()); 124 DCHECK(version.IsValid());
131 } 125 }
132 126
133 void SwiftShaderComponentInstaller::OnUpdateError(int error) { 127 void SwiftShaderComponentInstaller::OnUpdateError(int error) {
134 NOTREACHED() << "SwiftShader update error: " << error; 128 NOTREACHED() << "SwiftShader update error: " << error;
135 } 129 }
136 130
137 update_client::CrxInstaller::Result SwiftShaderComponentInstaller::Install( 131 bool SwiftShaderComponentInstaller::Install(
138 const base::DictionaryValue& manifest,
139 const base::FilePath& unpack_path) {
140 return update_client::InstallFunctionWrapper(base::Bind(
141 &SwiftShaderComponentInstaller::DoInstall, base::Unretained(this),
142 base::ConstRef(manifest), base::ConstRef(unpack_path)));
143 }
144
145 bool SwiftShaderComponentInstaller::DoInstall(
146 const base::DictionaryValue& manifest, 132 const base::DictionaryValue& manifest,
147 const base::FilePath& unpack_path) { 133 const base::FilePath& unpack_path) {
148 std::string name; 134 std::string name;
149 manifest.GetStringASCII("name", &name); 135 manifest.GetStringASCII("name", &name);
150 if (name != kSwiftShaderManifestName) 136 if (name != kSwiftShaderManifestName)
151 return false; 137 return false;
152 std::string proposed_version; 138 std::string proposed_version;
153 manifest.GetStringASCII("version", &proposed_version); 139 manifest.GetStringASCII("version", &proposed_version);
154 base::Version version(proposed_version.c_str()); 140 base::Version version(proposed_version.c_str());
155 if (!version.IsValid()) 141 if (!version.IsValid())
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 260
275 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) { 261 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) {
276 #if BUILDFLAG(ENABLE_SWIFTSHADER) && defined(ARCH_CPU_X86) 262 #if BUILDFLAG(ENABLE_SWIFTSHADER) && defined(ARCH_CPU_X86)
277 BrowserThread::PostTask(BrowserThread::FILE, 263 BrowserThread::PostTask(BrowserThread::FILE,
278 FROM_HERE, 264 FROM_HERE,
279 base::Bind(&RegisterSwiftShaderPath, cus)); 265 base::Bind(&RegisterSwiftShaderPath, cus));
280 #endif 266 #endif
281 } 267 }
282 268
283 } // namespace component_updater 269 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698