| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/cpu.h" | 13 #include "base/cpu.h" |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/files/file_enumerator.h" | 15 #include "base/files/file_enumerator.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.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 "chrome/browser/component_updater/component_updater_service.h" | 21 #include "chrome/browser/component_updater/component_updater_service.h" |
| 22 #include "chrome/common/chrome_paths.h" | 22 #include "components/component_updater/component_updater_paths.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/gpu_data_manager.h" | 24 #include "content/public/browser/gpu_data_manager.h" |
| 25 #include "content/public/browser/gpu_data_manager_observer.h" | 25 #include "content/public/browser/gpu_data_manager_observer.h" |
| 26 #include "gpu/config/gpu_feature_type.h" | 26 #include "gpu/config/gpu_feature_type.h" |
| 27 | 27 |
| 28 using content::BrowserThread; | 28 using content::BrowserThread; |
| 29 using content::GpuDataManager; | 29 using content::GpuDataManager; |
| 30 | 30 |
| 31 namespace component_updater { | 31 namespace component_updater { |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // CRX hash. The extension id is: nhfgdggnnopgbfdlpeoalgcjdgfafocg. | 35 // CRX hash. The extension id is: nhfgdggnnopgbfdlpeoalgcjdgfafocg. |
| 36 const uint8 kSha2Hash[] = {0xd7, 0x56, 0x36, 0x6d, 0xde, 0xf6, 0x15, 0x3b, | 36 const uint8 kSha2Hash[] = {0xd7, 0x56, 0x36, 0x6d, 0xde, 0xf6, 0x15, 0x3b, |
| 37 0xf4, 0xe0, 0xb6, 0x29, 0x36, 0x50, 0x5e, 0x26, | 37 0xf4, 0xe0, 0xb6, 0x29, 0x36, 0x50, 0x5e, 0x26, |
| 38 0xbd, 0x77, 0x8b, 0x8e, 0x35, 0xc2, 0x7e, 0x43, | 38 0xbd, 0x77, 0x8b, 0x8e, 0x35, 0xc2, 0x7e, 0x43, |
| 39 0x52, 0x47, 0x62, 0xed, 0x12, 0xca, 0xcc, 0x6a}; | 39 0x52, 0x47, 0x62, 0xed, 0x12, 0xca, 0xcc, 0x6a}; |
| 40 | 40 |
| 41 // File name of the internal SwiftShader plugin on different platforms. | 41 // File name of the internal SwiftShader plugin on different platforms. |
| 42 const base::FilePath::CharType kSwiftShaderEglName[] = | 42 const base::FilePath::CharType kSwiftShaderEglName[] = |
| 43 FILE_PATH_LITERAL("libegl.dll"); | 43 FILE_PATH_LITERAL("libegl.dll"); |
| 44 const base::FilePath::CharType kSwiftShaderGlesName[] = | 44 const base::FilePath::CharType kSwiftShaderGlesName[] = |
| 45 FILE_PATH_LITERAL("libglesv2.dll"); | 45 FILE_PATH_LITERAL("libglesv2.dll"); |
| 46 | 46 |
| 47 const char kSwiftShaderManifestName[] = "SwiftShader"; | 47 const char kSwiftShaderManifestName[] = "SwiftShader"; |
| 48 | 48 |
| 49 const base::FilePath::CharType kSwiftShaderBaseDirectory[] = | |
| 50 FILE_PATH_LITERAL("SwiftShader"); | |
| 51 | |
| 52 // If we don't have a SwiftShader component, this is the version we claim. | 49 // If we don't have a SwiftShader component, this is the version we claim. |
| 53 const char kNullVersion[] = "0.0.0.0"; | 50 const char kNullVersion[] = "0.0.0.0"; |
| 54 | 51 |
| 55 // The base directory on windows looks like: | 52 // The base directory on windows looks like: |
| 56 // <profile>\AppData\Local\Google\Chrome\User Data\SwiftShader\. | 53 // <profile>\AppData\Local\Google\Chrome\User Data\SwiftShader\. |
| 57 base::FilePath GetSwiftShaderBaseDirectory() { | 54 base::FilePath GetSwiftShaderBaseDirectory() { |
| 58 base::FilePath result; | 55 base::FilePath result; |
| 59 PathService::Get(chrome::DIR_USER_DATA, &result); | 56 if (!PathService::Get(DIR_SWIFT_SHADER, &result)) |
| 60 return result.Append(kSwiftShaderBaseDirectory); | 57 NOTREACHED() << "Couldn't get SwiftShader directory."; |
| 58 return result; |
| 61 } | 59 } |
| 62 | 60 |
| 63 // SwiftShader has version encoded in the path itself | 61 // SwiftShader has version encoded in the path itself |
| 64 // so we need to enumerate the directories to find the full path. | 62 // so we need to enumerate the directories to find the full path. |
| 65 // On success it returns something like: | 63 // On success it returns something like: |
| 66 // <profile>\AppData\Local\Google\Chrome\User Data\SwiftShader\10.3.44.555\. | 64 // <profile>\AppData\Local\Google\Chrome\User Data\SwiftShader\10.3.44.555\. |
| 67 bool GetLatestSwiftShaderDirectory(base::FilePath* result, | 65 bool GetLatestSwiftShaderDirectory(base::FilePath* result, |
| 68 Version* latest, | 66 Version* latest, |
| 69 std::vector<base::FilePath>* older_dirs) { | 67 std::vector<base::FilePath>* older_dirs) { |
| 70 base::FilePath base_dir = GetSwiftShaderBaseDirectory(); | 68 base::FilePath base_dir = GetSwiftShaderBaseDirectory(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 253 |
| 256 if (!cpu.has_sse2()) | 254 if (!cpu.has_sse2()) |
| 257 return; | 255 return; |
| 258 BrowserThread::PostTask(BrowserThread::FILE, | 256 BrowserThread::PostTask(BrowserThread::FILE, |
| 259 FROM_HERE, | 257 FROM_HERE, |
| 260 base::Bind(&RegisterSwiftShaderPath, cus)); | 258 base::Bind(&RegisterSwiftShaderPath, cus)); |
| 261 #endif | 259 #endif |
| 262 } | 260 } |
| 263 | 261 |
| 264 } // namespace component_updater | 262 } // namespace component_updater |
| OLD | NEW |