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

Side by Side Diff: net/url_request/url_request_file_dir_job.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 "net/url_request/url_request_file_dir_job.h" 5 #include "net/url_request/url_request_file_dir_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // SysNativeMBToWide takes care of it at least for now. We can try something 109 // SysNativeMBToWide takes care of it at least for now. We can try something
110 // more sophisticated if necessary later. 110 // more sophisticated if necessary later.
111 const base::string16& title = WideToUTF16( 111 const base::string16& title = WideToUTF16(
112 base::SysNativeMBToWide(dir_path_.value())); 112 base::SysNativeMBToWide(dir_path_.value()));
113 #endif 113 #endif
114 data_.append(GetDirectoryListingHeader(title)); 114 data_.append(GetDirectoryListingHeader(title));
115 wrote_header_ = true; 115 wrote_header_ = true;
116 } 116 }
117 117
118 #if defined(OS_WIN) 118 #if defined(OS_WIN)
119 int64 size = (static_cast<unsigned __int64>(data.info.nFileSizeHigh) << 32) | 119 std::string raw_bytes; // Empty on Windows means UTF-8 encoded name.
120 data.info.nFileSizeLow;
121
122 // Note that we should not convert ftLastWriteTime to the local time because
123 // ICU's datetime formatting APIs expect time in UTC and take into account
124 // the timezone before formatting.
125 data_.append(GetDirectoryListingEntry(
126 data.info.cFileName,
127 std::string(),
128 ((data.info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0),
129 size,
130 base::Time::FromFileTime(data.info.ftLastWriteTime)));
131 #elif defined(OS_POSIX) 120 #elif defined(OS_POSIX)
132 // TOOD(jungshik): The same issue as for the directory name. 121 // TOOD(jungshik): The same issue as for the directory name.
122 const std::string& raw_bytes = data.info.GetName().value();
123 #endif
133 data_.append(GetDirectoryListingEntry( 124 data_.append(GetDirectoryListingEntry(
134 WideToUTF16(base::SysNativeMBToWide(data.info.filename)), 125 data.info.GetName().LossyDisplayName(),
135 data.info.filename, 126 raw_bytes,
136 S_ISDIR(data.info.stat.st_mode), 127 data.info.IsDirectory(),
137 data.info.stat.st_size, 128 data.info.GetSize(),
138 base::Time::FromTimeT(data.info.stat.st_mtime))); 129 data.info.GetLastModifiedTime()));
139 #endif
140 130
141 // TODO(darin): coalesce more? 131 // TODO(darin): coalesce more?
142 CompleteRead(); 132 CompleteRead();
143 } 133 }
144 134
145 void URLRequestFileDirJob::OnListDone(int error) { 135 void URLRequestFileDirJob::OnListDone(int error) {
146 DCHECK(!canceled_); 136 DCHECK(!canceled_);
147 if (error != OK) { 137 if (error != OK) {
148 read_pending_ = false; 138 read_pending_ = false;
149 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, error)); 139 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, error));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 *bytes_read = count; 178 *bytes_read = count;
189 return true; 179 return true;
190 } else if (list_complete_) { 180 } else if (list_complete_) {
191 // EOF 181 // EOF
192 return true; 182 return true;
193 } 183 }
194 return false; 184 return false;
195 } 185 }
196 186
197 } // namespace net 187 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_in_memory_cache.cc ('k') | remoting/host/policy_hack/policy_watcher_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698