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

Side by Side Diff: chrome/browser/history/thumbnail_database_unittest.cc

Issue 109043002: Move more file_util functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 sql::Statement s(db->GetUniqueStatement(kPageSql)); 76 sql::Statement s(db->GetUniqueStatement(kPageSql));
77 s.BindString(0, name); 77 s.BindString(0, name);
78 EXPECT_TRUE(s.Step()); 78 EXPECT_TRUE(s.Step());
79 return s.ColumnInt(0); 79 return s.ColumnInt(0);
80 } 80 }
81 81
82 // Helper to read a SQLite page into a buffer. |page_no| is 1-based 82 // Helper to read a SQLite page into a buffer. |page_no| is 1-based
83 // per SQLite usage. 83 // per SQLite usage.
84 bool ReadPage(const base::FilePath& path, size_t page_no, 84 bool ReadPage(const base::FilePath& path, size_t page_no,
85 char* buf, size_t page_size) { 85 char* buf, size_t page_size) {
86 file_util::ScopedFILE file(file_util::OpenFile(path, "rb")); 86 file_util::ScopedFILE file(base::OpenFile(path, "rb"));
87 if (!file.get()) 87 if (!file.get())
88 return false; 88 return false;
89 if (0 != fseek(file.get(), (page_no - 1) * page_size, SEEK_SET)) 89 if (0 != fseek(file.get(), (page_no - 1) * page_size, SEEK_SET))
90 return false; 90 return false;
91 if (1u != fread(buf, page_size, 1, file.get())) 91 if (1u != fread(buf, page_size, 1, file.get()))
92 return false; 92 return false;
93 return true; 93 return true;
94 } 94 }
95 95
96 // Helper to write a SQLite page into a buffer. |page_no| is 1-based 96 // Helper to write a SQLite page into a buffer. |page_no| is 1-based
97 // per SQLite usage. 97 // per SQLite usage.
98 bool WritePage(const base::FilePath& path, size_t page_no, 98 bool WritePage(const base::FilePath& path, size_t page_no,
99 const char* buf, size_t page_size) { 99 const char* buf, size_t page_size) {
100 file_util::ScopedFILE file(file_util::OpenFile(path, "rb+")); 100 file_util::ScopedFILE file(base::OpenFile(path, "rb+"));
101 if (!file.get()) 101 if (!file.get())
102 return false; 102 return false;
103 if (0 != fseek(file.get(), (page_no - 1) * page_size, SEEK_SET)) 103 if (0 != fseek(file.get(), (page_no - 1) * page_size, SEEK_SET))
104 return false; 104 return false;
105 if (1u != fwrite(buf, page_size, 1, file.get())) 105 if (1u != fwrite(buf, page_size, 1, file.get()))
106 return false; 106 return false;
107 return true; 107 return true;
108 } 108 }
109 109
110 // Verify that the up-to-date database has the expected tables and 110 // Verify that the up-to-date database has the expected tables and
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 ThumbnailDatabase db; 1014 ThumbnailDatabase db;
1015 ASSERT_EQ(sql::INIT_OK, db.Init(db_path)); 1015 ASSERT_EQ(sql::INIT_OK, db.Init(db_path));
1016 1016
1017 // Verify that the resulting schema is correct, whether it 1017 // Verify that the resulting schema is correct, whether it
1018 // involved razing the file or fixing things in place. 1018 // involved razing the file or fixing things in place.
1019 VerifyTablesAndColumns(&db.db_); 1019 VerifyTablesAndColumns(&db.db_);
1020 } 1020 }
1021 } 1021 }
1022 1022
1023 } // namespace history 1023 } // namespace history
OLDNEW
« no previous file with comments | « chrome/browser/extensions/sandboxed_unpacker.cc ('k') | chrome/browser/importer/firefox_profile_lock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698