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

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

Issue 10855039: Cleanup: Remove FileSystemFileUtil::{Directory,Path}Exists (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 8 years, 4 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/obfuscated_file_util.h ('k') | webkit/fileapi/obfuscated_file_util_unittest.cc » ('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/obfuscated_file_util.h" 5 #include "webkit/fileapi/obfuscated_file_util.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 553
554 int64 growth = length - file_info.size; 554 int64 growth = length - file_info.size;
555 if (!AllocateQuota(context, growth)) 555 if (!AllocateQuota(context, growth))
556 return base::PLATFORM_FILE_ERROR_NO_SPACE; 556 return base::PLATFORM_FILE_ERROR_NO_SPACE;
557 error = NativeFileUtil::Truncate(local_path, length); 557 error = NativeFileUtil::Truncate(local_path, length);
558 if (error == base::PLATFORM_FILE_OK) 558 if (error == base::PLATFORM_FILE_OK)
559 UpdateUsage(context, url.origin(), url.type(), growth); 559 UpdateUsage(context, url.origin(), url.type(), growth);
560 return error; 560 return error;
561 } 561 }
562 562
563 bool ObfuscatedFileUtil::PathExists(
564 FileSystemOperationContext* context,
565 const FileSystemURL& url) {
566 FileSystemDirectoryDatabase* db = GetDirectoryDatabase(
567 url.origin(), url.type(), false);
568 if (!db)
569 return false;
570 FileId file_id;
571 return db->GetFileWithPath(url.path(), &file_id);
572 }
573
574 bool ObfuscatedFileUtil::DirectoryExists(
575 FileSystemOperationContext* context,
576 const FileSystemURL& url) {
577 if (IsRootDirectory(url)) {
578 // It's questionable whether we should return true or false for the
579 // root directory of nonexistent origin, but here we return true
580 // as the current implementation of ReadDirectory always returns an empty
581 // array (rather than erroring out with NOT_FOUND_ERR even) for
582 // nonexistent origins.
583 // Note: if you're going to change this behavior please also consider
584 // changiing the ReadDirectory's behavior!
585 return true;
586 }
587 FileSystemDirectoryDatabase* db = GetDirectoryDatabase(
588 url.origin(), url.type(), false);
589 if (!db)
590 return false;
591 FileId file_id;
592 if (!db->GetFileWithPath(url.path(), &file_id))
593 return false;
594 FileInfo file_info;
595 if (!db->GetFileInfo(file_id, &file_info)) {
596 NOTREACHED();
597 return false;
598 }
599 return file_info.is_directory();
600 }
601
602 bool ObfuscatedFileUtil::IsDirectoryEmpty( 563 bool ObfuscatedFileUtil::IsDirectoryEmpty(
603 FileSystemOperationContext* context, 564 FileSystemOperationContext* context,
604 const FileSystemURL& url) { 565 const FileSystemURL& url) {
605 FileSystemDirectoryDatabase* db = GetDirectoryDatabase( 566 FileSystemDirectoryDatabase* db = GetDirectoryDatabase(
606 url.origin(), url.type(), false); 567 url.origin(), url.type(), false);
607 if (!db) 568 if (!db)
608 return true; // Not a great answer, but it's what others do. 569 return true; // Not a great answer, but it's what others do.
609 FileId file_id; 570 FileId file_id;
610 if (!db->GetFileWithPath(url.path(), &file_id)) 571 if (!db->GetFileWithPath(url.path(), &file_id))
611 return true; // Ditto. 572 return true; // Ditto.
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 error = NativeFileUtil::CreateDirectory( 1349 error = NativeFileUtil::CreateDirectory(
1389 new_local_path, false /* exclusive */, false /* recursive */); 1350 new_local_path, false /* exclusive */, false /* recursive */);
1390 if (error != base::PLATFORM_FILE_OK) 1351 if (error != base::PLATFORM_FILE_OK)
1391 return error; 1352 return error;
1392 1353
1393 *local_path = new_local_path.AppendASCII(StringPrintf("%08" PRId64, number)); 1354 *local_path = new_local_path.AppendASCII(StringPrintf("%08" PRId64, number));
1394 return base::PLATFORM_FILE_OK; 1355 return base::PLATFORM_FILE_OK;
1395 } 1356 }
1396 1357
1397 } // namespace fileapi 1358 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/obfuscated_file_util.h ('k') | webkit/fileapi/obfuscated_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698