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" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 public: | 98 public: |
99 explicit SwiftShaderComponentInstaller(const Version& version); | 99 explicit SwiftShaderComponentInstaller(const Version& version); |
100 | 100 |
101 virtual ~SwiftShaderComponentInstaller() {} | 101 virtual ~SwiftShaderComponentInstaller() {} |
102 | 102 |
103 virtual void OnUpdateError(int error) OVERRIDE; | 103 virtual void OnUpdateError(int error) OVERRIDE; |
104 | 104 |
105 virtual bool Install(const base::DictionaryValue& manifest, | 105 virtual bool Install(const base::DictionaryValue& manifest, |
106 const base::FilePath& unpack_path) OVERRIDE; | 106 const base::FilePath& unpack_path) OVERRIDE; |
107 | 107 |
108 virtual bool GetInstalledFile(const std::string& file, | |
109 base::FilePath* installed_file) OVERRIDE; | |
110 | |
111 private: | 108 private: |
112 Version current_version_; | 109 Version current_version_; |
113 }; | 110 }; |
114 | 111 |
115 SwiftShaderComponentInstaller::SwiftShaderComponentInstaller( | 112 SwiftShaderComponentInstaller::SwiftShaderComponentInstaller( |
116 const Version& version) : current_version_(version) { | 113 const Version& version) : current_version_(version) { |
117 DCHECK(version.IsValid()); | 114 DCHECK(version.IsValid()); |
118 } | 115 } |
119 | 116 |
120 void SwiftShaderComponentInstaller::OnUpdateError(int error) { | 117 void SwiftShaderComponentInstaller::OnUpdateError(int error) { |
(...skipping 24 matching lines...) Expand all Loading... |
145 return false; | 142 return false; |
146 if (!file_util::Move(unpack_path, path)) | 143 if (!file_util::Move(unpack_path, path)) |
147 return false; | 144 return false; |
148 // Installation is done. Now tell the rest of chrome. | 145 // Installation is done. Now tell the rest of chrome. |
149 current_version_ = version; | 146 current_version_ = version; |
150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 147 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
151 base::Bind(&RegisterSwiftShaderWithChrome, path)); | 148 base::Bind(&RegisterSwiftShaderWithChrome, path)); |
152 return true; | 149 return true; |
153 } | 150 } |
154 | 151 |
155 bool SwiftShaderComponentInstaller::GetInstalledFile( | |
156 const std::string& file, base::FilePath* installed_file) { | |
157 return false; | |
158 } | |
159 | |
160 void FinishSwiftShaderUpdateRegistration(ComponentUpdateService* cus, | 152 void FinishSwiftShaderUpdateRegistration(ComponentUpdateService* cus, |
161 const Version& version) { | 153 const Version& version) { |
162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
163 | 155 |
164 CrxComponent swiftshader; | 156 CrxComponent swiftshader; |
165 swiftshader.name = "Swift Shader"; | 157 swiftshader.name = "Swift Shader"; |
166 swiftshader.installer = new SwiftShaderComponentInstaller(version); | 158 swiftshader.installer = new SwiftShaderComponentInstaller(version); |
167 swiftshader.version = version; | 159 swiftshader.version = version; |
168 swiftshader.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); | 160 swiftshader.pk_hash.assign(kSha2Hash, &kSha2Hash[sizeof(kSha2Hash)]); |
169 if (cus->RegisterComponent(swiftshader) != ComponentUpdateService::kOk) { | 161 if (cus->RegisterComponent(swiftshader) != ComponentUpdateService::kOk) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) { | 229 void RegisterSwiftShaderComponent(ComponentUpdateService* cus) { |
238 #if defined(ENABLE_SWIFTSHADER) | 230 #if defined(ENABLE_SWIFTSHADER) |
239 base::CPU cpu; | 231 base::CPU cpu; |
240 | 232 |
241 if (!cpu.has_sse2()) | 233 if (!cpu.has_sse2()) |
242 return; | 234 return; |
243 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 235 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
244 base::Bind(&RegisterSwiftShaderPath, cus)); | 236 base::Bind(&RegisterSwiftShaderPath, cus)); |
245 #endif | 237 #endif |
246 } | 238 } |
OLD | NEW |