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

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 return root_path.GetLongPathHack().Append(kFileSystemDirectory);
180 #endif
181 return root_path.Append(kFileSystemDirectory);
182 }
183
173 FileSystemPathManager::FileSystemPathManager( 184 FileSystemPathManager::FileSystemPathManager(
174 scoped_refptr<base::MessageLoopProxy> file_message_loop, 185 scoped_refptr<base::MessageLoopProxy> file_message_loop,
175 const FilePath& profile_path, 186 const FilePath& profile_path,
176 bool is_incognito, 187 bool is_incognito,
177 bool allow_file_access_from_files) 188 bool allow_file_access_from_files)
178 : file_message_loop_(file_message_loop), 189 : file_message_loop_(file_message_loop),
179 base_path_(profile_path.Append(kFileSystemDirectory)), 190 base_path_(GetFileSystemCommonRootDirectory(profile_path)),
180 is_incognito_(is_incognito), 191 is_incognito_(is_incognito),
181 allow_file_access_from_files_(allow_file_access_from_files) { 192 allow_file_access_from_files_(allow_file_access_from_files) {
182 } 193 }
183 194
184 FileSystemPathManager::~FileSystemPathManager() {} 195 FileSystemPathManager::~FileSystemPathManager() {}
185 196
186 void FileSystemPathManager::GetFileSystemRootPath( 197 void FileSystemPathManager::GetFileSystemRootPath(
187 const GURL& origin_url, fileapi::FileSystemType type, 198 const GURL& origin_url, fileapi::FileSystemType type,
188 bool create, GetRootPathCallback* callback_ptr) { 199 bool create, GetRootPathCallback* callback_ptr) {
189 scoped_ptr<GetRootPathCallback> callback(callback_ptr); 200 scoped_ptr<GetRootPathCallback> callback(callback_ptr);
(...skipping 18 matching lines...) Expand all
208 std::string storage_identifier = GetStorageIdentifierFromURL(origin_url); 219 std::string storage_identifier = GetStorageIdentifierFromURL(origin_url);
209 220
210 std::string type_string; 221 std::string type_string;
211 if (type == fileapi::kFileSystemTypeTemporary) 222 if (type == fileapi::kFileSystemTypeTemporary)
212 type_string = kTemporaryName; 223 type_string = kTemporaryName;
213 else if (type == fileapi::kFileSystemTypePersistent) 224 else if (type == fileapi::kFileSystemTypePersistent)
214 type_string = kPersistentName; 225 type_string = kPersistentName;
215 DCHECK(!type_string.empty()); 226 DCHECK(!type_string.empty());
216 227
217 FilePath origin_base_path = base_path_.AppendASCII(storage_identifier) 228 FilePath origin_base_path = base_path_.AppendASCII(storage_identifier)
218 .AppendASCII(type_string); 229 .AppendASCII(type_string);
230
219 std::string name = storage_identifier + ":" + type_string; 231 std::string name = storage_identifier + ":" + type_string;
220 232
221 scoped_refptr<GetFileSystemRootPathTask> task( 233 scoped_refptr<GetFileSystemRootPathTask> task(
222 new GetFileSystemRootPathTask(file_message_loop_, 234 new GetFileSystemRootPathTask(file_message_loop_,
223 name, callback.release())); 235 name, callback.release()));
224 task->Start(origin_url, origin_base_path, create); 236 task->Start(origin_url, origin_base_path, create);
225 } 237 }
226 238
227 bool FileSystemPathManager::CrackFileSystemPath( 239 bool FileSystemPathManager::CrackFileSystemPath(
228 const FilePath& path, GURL* origin_url, FileSystemType* type, 240 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())); 344 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec()));
333 return web_security_origin.databaseIdentifier().utf8(); 345 return web_security_origin.databaseIdentifier().utf8();
334 } 346 }
335 347
336 } // namespace fileapi 348 } // namespace fileapi
337 349
338 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ 350 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \
339 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); 351 int(fileapi::kFileSystemTypeTemporary), mismatching_enums);
340 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ 352 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \
341 int(fileapi::kFileSystemTypePersistent), mismatching_enums); 353 int(fileapi::kFileSystemTypePersistent), mismatching_enums);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698