OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 #include "chrome/browser/drive/drive_api_util.h" | 12 #include "chrome/browser/drive/drive_api_util.h" |
13 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h" | 13 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants. h" |
14 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" | 14 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" |
15 #include "chrome/browser/sync_file_system/logger.h" | 15 #include "chrome/browser/sync_file_system/logger.h" |
16 #include "google_apis/drive/drive_api_parser.h" | 16 #include "google_apis/drive/drive_api_parser.h" |
17 #include "google_apis/drive/gdata_wapi_parser.h" | 17 #include "google_apis/drive/gdata_wapi_parser.h" |
18 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 18 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
19 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 19 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
20 | 20 |
21 namespace sync_file_system { | 21 namespace sync_file_system { |
22 namespace drive_backend { | 22 namespace drive_backend { |
23 | 23 |
24 void PutVersionInfoToBatch(int64 version, leveldb::WriteBatch* batch) { | |
25 DCHECK(batch); | |
tzik
2014/07/16 04:35:27
if (!batch)return; for consistency?
peria
2014/07/16 04:40:49
Done.
| |
26 batch->Put(kDatabaseVersionKey, base::Int64ToString(version)); | |
27 } | |
28 | |
24 void PutServiceMetadataToBatch(const ServiceMetadata& service_metadata, | 29 void PutServiceMetadataToBatch(const ServiceMetadata& service_metadata, |
25 leveldb::WriteBatch* batch) { | 30 leveldb::WriteBatch* batch) { |
26 if (!batch) | 31 if (!batch) |
27 return; | 32 return; |
28 | 33 |
29 std::string value; | 34 std::string value; |
30 bool success = service_metadata.SerializeToString(&value); | 35 bool success = service_metadata.SerializeToString(&value); |
31 DCHECK(success); | 36 DCHECK(success); |
32 batch->Put(kServiceMetadataKey, value); | 37 batch->Put(kServiceMetadataKey, value); |
33 } | 38 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 | 182 |
178 scoped_ptr<ServiceMetadata> service_metadata(new ServiceMetadata); | 183 scoped_ptr<ServiceMetadata> service_metadata(new ServiceMetadata); |
179 if (!status.ok() || !service_metadata->ParseFromString(value)) | 184 if (!status.ok() || !service_metadata->ParseFromString(value)) |
180 service_metadata->set_next_tracker_id(1); | 185 service_metadata->set_next_tracker_id(1); |
181 | 186 |
182 return service_metadata.Pass(); | 187 return service_metadata.Pass(); |
183 } | 188 } |
184 | 189 |
185 } // namespace drive_backend | 190 } // namespace drive_backend |
186 } // namespace sync_file_system | 191 } // namespace sync_file_system |
OLD | NEW |