OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/indexed_db/leveldb/leveldb_database.h" | 5 #include "content/browser/indexed_db/leveldb/leveldb_database.h" |
6 | 6 |
7 #include <cerrno> | 7 #include <cerrno> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 leveldb::Env* env, | 96 leveldb::Env* env, |
97 const base::FilePath& path, | 97 const base::FilePath& path, |
98 leveldb::DB** db, | 98 leveldb::DB** db, |
99 scoped_ptr<const leveldb::FilterPolicy>* filter_policy) { | 99 scoped_ptr<const leveldb::FilterPolicy>* filter_policy) { |
100 filter_policy->reset(leveldb::NewBloomFilterPolicy(10)); | 100 filter_policy->reset(leveldb::NewBloomFilterPolicy(10)); |
101 leveldb::Options options; | 101 leveldb::Options options; |
102 options.comparator = comparator; | 102 options.comparator = comparator; |
103 options.create_if_missing = true; | 103 options.create_if_missing = true; |
104 options.paranoid_checks = true; | 104 options.paranoid_checks = true; |
105 options.filter_policy = filter_policy->get(); | 105 options.filter_policy = filter_policy->get(); |
| 106 #if defined(OS_CHROMEOS) |
| 107 // Reusing logs on Chrome OS resulted in an unacceptably high leveldb |
| 108 // corruption rate (at least for Indexed DB). More info at |
| 109 // https://crbug.com/460568 |
| 110 options.reuse_logs = false; |
| 111 #else |
106 options.reuse_logs = true; | 112 options.reuse_logs = true; |
| 113 #endif |
107 options.compression = leveldb::kSnappyCompression; | 114 options.compression = leveldb::kSnappyCompression; |
108 | 115 |
109 // For info about the troubles we've run into with this parameter, see: | 116 // For info about the troubles we've run into with this parameter, see: |
110 // https://code.google.com/p/chromium/issues/detail?id=227313#c11 | 117 // https://code.google.com/p/chromium/issues/detail?id=227313#c11 |
111 options.max_open_files = 80; | 118 options.max_open_files = 80; |
112 options.env = env; | 119 options.env = env; |
113 | 120 |
114 // ChromiumEnv assumes UTF8, converts back to FilePath before using. | 121 // ChromiumEnv assumes UTF8, converts back to FilePath before using. |
115 leveldb::Status s = leveldb::DB::Open(options, path.AsUTF8Unsafe(), db); | 122 leveldb::Status s = leveldb::DB::Open(options, path.AsUTF8Unsafe(), db); |
116 | 123 |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 const leveldb::Slice start_slice = MakeSlice(start); | 427 const leveldb::Slice start_slice = MakeSlice(start); |
421 const leveldb::Slice stop_slice = MakeSlice(stop); | 428 const leveldb::Slice stop_slice = MakeSlice(stop); |
422 // NULL batch means just wait for earlier writes to be done | 429 // NULL batch means just wait for earlier writes to be done |
423 db_->Write(leveldb::WriteOptions(), NULL); | 430 db_->Write(leveldb::WriteOptions(), NULL); |
424 db_->CompactRange(&start_slice, &stop_slice); | 431 db_->CompactRange(&start_slice, &stop_slice); |
425 } | 432 } |
426 | 433 |
427 void LevelDBDatabase::CompactAll() { db_->CompactRange(NULL, NULL); } | 434 void LevelDBDatabase::CompactAll() { db_->CompactRange(NULL, NULL); } |
428 | 435 |
429 } // namespace content | 436 } // namespace content |
OLD | NEW |