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

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

Issue 12258021: Fix filesystem API file_handlers to work for drive on ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
« no previous file with comments | « webkit/fileapi/isolated_context.h ('k') | webkit/fileapi/mount_points.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/isolated_context.h" 5 #include "webkit/fileapi/isolated_context.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 for (; component_iter != components.end(); ++component_iter) 294 for (; component_iter != components.end(); ++component_iter)
295 cracked_path = cracked_path.Append(*component_iter); 295 cracked_path = cracked_path.Append(*component_iter);
296 *path = cracked_path; 296 *path = cracked_path;
297 return true; 297 return true;
298 } 298 }
299 299
300 FileSystemURL IsolatedContext::CrackURL(const GURL& url) const { 300 FileSystemURL IsolatedContext::CrackURL(const GURL& url) const {
301 FileSystemURL filesystem_url = FileSystemURL(url); 301 FileSystemURL filesystem_url = FileSystemURL(url);
302 if (!filesystem_url.is_valid()) 302 if (!filesystem_url.is_valid())
303 return FileSystemURL(); 303 return FileSystemURL();
304 return CreateCrackedFileSystemURL(filesystem_url.origin(), 304 return CrackFileSystemURL(filesystem_url);
305 filesystem_url.mount_type(), 305 }
306 filesystem_url.path()); 306
307 FileSystemURL IsolatedContext::CrackFileSystemURL(
308 const FileSystemURL& url) const {
309 if (!HandlesFileSystemMountType(url.type()))
310 return FileSystemURL();
311
312 std::string mount_name;
313 FileSystemType cracked_type;
314 base::FilePath cracked_path;
315 if (!CrackVirtualPath(url.path(), &mount_name, &cracked_type, &cracked_path))
316 return FileSystemURL();
317
318 return FileSystemURL(
319 url.origin(), url.mount_type(), url.virtual_path(),
320 !url.filesystem_id().empty() ? url.filesystem_id() : mount_name,
321 cracked_type, cracked_path, mount_name);
307 } 322 }
308 323
309 FileSystemURL IsolatedContext::CreateCrackedFileSystemURL( 324 FileSystemURL IsolatedContext::CreateCrackedFileSystemURL(
310 const GURL& origin, 325 const GURL& origin,
311 FileSystemType type, 326 FileSystemType type,
312 const base::FilePath& path) const { 327 const base::FilePath& path) const {
313 if (!HandlesFileSystemMountType(type)) 328 return CrackFileSystemURL(FileSystemURL(origin, type, path));
314 return FileSystemURL();
315
316 std::string mount_name;
317 FileSystemType cracked_type;
318 base::FilePath cracked_path;
319 if (!CrackVirtualPath(path, &mount_name, &cracked_type, &cracked_path))
320 return FileSystemURL();
321
322 return FileSystemURL(origin, type, path,
323 mount_name, cracked_type, cracked_path);
324 } 329 }
325 330
326 void IsolatedContext::RevokeFileSystemByPath(const base::FilePath& path_in) { 331 void IsolatedContext::RevokeFileSystemByPath(const base::FilePath& path_in) {
327 base::AutoLock locker(lock_); 332 base::AutoLock locker(lock_);
328 base::FilePath path(path_in.NormalizePathSeparators()); 333 base::FilePath path(path_in.NormalizePathSeparators());
329 PathToID::iterator ids_iter = path_to_id_map_.find(path); 334 PathToID::iterator ids_iter = path_to_id_map_.find(path);
330 if (ids_iter == path_to_id_map_.end()) 335 if (ids_iter == path_to_id_map_.end())
331 return; 336 return;
332 std::set<std::string>& ids = ids_iter->second; 337 std::set<std::string>& ids = ids_iter->second;
333 for (std::set<std::string>::iterator iter = ids.begin(); 338 for (std::set<std::string>::iterator iter = ids.begin();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 uint32 random_data[4]; 420 uint32 random_data[4];
416 std::string id; 421 std::string id;
417 do { 422 do {
418 base::RandBytes(random_data, sizeof(random_data)); 423 base::RandBytes(random_data, sizeof(random_data));
419 id = base::HexEncode(random_data, sizeof(random_data)); 424 id = base::HexEncode(random_data, sizeof(random_data));
420 } while (instance_map_.find(id) != instance_map_.end()); 425 } while (instance_map_.find(id) != instance_map_.end());
421 return id; 426 return id;
422 } 427 }
423 428
424 } // namespace fileapi 429 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/isolated_context.h ('k') | webkit/fileapi/mount_points.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698