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

Side by Side Diff: chrome/browser/component_updater/pnacl/pnacl_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) 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/pnacl/pnacl_component_installer.h" 5 #include "chrome/browser/component_updater/pnacl/pnacl_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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_enumerator.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/json/json_file_value_serializer.h" 14 #include "base/json/json_file_value_serializer.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/path_service.h" 16 #include "base/path_service.h"
16 #include "base/string_util.h" 17 #include "base/string_util.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "base/version.h" 19 #include "base/version.h"
19 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // If we don't have Pnacl installed, this is the version we claim. 120 // If we don't have Pnacl installed, this is the version we claim.
120 const char kNullVersion[] = "0.0.0.0"; 121 const char kNullVersion[] = "0.0.0.0";
121 122
122 bool GetLatestPnaclDirectory(PnaclComponentInstaller* pci, 123 bool GetLatestPnaclDirectory(PnaclComponentInstaller* pci,
123 base::FilePath* latest_dir, 124 base::FilePath* latest_dir,
124 Version* latest_version, 125 Version* latest_version,
125 std::vector<base::FilePath>* older_dirs) { 126 std::vector<base::FilePath>* older_dirs) {
126 // Enumerate all versions starting from the base directory. 127 // Enumerate all versions starting from the base directory.
127 base::FilePath base_dir = pci->GetPnaclBaseDirectory(); 128 base::FilePath base_dir = pci->GetPnaclBaseDirectory();
128 bool found = false; 129 bool found = false;
129 file_util::FileEnumerator 130 base::FileEnumerator
130 file_enumerator(base_dir, false, file_util::FileEnumerator::DIRECTORIES); 131 file_enumerator(base_dir, false, base::FileEnumerator::DIRECTORIES);
131 for (base::FilePath path = file_enumerator.Next(); !path.value().empty(); 132 for (base::FilePath path = file_enumerator.Next(); !path.value().empty();
132 path = file_enumerator.Next()) { 133 path = file_enumerator.Next()) {
133 Version version(path.BaseName().MaybeAsASCII()); 134 Version version(path.BaseName().MaybeAsASCII());
134 if (!version.IsValid()) 135 if (!version.IsValid())
135 continue; 136 continue;
136 if (found) { 137 if (found) {
137 if (version.CompareTo(*latest_version) > 0) { 138 if (version.CompareTo(*latest_version) > 0) {
138 older_dirs->push_back(*latest_dir); 139 older_dirs->push_back(*latest_dir);
139 *latest_dir = path; 140 *latest_dir = path;
140 *latest_version = version; 141 *latest_version = version;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // No need to check the commandline flags again here. 429 // No need to check the commandline flags again here.
429 // We could only have gotten here after RegisterPnaclComponent 430 // We could only have gotten here after RegisterPnaclComponent
430 // found --enable-pnacl, since that is where we create the profile_observer_, 431 // found --enable-pnacl, since that is where we create the profile_observer_,
431 // which in turn calls ReRegisterPnacl. 432 // which in turn calls ReRegisterPnacl.
432 DCHECK(per_user_); 433 DCHECK(per_user_);
433 // Figure out profile information, before proceeding to look for files. 434 // Figure out profile information, before proceeding to look for files.
434 BrowserThread::PostTask( 435 BrowserThread::PostTask(
435 BrowserThread::UI, FROM_HERE, 436 BrowserThread::UI, FROM_HERE,
436 base::Bind(&GetProfileInformation, this)); 437 base::Bind(&GetProfileInformation, this));
437 } 438 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698