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

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

Issue 16392011: Move FileEnumerator to its own file, do some refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix incorrect includes Created 7 years, 6 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 | Annotate | Revision Log
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 <string.h> 7 #include <string.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/base_paths.h" 11 #include "base/base_paths.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/files/file_enumerator.h"
16 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "base/path_service.h" 19 #include "base/path_service.h"
19 #include "base/string_util.h" 20 #include "base/string_util.h"
20 #include "base/values.h" 21 #include "base/values.h"
21 #include "base/version.h" 22 #include "base/version.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "chrome/browser/component_updater/component_updater_service.h" 24 #include "chrome/browser/component_updater/component_updater_service.h"
24 #include "chrome/browser/plugins/plugin_prefs.h" 25 #include "chrome/browser/plugins/plugin_prefs.h"
25 #include "chrome/common/chrome_constants.h" 26 #include "chrome/common/chrome_constants.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // directories to find the full path. 87 // directories to find the full path.
87 // On success, |latest_dir| returns something like: 88 // On success, |latest_dir| returns something like:
88 // <profile>\AppData\Local\Google\Chrome\User Data\WidevineCdm\10.3.44.555\. 89 // <profile>\AppData\Local\Google\Chrome\User Data\WidevineCdm\10.3.44.555\.
89 // |latest_version| returns the corresponding version number. |older_dirs| 90 // |latest_version| returns the corresponding version number. |older_dirs|
90 // returns directories of all older versions. 91 // returns directories of all older versions.
91 bool GetWidevineCdmDirectory(base::FilePath* latest_dir, 92 bool GetWidevineCdmDirectory(base::FilePath* latest_dir,
92 base::Version* latest_version, 93 base::Version* latest_version,
93 std::vector<base::FilePath>* older_dirs) { 94 std::vector<base::FilePath>* older_dirs) {
94 base::FilePath base_dir = GetWidevineCdmBaseDirectory(); 95 base::FilePath base_dir = GetWidevineCdmBaseDirectory();
95 bool found = false; 96 bool found = false;
96 file_util::FileEnumerator file_enumerator( 97 base::FileEnumerator file_enumerator(
97 base_dir, false, file_util::FileEnumerator::DIRECTORIES); 98 base_dir, false, base::FileEnumerator::DIRECTORIES);
98 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); 99 for (base::FilePath path = file_enumerator.Next(); !path.value().empty();
99 path = file_enumerator.Next()) { 100 path = file_enumerator.Next()) {
100 base::Version version(path.BaseName().MaybeAsASCII()); 101 base::Version version(path.BaseName().MaybeAsASCII());
101 if (!version.IsValid()) 102 if (!version.IsValid())
102 continue; 103 continue;
103 if (found) { 104 if (found) {
104 if (version.CompareTo(*latest_version) > 0) { 105 if (version.CompareTo(*latest_version) > 0) {
105 older_dirs->push_back(*latest_dir); 106 older_dirs->push_back(*latest_dir);
106 *latest_dir = path; 107 *latest_dir = path;
107 *latest_version = version; 108 *latest_version = version;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 296 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
296 297
297 } // namespace 298 } // namespace
298 299
299 void RegisterWidevineCdmComponent(ComponentUpdateService* cus) { 300 void RegisterWidevineCdmComponent(ComponentUpdateService* cus) {
300 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 301 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
301 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 302 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
302 base::Bind(&StartWidevineCdmUpdateRegistration, cus)); 303 base::Bind(&StartWidevineCdmUpdateRegistration, cus));
303 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT) 304 #endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(WIDEVINE_CDM_IS_COMPONENT)
304 } 305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698