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

Side by Side Diff: trunk/src/chrome/browser/ui/webui/chromeos/drive_internals_ui.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/ui/webui/chromeos/drive_internals_ui.h" 5 #include "chrome/browser/ui/webui/chromeos/drive_internals_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h"
11 #include "base/format_macros.h" 10 #include "base/format_macros.h"
12 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
14 #include "base/path_service.h" 13 #include "base/path_service.h"
15 #include "base/prefs/pref_service.h" 14 #include "base/prefs/pref_service.h"
16 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
17 #include "base/sys_info.h" 16 #include "base/sys_info.h"
18 #include "chrome/browser/chromeos/drive/debug_info_collector.h" 17 #include "chrome/browser/chromeos/drive/debug_info_collector.h"
19 #include "chrome/browser/chromeos/drive/drive.pb.h" 18 #include "chrome/browser/chromeos/drive/drive.pb.h"
20 #include "chrome/browser/chromeos/drive/drive_system_service.h" 19 #include "chrome/browser/chromeos/drive/drive_system_service.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // [{ path: 'GCache/v1/tmp/<resource_id>', 53 // [{ path: 'GCache/v1/tmp/<resource_id>',
55 // size: 12345, 54 // size: 12345,
56 // is_directory: false, 55 // is_directory: false,
57 // last_modified: '2005-08-09T09:57:00-08:00', 56 // last_modified: '2005-08-09T09:57:00-08:00',
58 // },...] 57 // },...]
59 // 58 //
60 // The list is sorted by the path. 59 // The list is sorted by the path.
61 void GetGCacheContents(const base::FilePath& root_path, 60 void GetGCacheContents(const base::FilePath& root_path,
62 base::ListValue* gcache_contents, 61 base::ListValue* gcache_contents,
63 base::DictionaryValue* gcache_summary) { 62 base::DictionaryValue* gcache_summary) {
63 using file_util::FileEnumerator;
64 // Use this map to sort the result list by the path. 64 // Use this map to sort the result list by the path.
65 std::map<base::FilePath, DictionaryValue*> files; 65 std::map<base::FilePath, DictionaryValue*> files;
66 66
67 const int options = (base::FileEnumerator::FILES | 67 const int options = (file_util::FileEnumerator::FILES |
68 base::FileEnumerator::DIRECTORIES | 68 file_util::FileEnumerator::DIRECTORIES |
69 base::FileEnumerator::SHOW_SYM_LINKS); 69 file_util::FileEnumerator::SHOW_SYM_LINKS);
70 base::FileEnumerator enumerator(root_path, true /* recursive */, options); 70 FileEnumerator enumerator(root_path, true /* recursive */, options);
71 71
72 int64 total_size = 0; 72 int64 total_size = 0;
73 for (base::FilePath current = enumerator.Next(); !current.empty(); 73 for (base::FilePath current = enumerator.Next(); !current.empty();
74 current = enumerator.Next()) { 74 current = enumerator.Next()) {
75 base::FileEnumerator::FileInfo find_info = enumerator.GetInfo(); 75 FileEnumerator::FindInfo find_info;
76 int64 size = find_info.GetSize(); 76 enumerator.GetFindInfo(&find_info);
77 const bool is_directory = find_info.IsDirectory(); 77 int64 size = FileEnumerator::GetFilesize(find_info);
78 const bool is_symbolic_link = file_util::IsLink(find_info.GetName()); 78 const bool is_directory = FileEnumerator::IsDirectory(find_info);
79 const base::Time last_modified = find_info.GetLastModifiedTime(); 79 const bool is_symbolic_link =
80 file_util::IsLink(FileEnumerator::GetFilename(find_info));
81 const base::Time last_modified =
82 FileEnumerator::GetLastModifiedTime(find_info);
80 83
81 base::DictionaryValue* entry = new base::DictionaryValue; 84 base::DictionaryValue* entry = new base::DictionaryValue;
82 entry->SetString("path", current.value()); 85 entry->SetString("path", current.value());
83 // Use double instead of integer for large files. 86 // Use double instead of integer for large files.
84 entry->SetDouble("size", size); 87 entry->SetDouble("size", size);
85 entry->SetBoolean("is_directory", is_directory); 88 entry->SetBoolean("is_directory", is_directory);
86 entry->SetBoolean("is_symbolic_link", is_symbolic_link); 89 entry->SetBoolean("is_symbolic_link", is_symbolic_link);
87 entry->SetString( 90 entry->SetString(
88 "last_modified", 91 "last_modified",
89 google_apis::util::FormatTimeAsStringLocaltime(last_modified)); 92 google_apis::util::FormatTimeAsStringLocaltime(last_modified));
90 // Print lower 9 bits in octal format. 93 // Print lower 9 bits in octal format.
91 entry->SetString( 94 entry->SetString(
92 "permission", 95 "permission",
93 base::StringPrintf("%03o", find_info.stat().st_mode & 0x1ff)); 96 base::StringPrintf("%03o", find_info.stat.st_mode & 0x1ff));
94 files[current] = entry; 97 files[current] = entry;
95 98
96 total_size += size; 99 total_size += size;
97 } 100 }
98 101
99 // Convert |files| into |gcache_contents|. 102 // Convert |files| into |gcache_contents|.
100 for (std::map<base::FilePath, DictionaryValue*>::const_iterator 103 for (std::map<base::FilePath, DictionaryValue*>::const_iterator
101 iter = files.begin(); iter != files.end(); ++iter) { 104 iter = files.begin(); iter != files.end(); ++iter) {
102 gcache_contents->Append(iter->second); 105 gcache_contents->Append(iter->second);
103 } 106 }
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost); 746 content::WebUIDataSource::Create(chrome::kChromeUIDriveInternalsHost);
744 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS); 747 source->AddResourcePath("drive_internals.css", IDR_DRIVE_INTERNALS_CSS);
745 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS); 748 source->AddResourcePath("drive_internals.js", IDR_DRIVE_INTERNALS_JS);
746 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML); 749 source->SetDefaultResource(IDR_DRIVE_INTERNALS_HTML);
747 750
748 Profile* profile = Profile::FromWebUI(web_ui); 751 Profile* profile = Profile::FromWebUI(web_ui);
749 content::WebUIDataSource::Add(profile, source); 752 content::WebUIDataSource::Add(profile, source);
750 } 753 }
751 754
752 } // namespace chromeos 755 } // namespace chromeos
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/ui/pdf/pdf_browsertest.cc ('k') | trunk/src/chrome/browser/ui/webui/feedback_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698