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_origin_database.h" | 5 #include "webkit/browser/fileapi/sandbox_origin_database.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 SandboxOriginDatabase::~SandboxOriginDatabase() { | 65 SandboxOriginDatabase::~SandboxOriginDatabase() { |
66 } | 66 } |
67 | 67 |
68 bool SandboxOriginDatabase::Init(InitOption init_option, | 68 bool SandboxOriginDatabase::Init(InitOption init_option, |
69 RecoveryOption recovery_option) { | 69 RecoveryOption recovery_option) { |
70 if (db_) | 70 if (db_) |
71 return true; | 71 return true; |
72 | 72 |
73 base::FilePath db_path = GetDatabasePath(); | 73 base::FilePath db_path = GetDatabasePath(); |
74 if (init_option == FAIL_IF_NONEXISTENT && !file_util::PathExists(db_path)) | 74 if (init_option == FAIL_IF_NONEXISTENT && !base::PathExists(db_path)) |
75 return false; | 75 return false; |
76 | 76 |
77 std::string path = FilePathToString(db_path); | 77 std::string path = FilePathToString(db_path); |
78 leveldb::Options options; | 78 leveldb::Options options; |
79 options.create_if_missing = true; | 79 options.create_if_missing = true; |
80 leveldb::DB* db; | 80 leveldb::DB* db; |
81 leveldb::Status status = leveldb::DB::Open(options, path, &db); | 81 leveldb::Status status = leveldb::DB::Open(options, path, &db); |
82 ReportInitStatus(status); | 82 ReportInitStatus(status); |
83 if (status.ok()) { | 83 if (status.ok()) { |
84 db_.reset(db); | 84 db_.reset(db); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); | 329 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); |
330 if (!status.ok()) { | 330 if (!status.ok()) { |
331 HandleError(FROM_HERE, status); | 331 HandleError(FROM_HERE, status); |
332 return false; | 332 return false; |
333 } | 333 } |
334 *number = -1; | 334 *number = -1; |
335 return true; | 335 return true; |
336 } | 336 } |
337 | 337 |
338 } // namespace fileapi | 338 } // namespace fileapi |
OLD | NEW |