| 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" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 if (out) | 163 if (out) |
| 164 *out = str.substr(prefix.size()); | 164 *out = str.substr(prefix.size()); |
| 165 return true; | 165 return true; |
| 166 } | 166 } |
| 167 | 167 |
| 168 scoped_ptr<ServiceMetadata> InitializeServiceMetadata(LevelDBWrapper* db) { | 168 scoped_ptr<ServiceMetadata> InitializeServiceMetadata(LevelDBWrapper* db) { |
| 169 base::ThreadRestrictions::AssertIOAllowed(); | 169 base::ThreadRestrictions::AssertIOAllowed(); |
| 170 DCHECK(db); | 170 DCHECK(db); |
| 171 | 171 |
| 172 scoped_ptr<ServiceMetadata> service_metadata; |
| 173 |
| 172 std::string value; | 174 std::string value; |
| 173 leveldb::Status status = db->Get(kServiceMetadataKey, &value); | 175 leveldb::Status status = db->Get(kServiceMetadataKey, &value); |
| 174 | 176 if (status.ok()) { |
| 175 scoped_ptr<ServiceMetadata> service_metadata(new ServiceMetadata); | 177 service_metadata.reset(new ServiceMetadata); |
| 176 if (!status.ok() || !service_metadata->ParseFromString(value)) | 178 if (!service_metadata->ParseFromString(value)) |
| 179 service_metadata.reset(); |
| 180 } else if (status.IsNotFound()) { |
| 181 service_metadata.reset(new ServiceMetadata); |
| 177 service_metadata->set_next_tracker_id(1); | 182 service_metadata->set_next_tracker_id(1); |
| 183 } |
| 178 | 184 |
| 179 return service_metadata.Pass(); | 185 return service_metadata.Pass(); |
| 180 } | 186 } |
| 181 | 187 |
| 182 } // namespace drive_backend | 188 } // namespace drive_backend |
| 183 } // namespace sync_file_system | 189 } // namespace sync_file_system |
| OLD | NEW |