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

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

Issue 9663021: Add database recovery for FileSystemOriginDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add comment, remove default label Created 8 years, 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_system_directory_database.h" 5 #include "webkit/fileapi/file_system_directory_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 12 matching lines...) Expand all
23 EXPECT_TRUE(base_.CreateUniqueTempDir()); 23 EXPECT_TRUE(base_.CreateUniqueTempDir());
24 InitDatabase(); 24 InitDatabase();
25 } 25 }
26 26
27 FileSystemDirectoryDatabase* db() { 27 FileSystemDirectoryDatabase* db() {
28 return db_.get(); 28 return db_.get();
29 } 29 }
30 30
31 void InitDatabase() { 31 void InitDatabase() {
32 db_.reset(); 32 db_.reset();
33 FilePath path = base_.path().AppendASCII("db"); 33 db_.reset(new FileSystemDirectoryDatabase(base_.path()));
ericu 2012/03/26 18:39:18 Remove the extra reset() call.
tzik 2012/03/27 02:44:18 First reset() call is to avoid multiple database i
ericu 2012/03/29 04:22:19 Sure, thanks for the comment.
34 db_.reset(new FileSystemDirectoryDatabase(path));
35 } 34 }
36 35
37 bool AddFileInfo(FileId parent_id, const FilePath::StringType& name) { 36 bool AddFileInfo(FileId parent_id, const FilePath::StringType& name) {
38 FileId file_id; 37 FileId file_id;
39 FileInfo info; 38 FileInfo info;
40 info.parent_id = parent_id; 39 info.parent_id = parent_id;
41 info.name = name; 40 info.name = name;
42 return db_->AddFileInfo(info, &file_id); 41 return db_->AddFileInfo(info, &file_id);
43 } 42 }
44 43
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 EXPECT_TRUE(db()->GetNextInteger(&next)); 410 EXPECT_TRUE(db()->GetNextInteger(&next));
412 EXPECT_EQ(2, next); 411 EXPECT_EQ(2, next);
413 EXPECT_TRUE(db()->GetNextInteger(&next)); 412 EXPECT_TRUE(db()->GetNextInteger(&next));
414 EXPECT_EQ(3, next); 413 EXPECT_EQ(3, next);
415 InitDatabase(); 414 InitDatabase();
416 EXPECT_TRUE(db()->GetNextInteger(&next)); 415 EXPECT_TRUE(db()->GetNextInteger(&next));
417 EXPECT_EQ(4, next); 416 EXPECT_EQ(4, next);
418 } 417 }
419 418
420 } // namespace fileapi 419 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698