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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 255 |
255 AttachmentStore::Result OnDiskAttachmentStore::OpenOrCreate( | 256 AttachmentStore::Result OnDiskAttachmentStore::OpenOrCreate( |
256 const base::FilePath& path) { | 257 const base::FilePath& path) { |
257 DCHECK(!db_); | 258 DCHECK(!db_); |
258 base::FilePath leveldb_path = path.Append(kLeveldbDirectory); | 259 base::FilePath leveldb_path = path.Append(kLeveldbDirectory); |
259 | 260 |
260 leveldb::DB* db_raw; | 261 leveldb::DB* db_raw; |
261 scoped_ptr<leveldb::DB> db; | 262 scoped_ptr<leveldb::DB> db; |
262 leveldb::Options options; | 263 leveldb::Options options; |
263 options.create_if_missing = true; | 264 options.create_if_missing = true; |
| 265 options.reuse_logs = leveldb_env::kDefaultLogReuseOptionValue; |
264 // TODO(pavely): crbug/424287 Consider adding info_log, block_cache and | 266 // TODO(pavely): crbug/424287 Consider adding info_log, block_cache and |
265 // filter_policy to options. | 267 // filter_policy to options. |
266 leveldb::Status status = | 268 leveldb::Status status = |
267 leveldb::DB::Open(options, leveldb_path.AsUTF8Unsafe(), &db_raw); | 269 leveldb::DB::Open(options, leveldb_path.AsUTF8Unsafe(), &db_raw); |
268 if (!status.ok()) { | 270 if (!status.ok()) { |
269 DVLOG(1) << "DB::Open failed: status=" << status.ToString() | 271 DVLOG(1) << "DB::Open failed: status=" << status.ToString() |
270 << ", path=" << path.AsUTF8Unsafe(); | 272 << ", path=" << path.AsUTF8Unsafe(); |
271 return AttachmentStore::UNSPECIFIED_ERROR; | 273 return AttachmentStore::UNSPECIFIED_ERROR; |
272 } | 274 } |
273 | 275 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 return key; | 408 return key; |
407 } | 409 } |
408 | 410 |
409 AttachmentMetadata OnDiskAttachmentStore::MakeAttachmentMetadata( | 411 AttachmentMetadata OnDiskAttachmentStore::MakeAttachmentMetadata( |
410 const AttachmentId& attachment_id, | 412 const AttachmentId& attachment_id, |
411 const attachment_store_pb::RecordMetadata& record_metadata) { | 413 const attachment_store_pb::RecordMetadata& record_metadata) { |
412 return AttachmentMetadata(attachment_id, record_metadata.attachment_size()); | 414 return AttachmentMetadata(attachment_id, record_metadata.attachment_size()); |
413 } | 415 } |
414 | 416 |
415 } // namespace syncer | 417 } // namespace syncer |
OLD | NEW |