OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/internal_api/public/attachments/on_disk_attachment_store.h" | 5 #include "sync/internal_api/public/attachments/on_disk_attachment_store.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
13 #include "sync/internal_api/attachments/proto/attachment_store.pb.h" | 13 #include "sync/internal_api/attachments/proto/attachment_store.pb.h" |
14 #include "sync/internal_api/public/attachments/attachment_util.h" | 14 #include "sync/internal_api/public/attachments/attachment_util.h" |
15 #include "sync/protocol/attachments.pb.h" | 15 #include "sync/protocol/attachments.pb.h" |
| 16 #include "third_party/leveldatabase/env_chromium.h" |
16 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 17 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
17 #include "third_party/leveldatabase/src/include/leveldb/options.h" | 18 #include "third_party/leveldatabase/src/include/leveldb/options.h" |
18 #include "third_party/leveldatabase/src/include/leveldb/slice.h" | 19 #include "third_party/leveldatabase/src/include/leveldb/slice.h" |
19 #include "third_party/leveldatabase/src/include/leveldb/status.h" | 20 #include "third_party/leveldatabase/src/include/leveldb/status.h" |
20 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 21 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
21 | 22 |
22 namespace syncer { | 23 namespace syncer { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 268 |
268 AttachmentStore::Result OnDiskAttachmentStore::OpenOrCreate( | 269 AttachmentStore::Result OnDiskAttachmentStore::OpenOrCreate( |
269 const base::FilePath& path) { | 270 const base::FilePath& path) { |
270 DCHECK(!db_); | 271 DCHECK(!db_); |
271 base::FilePath leveldb_path = path.Append(kLeveldbDirectory); | 272 base::FilePath leveldb_path = path.Append(kLeveldbDirectory); |
272 | 273 |
273 leveldb::DB* db_raw; | 274 leveldb::DB* db_raw; |
274 scoped_ptr<leveldb::DB> db; | 275 scoped_ptr<leveldb::DB> db; |
275 leveldb::Options options; | 276 leveldb::Options options; |
276 options.create_if_missing = true; | 277 options.create_if_missing = true; |
| 278 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
277 // TODO(pavely): crbug/424287 Consider adding info_log, block_cache and | 279 // TODO(pavely): crbug/424287 Consider adding info_log, block_cache and |
278 // filter_policy to options. | 280 // filter_policy to options. |
279 leveldb::Status status = | 281 leveldb::Status status = |
280 leveldb::DB::Open(options, leveldb_path.AsUTF8Unsafe(), &db_raw); | 282 leveldb::DB::Open(options, leveldb_path.AsUTF8Unsafe(), &db_raw); |
281 if (!status.ok()) { | 283 if (!status.ok()) { |
282 DVLOG(1) << "DB::Open failed: status=" << status.ToString() | 284 DVLOG(1) << "DB::Open failed: status=" << status.ToString() |
283 << ", path=" << path.AsUTF8Unsafe(); | 285 << ", path=" << path.AsUTF8Unsafe(); |
284 return AttachmentStore::UNSPECIFIED_ERROR; | 286 return AttachmentStore::UNSPECIFIED_ERROR; |
285 } | 287 } |
286 | 288 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 return key; | 421 return key; |
420 } | 422 } |
421 | 423 |
422 AttachmentMetadata OnDiskAttachmentStore::MakeAttachmentMetadata( | 424 AttachmentMetadata OnDiskAttachmentStore::MakeAttachmentMetadata( |
423 const AttachmentId& attachment_id, | 425 const AttachmentId& attachment_id, |
424 const attachment_store_pb::RecordMetadata& record_metadata) { | 426 const attachment_store_pb::RecordMetadata& record_metadata) { |
425 return AttachmentMetadata(attachment_id, record_metadata.attachment_size()); | 427 return AttachmentMetadata(attachment_id, record_metadata.attachment_size()); |
426 } | 428 } |
427 | 429 |
428 } // namespace syncer | 430 } // namespace syncer |
OLD | NEW |