| 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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/cpu.h" | 10 #include "base/cpu.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/file_enumerator.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "chrome/browser/component_updater/component_updater_service.h" | 18 #include "chrome/browser/component_updater/component_updater_service.h" |
| 18 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/gpu_data_manager.h" | 21 #include "content/public/browser/gpu_data_manager.h" |
| 21 #include "content/public/browser/gpu_data_manager_observer.h" | 22 #include "content/public/browser/gpu_data_manager_observer.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 57 |
| 57 // SwiftShader has version encoded in the path itself | 58 // SwiftShader has version encoded in the path itself |
| 58 // so we need to enumerate the directories to find the full path. | 59 // so we need to enumerate the directories to find the full path. |
| 59 // On success it returns something like: | 60 // On success it returns something like: |
| 60 // <profile>\AppData\Local\Google\Chrome\User Data\SwiftShader\10.3.44.555\. | 61 // <profile>\AppData\Local\Google\Chrome\User Data\SwiftShader\10.3.44.555\. |
| 61 bool GetLatestSwiftShaderDirectory(base::FilePath* result, | 62 bool GetLatestSwiftShaderDirectory(base::FilePath* result, |
| 62 Version* latest, | 63 Version* latest, |
| 63 std::vector<base::FilePath>* older_dirs) { | 64 std::vector<base::FilePath>* older_dirs) { |
| 64 base::FilePath base_dir = GetSwiftShaderBaseDirectory(); | 65 base::FilePath base_dir = GetSwiftShaderBaseDirectory(); |
| 65 bool found = false; | 66 bool found = false; |
| 66 file_util::FileEnumerator | 67 base::FileEnumerator |
| 67 file_enumerator(base_dir, false, file_util::FileEnumerator::DIRECTORIES); | 68 file_enumerator(base_dir, false, base::FileEnumerator::DIRECTORIES); |
| 68 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); | 69 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); |
| 69 path = file_enumerator.Next()) { | 70 path = file_enumerator.Next()) { |
| 70 Version version(path.BaseName().MaybeAsASCII()); | 71 Version version(path.BaseName().MaybeAsASCII()); |
| 71 if (!version.IsValid()) | 72 if (!version.IsValid()) |
| 72 continue; | 73 continue; |
| 73 if (version.CompareTo(*latest) > 0 && | 74 if (version.CompareTo(*latest) > 0 && |
| 74 file_util::PathExists(path.Append(kSwiftShaderEglName)) && | 75 file_util::PathExists(path.Append(kSwiftShaderEglName)) && |
| 75 file_util::PathExists(path.Append(kSwiftShaderGlesName))) { | 76 file_util::PathExists(path.Append(kSwiftShaderGlesName))) { |
| 76 if (found && older_dirs) | 77 if (found && older_dirs) |
| 77 older_dirs->push_back(*result); | 78 older_dirs->push_back(*result); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) { | 229 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) { |
| 229 #if defined(ENABLE_SWIFTSHADER) | 230 #if defined(ENABLE_SWIFTSHADER) |
| 230 base::CPU cpu; | 231 base::CPU cpu; |
| 231 | 232 |
| 232 if (!cpu.has_sse2()) | 233 if (!cpu.has_sse2()) |
| 233 return; | 234 return; |
| 234 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 235 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 235 base::Bind(&RegisterSwiftShaderPath, cus)); | 236 base::Bind(&RegisterSwiftShaderPath, cus)); |
| 236 #endif | 237 #endif |
| 237 } | 238 } |
| OLD | NEW |