OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "sql/test/test_helpers.h" | 5 #include "sql/test/test_helpers.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 file_util::ScopedFILE file(file_util::OpenFile(db_path, "rb+")); | 58 file_util::ScopedFILE file(file_util::OpenFile(db_path, "rb+")); |
59 if (!file.get()) | 59 if (!file.get()) |
60 return false; | 60 return false; |
61 | 61 |
62 if (0 != fseek(file.get(), 0, SEEK_SET)) | 62 if (0 != fseek(file.get(), 0, SEEK_SET)) |
63 return false; | 63 return false; |
64 if (1u != fread(header, sizeof(header), 1, file.get())) | 64 if (1u != fread(header, sizeof(header), 1, file.get())) |
65 return false; | 65 return false; |
66 | 66 |
67 int64 db_size = 0; | 67 int64 db_size = 0; |
68 if (!file_util::GetFileSize(db_path, &db_size)) | 68 if (!base::GetFileSize(db_path, &db_size)) |
69 return false; | 69 return false; |
70 | 70 |
71 const unsigned page_size = ReadBigEndian(header + kPageSizeOffset, 2); | 71 const unsigned page_size = ReadBigEndian(header + kPageSizeOffset, 2); |
72 | 72 |
73 // One larger than the expected size. | 73 // One larger than the expected size. |
74 const unsigned page_count = (db_size + page_size) / page_size; | 74 const unsigned page_count = (db_size + page_size) / page_size; |
75 WriteBigEndian(page_count, header + kPageCountOffset, 4); | 75 WriteBigEndian(page_count, header + kPageCountOffset, 4); |
76 | 76 |
77 // Update change count so outstanding readers know the info changed. | 77 // Update change count so outstanding readers know the info changed. |
78 // Both spots must match for the page count to be considered valid. | 78 // Both spots must match for the page count to be considered valid. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check")); | 157 sql::Statement statement(db->GetUniqueStatement("PRAGMA integrity_check")); |
158 | 158 |
159 // SQLite should always return a row of data. | 159 // SQLite should always return a row of data. |
160 EXPECT_TRUE(statement.Step()); | 160 EXPECT_TRUE(statement.Step()); |
161 | 161 |
162 return statement.ColumnString(0); | 162 return statement.ColumnString(0); |
163 } | 163 } |
164 | 164 |
165 } // namespace test | 165 } // namespace test |
166 } // namespace sql | 166 } // namespace sql |
OLD | NEW |