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

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: more fixes 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 (adapter_install_path != adapter_source_path &&
xhwang 2016/05/20 19:30:00 Being paranoid about this check... If there's an i
ddorwin 2016/05/20 21:37:22 You should have a comment to explain this. To isol
xhwang 2016/05/20 23:46:11 Updated comments.
355 !base::PathExists(adapter_install_path)) { 358 (!base::ReadFileToString(adapter_version_path, &adapter_version) ||
359 adapter_version != chrome_version ||
360 !base::PathExists(adapter_install_path))) {
356 int bytes_written = base::WriteFile( 361 int bytes_written = base::WriteFile(
357 adapter_version_path, chrome_version.data(), chrome_version.size()); 362 adapter_version_path, chrome_version.data(), chrome_version.size());
358 if (bytes_written < 0 || 363 if (bytes_written < 0 ||
359 static_cast<size_t>(bytes_written) != chrome_version.size()) { 364 static_cast<size_t>(bytes_written) != chrome_version.size()) {
360 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file."; 365 PLOG(WARNING) << "Failed to write Widevine CDM adapter version file.";
361 // Ignore version file writing failure and try to copy the CDM adapter. 366 // Ignore version file writing failure and try to copy the CDM adapter.
362 } 367 }
363 368
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)) { 369 if (!base::CopyFile(adapter_source_path, adapter_install_path)) {
367 PLOG(WARNING) << "Failed to copy Widevine CDM adapter."; 370 PLOG(WARNING) << "Failed to copy Widevine CDM adapter.";
368 return; 371 return;
369 } 372 }
370 } 373 }
371 374
372 BrowserThread::PostTask( 375 BrowserThread::PostTask(
373 content::BrowserThread::UI, FROM_HERE, 376 content::BrowserThread::UI, FROM_HERE,
374 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir, 377 base::Bind(&RegisterWidevineCdmWithChrome, cdm_version, cdm_install_dir,
375 base::Passed(&manifest))); 378 base::Passed(&manifest)));
(...skipping 10 matching lines...) Expand all
386 std::unique_ptr<ComponentInstallerTraits> traits( 389 std::unique_ptr<ComponentInstallerTraits> traits(
387 new WidevineCdmComponentInstallerTraits); 390 new WidevineCdmComponentInstallerTraits);
388 // |cus| will take ownership of |installer| during installer->Register(cus). 391 // |cus| will take ownership of |installer| during installer->Register(cus).
389 DefaultComponentInstaller* installer = 392 DefaultComponentInstaller* installer =
390 new DefaultComponentInstaller(std::move(traits)); 393 new DefaultComponentInstaller(std::move(traits));
391 installer->Register(cus, base::Closure()); 394 installer->Register(cus, base::Closure());
392 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 395 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
393 } 396 }
394 397
395 } // namespace component_updater 398 } // 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