| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "storage/browser/fileapi/sandbox_directory_database.h" | 5 #include "storage/browser/fileapi/sandbox_directory_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ASSERT_TRUE(base::DeleteFile(path(), true /* recursive */)); | 106 ASSERT_TRUE(base::DeleteFile(path(), true /* recursive */)); |
| 107 ASSERT_TRUE(base::CreateDirectory(path())); | 107 ASSERT_TRUE(base::CreateDirectory(path())); |
| 108 db_.reset(new SandboxDirectoryDatabase(path(), NULL)); | 108 db_.reset(new SandboxDirectoryDatabase(path(), NULL)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool RepairDatabase() { | 111 bool RepairDatabase() { |
| 112 return db()->RepairDatabase( | 112 return db()->RepairDatabase( |
| 113 FilePathToString(path().Append(kDirectoryDatabaseName))); | 113 FilePathToString(path().Append(kDirectoryDatabaseName))); |
| 114 } | 114 } |
| 115 | 115 |
| 116 const base::FilePath& path() { | 116 const base::FilePath& path() { return base_.GetPath(); } |
| 117 return base_.path(); | |
| 118 } | |
| 119 | 117 |
| 120 // Makes link from |parent_id| to |child_id| with |name|. | 118 // Makes link from |parent_id| to |child_id| with |name|. |
| 121 void MakeHierarchyLink(FileId parent_id, | 119 void MakeHierarchyLink(FileId parent_id, |
| 122 FileId child_id, | 120 FileId child_id, |
| 123 const base::FilePath::StringType& name) { | 121 const base::FilePath::StringType& name) { |
| 124 ASSERT_TRUE(db()->db_->Put( | 122 ASSERT_TRUE(db()->db_->Put( |
| 125 leveldb::WriteOptions(), | 123 leveldb::WriteOptions(), |
| 126 "CHILD_OF:" + base::Int64ToString(parent_id) + ":" + | 124 "CHILD_OF:" + base::Int64ToString(parent_id) + ":" + |
| 127 FilePathToString(base::FilePath(name)), | 125 FilePathToString(base::FilePath(name)), |
| 128 base::Int64ToString(child_id)).ok()); | 126 base::Int64ToString(child_id)).ok()); |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 EXPECT_FALSE(db()->IsFileSystemConsistent()); | 668 EXPECT_FALSE(db()->IsFileSystemConsistent()); |
| 671 | 669 |
| 672 FileId file_id; | 670 FileId file_id; |
| 673 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id)); | 671 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id)); |
| 674 EXPECT_EQ(file_id_prev, file_id); | 672 EXPECT_EQ(file_id_prev, file_id); |
| 675 | 673 |
| 676 EXPECT_TRUE(db()->IsFileSystemConsistent()); | 674 EXPECT_TRUE(db()->IsFileSystemConsistent()); |
| 677 } | 675 } |
| 678 | 676 |
| 679 } // namespace content | 677 } // namespace content |
| OLD | NEW |