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

Side by Side Diff: trunk/src/chrome/browser/profiles/profile_manager.cc

Issue 14824006: Revert 198820 "Move FileEnumerator to its own file, do some refa..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 | 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/profiles/profile_manager.h" 5 #include "chrome/browser/profiles/profile_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/deferred_sequenced_task_runner.h" 11 #include "base/deferred_sequenced_task_runner.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/files/file_enumerator.h"
14 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
15 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_registry_simple.h" 15 #include "base/prefs/pref_registry_simple.h"
17 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
18 #include "base/string_util.h" 17 #include "base/string_util.h"
19 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
20 #include "base/utf_string_conversions.h" 19 #include "base/utf_string_conversions.h"
21 #include "chrome/browser/bookmarks/bookmark_model.h" 20 #include "chrome/browser/bookmarks/bookmark_model.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 21 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 87
89 // Profiles that should be deleted on shutdown. 88 // Profiles that should be deleted on shutdown.
90 std::vector<base::FilePath>& ProfilesToDelete() { 89 std::vector<base::FilePath>& ProfilesToDelete() {
91 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ()); 90 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ());
92 return profiles_to_delete; 91 return profiles_to_delete;
93 } 92 }
94 93
95 int64 ComputeFilesSize(const base::FilePath& directory, 94 int64 ComputeFilesSize(const base::FilePath& directory,
96 const base::FilePath::StringType& pattern) { 95 const base::FilePath::StringType& pattern) {
97 int64 running_size = 0; 96 int64 running_size = 0;
98 base::FileEnumerator iter(directory, false, base::FileEnumerator::FILES, 97 file_util::FileEnumerator iter(directory, false,
99 pattern); 98 file_util::FileEnumerator::FILES,
100 while (!iter.Next().empty()) 99 pattern);
101 running_size += iter.GetInfo().GetSize(); 100 while (!iter.Next().empty()) {
101 file_util::FileEnumerator::FindInfo info;
102 iter.GetFindInfo(&info);
103 running_size += file_util::FileEnumerator::GetFilesize(info);
104 }
102 return running_size; 105 return running_size;
103 } 106 }
104 107
105 // Simple task to log the size of the current profile. 108 // Simple task to log the size of the current profile.
106 void ProfileSizeTask(const base::FilePath& path, int extension_count) { 109 void ProfileSizeTask(const base::FilePath& path, int extension_count) {
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 110 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
108 111
109 int64 size = ComputeFilesSize(path, FILE_PATH_LITERAL("*")); 112 int64 size = ComputeFilesSize(path, FILE_PATH_LITERAL("*"));
110 int size_MB = static_cast<int>(size / (1024 * 1024)); 113 int size_MB = static_cast<int>(size / (1024 * 1024));
111 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB); 114 UMA_HISTOGRAM_COUNTS_10000("Profile.TotalSize", size_MB);
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 ProfileManager::ProfileInfo::ProfileInfo( 1185 ProfileManager::ProfileInfo::ProfileInfo(
1183 Profile* profile, 1186 Profile* profile,
1184 bool created) 1187 bool created)
1185 : profile(profile), 1188 : profile(profile),
1186 created(created) { 1189 created(created) {
1187 } 1190 }
1188 1191
1189 ProfileManager::ProfileInfo::~ProfileInfo() { 1192 ProfileManager::ProfileInfo::~ProfileInfo() {
1190 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1193 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1191 } 1194 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698