| OLD | NEW |
| 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/browser/fileapi/sandbox_directory_database.h" | 5 #include "webkit/browser/fileapi/sandbox_directory_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 SandboxDirectoryDatabase* db() { | 39 SandboxDirectoryDatabase* db() { |
| 40 return db_.get(); | 40 return db_.get(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void InitDatabase() { | 43 void InitDatabase() { |
| 44 // Call CloseDatabase() to avoid having multiple database instances for | 44 // Call CloseDatabase() to avoid having multiple database instances for |
| 45 // single directory at once. | 45 // single directory at once. |
| 46 CloseDatabase(); | 46 CloseDatabase(); |
| 47 db_.reset(new SandboxDirectoryDatabase(path())); | 47 db_.reset(new SandboxDirectoryDatabase(path(), NULL)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void CloseDatabase() { | 50 void CloseDatabase() { |
| 51 db_.reset(); | 51 db_.reset(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 base::File::Error AddFileInfo( | 54 base::File::Error AddFileInfo( |
| 55 FileId parent_id, const base::FilePath::StringType& name) { | 55 FileId parent_id, const base::FilePath::StringType& name) { |
| 56 FileId file_id; | 56 FileId file_id; |
| 57 FileInfo info; | 57 FileInfo info; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 ASSERT_TRUE(file.created()); | 91 ASSERT_TRUE(file.created()); |
| 92 | 92 |
| 93 if (file_id_out) | 93 if (file_id_out) |
| 94 *file_id_out = file_id; | 94 *file_id_out = file_id; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void ClearDatabaseAndDirectory() { | 97 void ClearDatabaseAndDirectory() { |
| 98 db_.reset(); | 98 db_.reset(); |
| 99 ASSERT_TRUE(base::DeleteFile(path(), true /* recursive */)); | 99 ASSERT_TRUE(base::DeleteFile(path(), true /* recursive */)); |
| 100 ASSERT_TRUE(base::CreateDirectory(path())); | 100 ASSERT_TRUE(base::CreateDirectory(path())); |
| 101 db_.reset(new SandboxDirectoryDatabase(path())); | 101 db_.reset(new SandboxDirectoryDatabase(path(), NULL)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool RepairDatabase() { | 104 bool RepairDatabase() { |
| 105 return db()->RepairDatabase( | 105 return db()->RepairDatabase( |
| 106 FilePathToString(path().Append(kDirectoryDatabaseName))); | 106 FilePathToString(path().Append(kDirectoryDatabaseName))); |
| 107 } | 107 } |
| 108 | 108 |
| 109 const base::FilePath& path() { | 109 const base::FilePath& path() { |
| 110 return base_.path(); | 110 return base_.path(); |
| 111 } | 111 } |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 EXPECT_FALSE(db()->IsFileSystemConsistent()); | 663 EXPECT_FALSE(db()->IsFileSystemConsistent()); |
| 664 | 664 |
| 665 FileId file_id; | 665 FileId file_id; |
| 666 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id)); | 666 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id)); |
| 667 EXPECT_EQ(file_id_prev, file_id); | 667 EXPECT_EQ(file_id_prev, file_id); |
| 668 | 668 |
| 669 EXPECT_TRUE(db()->IsFileSystemConsistent()); | 669 EXPECT_TRUE(db()->IsFileSystemConsistent()); |
| 670 } | 670 } |
| 671 | 671 |
| 672 } // namespace fileapi | 672 } // namespace fileapi |
| OLD | NEW |