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

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

Issue 1107963003: [chrome/browser/component_updater] favor DCHECK_CURRENTLY_ON for better logs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased the patch Created 5 years, 7 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
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
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 found = true; 85 found = true;
86 } else { 86 } else {
87 if (older_dirs) 87 if (older_dirs)
88 older_dirs->push_back(path); 88 older_dirs->push_back(path);
89 } 89 }
90 } 90 }
91 return found; 91 return found;
92 } 92 }
93 93
94 void RegisterSwiftShaderWithChrome(const base::FilePath& path) { 94 void RegisterSwiftShaderWithChrome(const base::FilePath& path) {
95 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 95 DCHECK_CURRENTLY_ON(BrowserThread::UI);
96 GpuDataManager::GetInstance()->RegisterSwiftShaderPath(path); 96 GpuDataManager::GetInstance()->RegisterSwiftShaderPath(path);
97 } 97 }
98 98
99 class SwiftShaderComponentInstaller : public update_client::CrxInstaller { 99 class SwiftShaderComponentInstaller : public update_client::CrxInstaller {
100 public: 100 public:
101 explicit SwiftShaderComponentInstaller(const Version& version); 101 explicit SwiftShaderComponentInstaller(const Version& version);
102 102
103 // ComponentInstaller implementation: 103 // ComponentInstaller implementation:
104 void OnUpdateError(int error) override; 104 void OnUpdateError(int error) override;
105 105
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 base::FilePath* installed_file) { 164 base::FilePath* installed_file) {
165 return false; 165 return false;
166 } 166 }
167 167
168 bool SwiftShaderComponentInstaller::Uninstall() { 168 bool SwiftShaderComponentInstaller::Uninstall() {
169 return false; 169 return false;
170 } 170 }
171 171
172 void FinishSwiftShaderUpdateRegistration(ComponentUpdateService* cus, 172 void FinishSwiftShaderUpdateRegistration(ComponentUpdateService* cus,
173 const Version& version) { 173 const Version& version) {
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 174 DCHECK_CURRENTLY_ON(BrowserThread::UI);
175 175
176 update_client::CrxComponent swiftshader; 176 update_client::CrxComponent swiftshader;
177 swiftshader.name = "Swift Shader"; 177 swiftshader.name = "Swift Shader";
178 swiftshader.installer = new SwiftShaderComponentInstaller(version); 178 swiftshader.installer = new SwiftShaderComponentInstaller(version);
179 swiftshader.version = version; 179 swiftshader.version = version;
180 swiftshader.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); 180 swiftshader.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]);
181 if (cus->RegisterComponent(swiftshader) != 181 if (cus->RegisterComponent(swiftshader) !=
182 ComponentUpdateService::Status::kOk) { 182 ComponentUpdateService::Status::kOk) {
183 NOTREACHED() << "SwiftShader component registration fail"; 183 NOTREACHED() << "SwiftShader component registration fail";
184 } 184 }
(...skipping 12 matching lines...) Expand all
197 UpdateChecker::UpdateChecker(ComponentUpdateService* cus) : cus_(cus) { 197 UpdateChecker::UpdateChecker(ComponentUpdateService* cus) : cus_(cus) {
198 } 198 }
199 199
200 void UpdateChecker::OnGpuInfoUpdate() { 200 void UpdateChecker::OnGpuInfoUpdate() {
201 GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance(); 201 GpuDataManager* gpu_data_manager = GpuDataManager::GetInstance();
202 202
203 if (!gpu_data_manager->GpuAccessAllowed(NULL) || 203 if (!gpu_data_manager->GpuAccessAllowed(NULL) ||
204 gpu_data_manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL) || 204 gpu_data_manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL) ||
205 gpu_data_manager->ShouldUseSwiftShader()) { 205 gpu_data_manager->ShouldUseSwiftShader()) {
206 gpu_data_manager->RemoveObserver(this); 206 gpu_data_manager->RemoveObserver(this);
207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 207 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
208 base::FilePath path = GetSwiftShaderBaseDirectory(); 208 base::FilePath path = GetSwiftShaderBaseDirectory();
209 209
210 Version version(kNullVersion); 210 Version version(kNullVersion);
211 GetLatestSwiftShaderDirectory(&path, &version, NULL); 211 GetLatestSwiftShaderDirectory(&path, &version, NULL);
212 212
213 BrowserThread::PostTask( 213 BrowserThread::PostTask(
214 BrowserThread::UI, 214 BrowserThread::UI,
215 FROM_HERE, 215 FROM_HERE,
216 base::Bind(&FinishSwiftShaderUpdateRegistration, cus_, version)); 216 base::Bind(&FinishSwiftShaderUpdateRegistration, cus_, version));
217 } 217 }
218 } 218 }
219 219
220 #if defined(ENABLE_SWIFTSHADER) 220 #if defined(ENABLE_SWIFTSHADER)
221 221
222 // Check if there already is a version of swiftshader installed, 222 // Check if there already is a version of swiftshader installed,
223 // and if so register it. 223 // and if so register it.
224 void RegisterSwiftShaderPath(ComponentUpdateService* cus) { 224 void RegisterSwiftShaderPath(ComponentUpdateService* cus) {
225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 225 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
226 base::FilePath path = GetSwiftShaderBaseDirectory(); 226 base::FilePath path = GetSwiftShaderBaseDirectory();
227 if (!base::PathExists(path)) { 227 if (!base::PathExists(path)) {
228 if (!base::CreateDirectory(path)) { 228 if (!base::CreateDirectory(path)) {
229 NOTREACHED() << "Could not create SwiftShader directory."; 229 NOTREACHED() << "Could not create SwiftShader directory.";
230 return; 230 return;
231 } 231 }
232 } 232 }
233 233
234 Version version(kNullVersion); 234 Version version(kNullVersion);
235 std::vector<base::FilePath> older_dirs; 235 std::vector<base::FilePath> older_dirs;
(...skipping 22 matching lines...) Expand all
258 258
259 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) { 259 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) {
260 #if defined(ENABLE_SWIFTSHADER) 260 #if defined(ENABLE_SWIFTSHADER)
261 BrowserThread::PostTask(BrowserThread::FILE, 261 BrowserThread::PostTask(BrowserThread::FILE,
262 FROM_HERE, 262 FROM_HERE,
263 base::Bind(&RegisterSwiftShaderPath, cus)); 263 base::Bind(&RegisterSwiftShaderPath, cus));
264 #endif 264 #endif
265 } 265 }
266 266
267 } // namespace component_updater 267 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698