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

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

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

Powered by Google App Engine
This is Rietveld 408576698