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

Side by Side Diff: chrome/browser/profiles/profile_manager.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/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/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/deferred_sequenced_task_runner.h" 12 #include "base/deferred_sequenced_task_runner.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/files/file_enumerator.h"
14 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
15 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
16 #include "base/prefs/pref_registry_simple.h" 17 #include "base/prefs/pref_registry_simple.h"
17 #include "base/prefs/pref_service.h" 18 #include "base/prefs/pref_service.h"
18 #include "base/string_util.h" 19 #include "base/string_util.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
21 #include "chrome/browser/bookmarks/bookmark_model.h" 22 #include "chrome/browser/bookmarks/bookmark_model.h"
22 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 23 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
23 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 // Profiles that should be deleted on shutdown. 91 // Profiles that should be deleted on shutdown.
91 std::vector<base::FilePath>& ProfilesToDelete() { 92 std::vector<base::FilePath>& ProfilesToDelete() {
92 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ()); 93 CR_DEFINE_STATIC_LOCAL(std::vector<base::FilePath>, profiles_to_delete, ());
93 return profiles_to_delete; 94 return profiles_to_delete;
94 } 95 }
95 96
96 int64 ComputeFilesSize(const base::FilePath& directory, 97 int64 ComputeFilesSize(const base::FilePath& directory,
97 const base::FilePath::StringType& pattern) { 98 const base::FilePath::StringType& pattern) {
98 int64 running_size = 0; 99 int64 running_size = 0;
99 file_util::FileEnumerator iter(directory, false, 100 base::FileEnumerator iter(directory, false, base::FileEnumerator::FILES,
100 file_util::FileEnumerator::FILES, 101 pattern);
101 pattern); 102 while (!iter.Next().empty())
102 while (!iter.Next().empty()) { 103 running_size += iter.GetInfo().GetSize();
103 file_util::FileEnumerator::FindInfo info;
104 iter.GetFindInfo(&info);
105 running_size += file_util::FileEnumerator::GetFilesize(info);
106 }
107 return running_size; 104 return running_size;
108 } 105 }
109 106
110 // Simple task to log the size of the current profile. 107 // Simple task to log the size of the current profile.
111 void ProfileSizeTask(const base::FilePath& path, int extension_count) { 108 void ProfileSizeTask(const base::FilePath& path, int extension_count) {
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
113 const int64 kBytesInOneMB = 1024 * 1024; 110 const int64 kBytesInOneMB = 1024 * 1024;
114 111
115 int64 size = ComputeFilesSize(path, FILE_PATH_LITERAL("*")); 112 int64 size = ComputeFilesSize(path, FILE_PATH_LITERAL("*"));
116 int size_MB = static_cast<int>(size / kBytesInOneMB); 113 int size_MB = static_cast<int>(size / kBytesInOneMB);
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 ProfileManager::ProfileInfo::ProfileInfo( 1156 ProfileManager::ProfileInfo::ProfileInfo(
1160 Profile* profile, 1157 Profile* profile,
1161 bool created) 1158 bool created)
1162 : profile(profile), 1159 : profile(profile),
1163 created(created) { 1160 created(created) {
1164 } 1161 }
1165 1162
1166 ProfileManager::ProfileInfo::~ProfileInfo() { 1163 ProfileManager::ProfileInfo::~ProfileInfo() {
1167 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); 1164 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release());
1168 } 1165 }
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