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

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

Issue 5259003: On windows filepaths need \\?\ prefix to allow extended file path names. Fix ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 FilePath::StringType extended_length_str(L"\\\\?\\");
180 extended_length_str.append(root_path.value());
181 return FilePath(extended_length_str).Append(kFileSystemDirectory);
182 #endif
183 return root_path.Append(kFileSystemDirectory);
184 }
185
173 FileSystemPathManager::FileSystemPathManager( 186 FileSystemPathManager::FileSystemPathManager(
174 scoped_refptr<base::MessageLoopProxy> file_message_loop, 187 scoped_refptr<base::MessageLoopProxy> file_message_loop,
175 const FilePath& profile_path, 188 const FilePath& profile_path,
176 bool is_incognito, 189 bool is_incognito,
177 bool allow_file_access_from_files) 190 bool allow_file_access_from_files)
178 : file_message_loop_(file_message_loop), 191 : file_message_loop_(file_message_loop),
179 base_path_(profile_path.Append(kFileSystemDirectory)), 192 base_path_(profile_path),
kinuko (google) 2010/11/25 03:36:47 Please remove this line and use profile_path below
Kavita Kanetkar 2010/11/25 03:42:05 Done.
180 is_incognito_(is_incognito), 193 is_incognito_(is_incognito),
181 allow_file_access_from_files_(allow_file_access_from_files) { 194 allow_file_access_from_files_(allow_file_access_from_files) {
195 base_path_ = GetFileSystemCommonRootDirectory(base_path_);
182 } 196 }
183 197
184 FileSystemPathManager::~FileSystemPathManager() {} 198 FileSystemPathManager::~FileSystemPathManager() {}
185 199
186 void FileSystemPathManager::GetFileSystemRootPath( 200 void FileSystemPathManager::GetFileSystemRootPath(
187 const GURL& origin_url, fileapi::FileSystemType type, 201 const GURL& origin_url, fileapi::FileSystemType type,
188 bool create, GetRootPathCallback* callback_ptr) { 202 bool create, GetRootPathCallback* callback_ptr) {
189 scoped_ptr<GetRootPathCallback> callback(callback_ptr); 203 scoped_ptr<GetRootPathCallback> callback(callback_ptr);
190 if (is_incognito_) { 204 if (is_incognito_) {
191 // TODO(kinuko): return an isolated temporary directory. 205 // TODO(kinuko): return an isolated temporary directory.
(...skipping 16 matching lines...) Expand all
208 std::string storage_identifier = GetStorageIdentifierFromURL(origin_url); 222 std::string storage_identifier = GetStorageIdentifierFromURL(origin_url);
209 223
210 std::string type_string; 224 std::string type_string;
211 if (type == fileapi::kFileSystemTypeTemporary) 225 if (type == fileapi::kFileSystemTypeTemporary)
212 type_string = kTemporaryName; 226 type_string = kTemporaryName;
213 else if (type == fileapi::kFileSystemTypePersistent) 227 else if (type == fileapi::kFileSystemTypePersistent)
214 type_string = kPersistentName; 228 type_string = kPersistentName;
215 DCHECK(!type_string.empty()); 229 DCHECK(!type_string.empty());
216 230
217 FilePath origin_base_path = base_path_.AppendASCII(storage_identifier) 231 FilePath origin_base_path = base_path_.AppendASCII(storage_identifier)
218 .AppendASCII(type_string); 232 .AppendASCII(type_string);
233
219 std::string name = storage_identifier + ":" + type_string; 234 std::string name = storage_identifier + ":" + type_string;
220 235
221 scoped_refptr<GetFileSystemRootPathTask> task( 236 scoped_refptr<GetFileSystemRootPathTask> task(
222 new GetFileSystemRootPathTask(file_message_loop_, 237 new GetFileSystemRootPathTask(file_message_loop_,
223 name, callback.release())); 238 name, callback.release()));
224 task->Start(origin_url, origin_base_path, create); 239 task->Start(origin_url, origin_base_path, create);
225 } 240 }
226 241
227 bool FileSystemPathManager::CrackFileSystemPath( 242 bool FileSystemPathManager::CrackFileSystemPath(
228 const FilePath& path, GURL* origin_url, FileSystemType* type, 243 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())); 347 WebKit::WebSecurityOrigin::createFromString(UTF8ToUTF16(url.spec()));
333 return web_security_origin.databaseIdentifier().utf8(); 348 return web_security_origin.databaseIdentifier().utf8();
334 } 349 }
335 350
336 } // namespace fileapi 351 } // namespace fileapi
337 352
338 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \ 353 COMPILE_ASSERT(int(WebFileSystem::TypeTemporary) == \
339 int(fileapi::kFileSystemTypeTemporary), mismatching_enums); 354 int(fileapi::kFileSystemTypeTemporary), mismatching_enums);
340 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \ 355 COMPILE_ASSERT(int(WebFileSystem::TypePersistent) == \
341 int(fileapi::kFileSystemTypePersistent), mismatching_enums); 356 int(fileapi::kFileSystemTypePersistent), mismatching_enums);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698