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

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

Issue 2000513002: media: Bundle Widevine CDM on Win/Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments Created 4 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
« no previous file with comments | « no previous file | chrome/chrome_dll_bundle.gypi » ('j') | chrome/chrome_dll_bundle.gypi » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/widevine_cdm_component_installer.h" 5 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 #include <string> 10 #include <string>
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 const base::FilePath adapter_version_path = 340 const base::FilePath adapter_version_path =
341 GetPlatformDirectory(cdm_install_dir).AppendASCII(kCdmAdapterVersionName); 341 GetPlatformDirectory(cdm_install_dir).AppendASCII(kCdmAdapterVersionName);
342 const base::FilePath adapter_install_path = 342 const base::FilePath adapter_install_path =
343 GetPlatformDirectory(cdm_install_dir) 343 GetPlatformDirectory(cdm_install_dir)
344 .AppendASCII(kWidevineCdmAdapterFileName); 344 .AppendASCII(kWidevineCdmAdapterFileName);
345 345
346 VLOG(1) << "UpdateCdmAdapter: version" << cdm_version.GetString() 346 VLOG(1) << "UpdateCdmAdapter: version" << cdm_version.GetString()
347 << " adapter_install_path=" << adapter_install_path.AsUTF8Unsafe() 347 << " adapter_install_path=" << adapter_install_path.AsUTF8Unsafe()
348 << " adapter_version_path=" << adapter_version_path.AsUTF8Unsafe(); 348 << " adapter_version_path=" << adapter_version_path.AsUTF8Unsafe();
349 349
350 base::FilePath adapter_source_path;
351 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
352
350 const std::string chrome_version = version_info::GetVersionNumber(); 353 const std::string chrome_version = version_info::GetVersionNumber();
351 DCHECK(!chrome_version.empty()); 354 DCHECK(!chrome_version.empty());
352 std::string adapter_version; 355 std::string adapter_version;
353 if (!base::ReadFileToString(adapter_version_path, &adapter_version) || 356
354 adapter_version != chrome_version || 357 // If we are not using bundled CDM, then we need to verify whether we have
355 !base::PathExists(adapter_install_path)) { 358 // the correct CDM adapter. If not, copy the CDM adapter from
359 // |adapter_source_path| to |adapter_install_path|.
360 if (adapter_install_path != adapter_source_path &&
361 (!base::ReadFileToString(adapter_version_path, &adapter_version) ||
Lei Zhang 2016/05/20 23:54:28 Maybe break this off into: AdapterVersionMatchesCh
xhwang 2016/05/21 00:25:57 Done.
362 adapter_version != chrome_version ||
363 !base::PathExists(adapter_install_path))) {
356 int bytes_written = base::WriteFile( 364 int bytes_written = base::WriteFile(
357 adapter_version_path, chrome_version.data(), chrome_version.size()); 365 adapter_version_path, chrome_version.data(), chrome_version.size());
358 if (bytes_written < 0 || 366 if (bytes_written < 0 ||
359 static_cast<size_t>(bytes_written) != chrome_version.size()) { 367 static_cast<size_t>(bytes_written) != chrome_version.size()) {
360 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file."; 368 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file.";
361 // Ignore version file writing failure and try to copy the CDM adapter. 369 // Ignore version file writing failure and try to copy the CDM adapter.
362 } 370 }
363 371
364 base::FilePath adapter_source_path;
365 PathService::Get(chrome::FILE_WIDEVINE_CDM_ADAPTER, &adapter_source_path);
366 if (!base::CopyFile(adapter_source_path, adapter_install_path)) { 372 if (!base::CopyFile(adapter_source_path, adapter_install_path)) {
367 PLOG(WARNING) << "Failed to copy Widevine CDM adapter."; 373 PLOG(WARNING) << "Failed to copy Widevine CDM adapter.";
368 return; 374 return;
369 } 375 }
370 } 376 }
371 377
372 BrowserThread::PostTask( 378 BrowserThread::PostTask(
373 content::BrowserThread::UI, FROM_HERE, 379 content::BrowserThread::UI, FROM_HERE,
374 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir, 380 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir,
375 base::Passed(&manifest))); 381 base::Passed(&manifest)));
(...skipping 10 matching lines...) Expand all
386 std::unique_ptr<ComponentInstallerTraits> traits( 392 std::unique_ptr<ComponentInstallerTraits> traits(
387 new WidevineCdmComponentInstallerTraits); 393 new WidevineCdmComponentInstallerTraits);
388 // |cus| will take ownership of |installer| during installer->Register(cus). 394 // |cus| will take ownership of |installer| during installer->Register(cus).
389 DefaultComponentInstaller* installer = 395 DefaultComponentInstaller* installer =
390 new DefaultComponentInstaller(std::move(traits)); 396 new DefaultComponentInstaller(std::move(traits));
391 installer->Register(cus, base::Closure()); 397 installer->Register(cus, base::Closure());
392 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 398 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
393 } 399 }
394 400
395 } // namespace component_updater 401 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | chrome/chrome_dll_bundle.gypi » ('j') | chrome/chrome_dll_bundle.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698