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