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

Side by Side Diff: webkit/fileapi/file_system_dir_url_request_job.cc

Issue 14671020: FileAPI: Copy base::FileUtilProxy::Entry to fileapi::DirectoryEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build and remove base/ change 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 "webkit/fileapi/file_system_dir_url_request_job.h" 5 #include "webkit/fileapi/file_system_dir_url_request_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/files/file_util_proxy.h"
12 #include "base/message_loop.h" 11 #include "base/message_loop.h"
13 #include "base/platform_file.h" 12 #include "base/platform_file.h"
14 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
15 #include "base/time.h" 14 #include "base/time.h"
16 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
17 #include "build/build_config.h" 16 #include "build/build_config.h"
18 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
19 #include "net/base/io_buffer.h" 18 #include "net/base/io_buffer.h"
20 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
21 #include "net/base/net_util.h" 20 #include "net/base/net_util.h"
22 #include "net/url_request/url_request.h" 21 #include "net/url_request/url_request.h"
22 #include "webkit/fileapi/directory_entry.h"
23 #include "webkit/fileapi/file_system_context.h" 23 #include "webkit/fileapi/file_system_context.h"
24 #include "webkit/fileapi/file_system_operation.h" 24 #include "webkit/fileapi/file_system_operation.h"
25 #include "webkit/fileapi/file_system_url.h" 25 #include "webkit/fileapi/file_system_url.h"
26 26
27 using net::NetworkDelegate; 27 using net::NetworkDelegate;
28 using net::URLRequest; 28 using net::URLRequest;
29 using net::URLRequestJob; 29 using net::URLRequestJob;
30 using net::URLRequestStatus; 30 using net::URLRequestStatus;
31 31
32 namespace fileapi { 32 namespace fileapi {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 net::PlatformFileErrorToNetError(error_code))); 87 net::PlatformFileErrorToNetError(error_code)));
88 return; 88 return;
89 } 89 }
90 operation->ReadDirectory( 90 operation->ReadDirectory(
91 url_, 91 url_,
92 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this)); 92 base::Bind(&FileSystemDirURLRequestJob::DidReadDirectory, this));
93 } 93 }
94 94
95 void FileSystemDirURLRequestJob::DidReadDirectory( 95 void FileSystemDirURLRequestJob::DidReadDirectory(
96 base::PlatformFileError result, 96 base::PlatformFileError result,
97 const std::vector<base::FileUtilProxy::Entry>& entries, 97 const std::vector<DirectoryEntry>& entries,
98 bool has_more) { 98 bool has_more) {
99 if (result != base::PLATFORM_FILE_OK) { 99 if (result != base::PLATFORM_FILE_OK) {
100 int rv = net::ERR_FILE_NOT_FOUND; 100 int rv = net::ERR_FILE_NOT_FOUND;
101 if (result == base::PLATFORM_FILE_ERROR_INVALID_URL) 101 if (result == base::PLATFORM_FILE_ERROR_INVALID_URL)
102 rv = net::ERR_INVALID_URL; 102 rv = net::ERR_INVALID_URL;
103 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv)); 103 NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, rv));
104 return; 104 return;
105 } 105 }
106 106
107 if (!request_) 107 if (!request_)
108 return; 108 return;
109 109
110 if (data_.empty()) { 110 if (data_.empty()) {
111 base::FilePath relative_path = url_.path(); 111 base::FilePath relative_path = url_.path();
112 #if defined(OS_POSIX) 112 #if defined(OS_POSIX)
113 relative_path = base::FilePath(FILE_PATH_LITERAL("/") + relative_path.value( )); 113 relative_path = base::FilePath(FILE_PATH_LITERAL("/") + relative_path.value( ));
114 #endif 114 #endif
115 const base::string16& title = relative_path.LossyDisplayName(); 115 const base::string16& title = relative_path.LossyDisplayName();
116 data_.append(net::GetDirectoryListingHeader(title)); 116 data_.append(net::GetDirectoryListingHeader(title));
117 } 117 }
118 118
119 typedef std::vector<base::FileUtilProxy::Entry>::const_iterator EntryIterator; 119 typedef std::vector<DirectoryEntry>::const_iterator EntryIterator;
120 for (EntryIterator it = entries.begin(); it != entries.end(); ++it) { 120 for (EntryIterator it = entries.begin(); it != entries.end(); ++it) {
121 const base::string16& name = base::FilePath(it->name).LossyDisplayName(); 121 const base::string16& name = base::FilePath(it->name).LossyDisplayName();
122 data_.append(net::GetDirectoryListingEntry( 122 data_.append(net::GetDirectoryListingEntry(
123 name, std::string(), it->is_directory, it->size, 123 name, std::string(), it->is_directory, it->size,
124 it->last_modified_time)); 124 it->last_modified_time));
125 } 125 }
126 126
127 if (has_more) { 127 if (has_more) {
128 base::PlatformFileError error_code; 128 base::PlatformFileError error_code;
129 FileSystemOperation* operation = GetNewOperation(&error_code); 129 FileSystemOperation* operation = GetNewOperation(&error_code);
(...skipping 12 matching lines...) Expand all
142 NotifyHeadersComplete(); 142 NotifyHeadersComplete();
143 } 143 }
144 } 144 }
145 145
146 FileSystemOperation* FileSystemDirURLRequestJob::GetNewOperation( 146 FileSystemOperation* FileSystemDirURLRequestJob::GetNewOperation(
147 base::PlatformFileError* error_code) { 147 base::PlatformFileError* error_code) {
148 return file_system_context_->CreateFileSystemOperation(url_, error_code); 148 return file_system_context_->CreateFileSystemOperation(url_, error_code);
149 } 149 }
150 150
151 } // namespace fileapi 151 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_dir_url_request_job.h ('k') | webkit/fileapi/file_system_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698