OLD | NEW |
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/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/files/file_enumerator.h" | 14 #include "base/files/file_enumerator.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "components/component_updater/component_updater_paths.h" | 21 #include "components/component_updater/component_updater_paths.h" |
22 #include "components/component_updater/component_updater_service.h" | 22 #include "components/component_updater/component_updater_service.h" |
| 23 #include "components/update_client/update_client.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/gpu_data_manager.h" | 25 #include "content/public/browser/gpu_data_manager.h" |
25 #include "content/public/browser/gpu_data_manager_observer.h" | 26 #include "content/public/browser/gpu_data_manager_observer.h" |
26 #include "gpu/config/gpu_feature_type.h" | 27 #include "gpu/config/gpu_feature_type.h" |
27 | 28 |
28 using content::BrowserThread; | 29 using content::BrowserThread; |
29 using content::GpuDataManager; | 30 using content::GpuDataManager; |
30 | 31 |
31 namespace component_updater { | 32 namespace component_updater { |
32 | 33 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 89 } |
89 } | 90 } |
90 return found; | 91 return found; |
91 } | 92 } |
92 | 93 |
93 void RegisterSwiftShaderWithChrome(const base::FilePath& path) { | 94 void RegisterSwiftShaderWithChrome(const base::FilePath& path) { |
94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
95 GpuDataManager::GetInstance()->RegisterSwiftShaderPath(path); | 96 GpuDataManager::GetInstance()->RegisterSwiftShaderPath(path); |
96 } | 97 } |
97 | 98 |
98 class SwiftShaderComponentInstaller : public ComponentInstaller { | 99 class SwiftShaderComponentInstaller : public update_client::ComponentInstaller { |
99 public: | 100 public: |
100 explicit SwiftShaderComponentInstaller(const Version& version); | 101 explicit SwiftShaderComponentInstaller(const Version& version); |
101 | 102 |
102 ~SwiftShaderComponentInstaller() override {} | 103 ~SwiftShaderComponentInstaller() override {} |
103 | 104 |
104 void OnUpdateError(int error) override; | 105 void OnUpdateError(int error) override; |
105 | 106 |
106 bool Install(const base::DictionaryValue& manifest, | 107 bool Install(const base::DictionaryValue& manifest, |
107 const base::FilePath& unpack_path) override; | 108 const base::FilePath& unpack_path) override; |
108 | 109 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bool SwiftShaderComponentInstaller::GetInstalledFile( | 159 bool SwiftShaderComponentInstaller::GetInstalledFile( |
159 const std::string& file, | 160 const std::string& file, |
160 base::FilePath* installed_file) { | 161 base::FilePath* installed_file) { |
161 return false; | 162 return false; |
162 } | 163 } |
163 | 164 |
164 void FinishSwiftShaderUpdateRegistration(ComponentUpdateService* cus, | 165 void FinishSwiftShaderUpdateRegistration(ComponentUpdateService* cus, |
165 const Version& version) { | 166 const Version& version) { |
166 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 167 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
167 | 168 |
168 CrxComponent swiftshader; | 169 update_client::CrxComponent swiftshader; |
169 swiftshader.name = "Swift Shader"; | 170 swiftshader.name = "Swift Shader"; |
170 swiftshader.installer = new SwiftShaderComponentInstaller(version); | 171 swiftshader.installer = new SwiftShaderComponentInstaller(version); |
171 swiftshader.version = version; | 172 swiftshader.version = version; |
172 swiftshader.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); | 173 swiftshader.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); |
173 if (cus->RegisterComponent(swiftshader) != ComponentUpdateService::kOk) { | 174 if (cus->RegisterComponent(swiftshader) != ComponentUpdateService::kOk) { |
174 NOTREACHED() << "SwiftShader component registration fail"; | 175 NOTREACHED() << "SwiftShader component registration fail"; |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 class UpdateChecker : public content::GpuDataManagerObserver { | 179 class UpdateChecker : public content::GpuDataManagerObserver { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 250 |
250 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) { | 251 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) { |
251 #if defined(ENABLE_SWIFTSHADER) | 252 #if defined(ENABLE_SWIFTSHADER) |
252 BrowserThread::PostTask(BrowserThread::FILE, | 253 BrowserThread::PostTask(BrowserThread::FILE, |
253 FROM_HERE, | 254 FROM_HERE, |
254 base::Bind(&RegisterSwiftShaderPath, cus)); | 255 base::Bind(&RegisterSwiftShaderPath, cus)); |
255 #endif | 256 #endif |
256 } | 257 } |
257 | 258 |
258 } // namespace component_updater | 259 } // namespace component_updater |
OLD | NEW |