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

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

Issue 5754002: Moving away from shell api to support long path names on windows for filesystem. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_path_manager.h" 5 #include "webkit/fileapi/file_system_path_manager.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 DispatchCallbackOnCallerThread(FilePath()); 117 DispatchCallbackOnCallerThread(FilePath());
118 return; 118 return;
119 } 119 }
120 120
121 // Creates the root directory. 121 // Creates the root directory.
122 root = base_path.Append(CreateUniqueDirectoryName(origin_url)); 122 root = base_path.Append(CreateUniqueDirectoryName(origin_url));
123 if (!file_util::CreateDirectory(root)) { 123 if (!file_util::CreateDirectory(root)) {
124 DispatchCallbackOnCallerThread(FilePath()); 124 DispatchCallbackOnCallerThread(FilePath());
125 return; 125 return;
126 } 126 }
127
127 DispatchCallbackOnCallerThread(root); 128 DispatchCallbackOnCallerThread(root);
128 } 129 }
129 130
130 bool ReadOriginDirectory(const FilePath& base_path, 131 bool ReadOriginDirectory(const FilePath& base_path,
131 const GURL& origin_url, 132 const GURL& origin_url,
132 FilePath* unique) { 133 FilePath* unique) {
133 file_util::FileEnumerator file_enum( 134 file_util::FileEnumerator file_enum(
134 base_path, false /* recursive */, 135 base_path, false /* recursive */,
135 file_util::FileEnumerator::DIRECTORIES, 136 file_util::FileEnumerator::DIRECTORIES,
136 FilePath::StringType(kFileSystemUniqueNamePrefix) + 137 FilePath::StringType(kFileSystemUniqueNamePrefix) +
(...skipping 26 matching lines...) Expand all
163 callback_->Run(!root_path.empty(), root_path, name_); 164 callback_->Run(!root_path.empty(), root_path, name_);
164 callback_.reset(); 165 callback_.reset();
165 } 166 }
166 167
167 scoped_refptr<base::MessageLoopProxy> file_message_loop_; 168 scoped_refptr<base::MessageLoopProxy> file_message_loop_;
168 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; 169 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_;
169 std::string name_; 170 std::string name_;
170 scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback_; 171 scoped_ptr<FileSystemPathManager::GetRootPathCallback> callback_;
171 }; 172 };
172 173
174 FilePath FileSystemPathManager::GetFileSystemCommonRootDirectory(
175 const FilePath& root_path) {
176 #if defined(OS_WIN)
177 // To specify an extended-length path, "\\?\" prefix is used. Else path names
178 // are limited to 260 characters.
179 if (!root_path.StartsWithExtendedPathPrefix()) {
Erik does not do reviews 2010/12/16 18:34:54 I really don't like this approach. Doesn't this m
Mark Mentovai 2010/12/16 19:48:19 This is wrong. It should check whether root_path i
Kavita Kanetkar 2010/12/17 00:59:32 Isn't it the case that even in UNC if path doesn't
michaeln 2010/12/17 01:22:24 In gears this was handled by doing the \\?\'ificat
Kavita Kanetkar 2010/12/23 03:14:28 Changed this to a central place in FilePath. And m
180 FilePath::StringType extended_length_str(FilePath::kExtendedPathPrefix);
181 extended_length_str.append(root_path.value());
182 return FilePath(extended_length_str).Append(kFileSystemDirectory);
Mark Mentovai 2010/12/16 19:48:19 Nobody takes care to do this anywhere else in Chro
Kavita Kanetkar 2010/12/17 00:59:32 Yes. Actually shell32 api that restricts path leng
183 }
184 #endif
185 return root_path.Append(kFileSystemDirectory);
186 }
187
173 FileSystemPathManager::FileSystemPathManager( 188 FileSystemPathManager::FileSystemPathManager(
174 scoped_refptr<base::MessageLoopProxy> file_message_loop, 189 scoped_refptr<base::MessageLoopProxy> file_message_loop,
175 const FilePath& profile_path, 190 const FilePath& profile_path,
176 bool is_incognito, 191 bool is_incognito,
177 bool allow_file_access_from_files) 192 bool allow_file_access_from_files)
178 : file_message_loop_(file_message_loop), 193 : file_message_loop_(file_message_loop),
179 base_path_(profile_path.Append(kFileSystemDirectory)), 194 base_path_(GetFileSystemCommonRootDirectory(profile_path)),
180 is_incognito_(is_incognito), 195 is_incognito_(is_incognito),
181 allow_file_access_from_files_(allow_file_access_from_files) { 196 allow_file_access_from_files_(allow_file_access_from_files) {
182 } 197 }
183 198
184 FileSystemPathManager::~FileSystemPathManager() {} 199 FileSystemPathManager::~FileSystemPathManager() {}
185 200
186 void FileSystemPathManager::GetFileSystemRootPath( 201 void FileSystemPathManager::GetFileSystemRootPath(
187 const GURL& origin_url, fileapi::FileSystemType type, 202 const GURL& origin_url, fileapi::FileSystemType type,
188 bool create, GetRootPathCallback* callback_ptr) { 203 bool create, GetRootPathCallback* callback_ptr) {
189 scoped_ptr<GetRootPathCallback> callback(callback_ptr); 204 scoped_ptr<GetRootPathCallback> callback(callback_ptr);
(...skipping 18 matching lines...) Expand all
208 std::string storage_identifier = GetStorageIdentifierFromURL(origin_url); 223 std::string storage_identifier = GetStorageIdentifierFromURL(origin_url);
209 224
210 std::string type_string; 225 std::string type_string;
211 if (type == fileapi::kFileSystemTypeTemporary) 226 if (type == fileapi::kFileSystemTypeTemporary)
212 type_string = kTemporaryName; 227 type_string = kTemporaryName;
213 else if (type == fileapi::kFileSystemTypePersistent) 228 else if (type == fileapi::kFileSystemTypePersistent)
214 type_string = kPersistentName; 229 type_string = kPersistentName;
215 DCHECK(!type_string.empty()); 230 DCHECK(!type_string.empty());
216 231
217 FilePath origin_base_path = base_path_.AppendASCII(storage_identifier) 232 FilePath origin_base_path = base_path_.AppendASCII(storage_identifier)
218 .AppendASCII(type_string); 233 .AppendASCII(type_string);
234
219 std::string name = storage_identifier + ":" + type_string; 235 std::string name = storage_identifier + ":" + type_string;
220 236
221 scoped_refptr<GetFileSystemRootPathTask> task( 237 scoped_refptr<GetFileSystemRootPathTask> task(
222 new GetFileSystemRootPathTask(file_message_loop_, 238 new GetFileSystemRootPathTask(file_message_loop_,
223 name, callback.release())); 239 name, callback.release()));
224 task->Start(origin_url, origin_base_path, create); 240 task->Start(origin_url, origin_base_path, create);
225 } 241 }
226 242
227 bool FileSystemPathManager::CrackFileSystemPath( 243 bool FileSystemPathManager::CrackFileSystemPath(
228 const FilePath& path, GURL* origin_url, FileSystemType* type, 244 const FilePath& path, GURL* origin_url, FileSystemType* type,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec())); 348 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec()));
333 return web_security_origin.databaseIdentifier().utf8(); 349 return web_security_origin.databaseIdentifier().utf8();
334 } 350 }
335 351
336 } // namespace fileapi 352 } // namespace fileapi
337 353
338 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ 354 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \
339 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); 355 int(fileapi::kFileSystemTypeTemporary), mismatching_enums);
340 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ 356 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \
341 int(fileapi::kFileSystemTypePersistent), mismatching_enums); 357 int(fileapi::kFileSystemTypePersistent), mismatching_enums);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698