| 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/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (out) | 147 if (out) |
| 148 *out = str; | 148 *out = str; |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 if (out) | 152 if (out) |
| 153 *out = str.substr(prefix.size()); | 153 *out = str.substr(prefix.size()); |
| 154 return true; | 154 return true; |
| 155 } | 155 } |
| 156 | 156 |
| 157 scoped_ptr<ServiceMetadata> InitializeServiceMetadata(LevelDBWrapper* db) { | 157 std::unique_ptr<ServiceMetadata> InitializeServiceMetadata(LevelDBWrapper* db) { |
| 158 base::ThreadRestrictions::AssertIOAllowed(); | 158 base::ThreadRestrictions::AssertIOAllowed(); |
| 159 DCHECK(db); | 159 DCHECK(db); |
| 160 | 160 |
| 161 scoped_ptr<ServiceMetadata> service_metadata; | 161 std::unique_ptr<ServiceMetadata> service_metadata; |
| 162 | 162 |
| 163 std::string value; | 163 std::string value; |
| 164 leveldb::Status status = db->Get(kServiceMetadataKey, &value); | 164 leveldb::Status status = db->Get(kServiceMetadataKey, &value); |
| 165 if (status.ok()) { | 165 if (status.ok()) { |
| 166 service_metadata.reset(new ServiceMetadata); | 166 service_metadata.reset(new ServiceMetadata); |
| 167 if (!service_metadata->ParseFromString(value)) | 167 if (!service_metadata->ParseFromString(value)) |
| 168 service_metadata.reset(); | 168 service_metadata.reset(); |
| 169 } else if (status.IsNotFound()) { | 169 } else if (status.IsNotFound()) { |
| 170 service_metadata.reset(new ServiceMetadata); | 170 service_metadata.reset(new ServiceMetadata); |
| 171 service_metadata->set_next_tracker_id(1); | 171 service_metadata->set_next_tracker_id(1); |
| 172 } | 172 } |
| 173 | 173 |
| 174 return service_metadata; | 174 return service_metadata; |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace drive_backend | 177 } // namespace drive_backend |
| 178 } // namespace sync_file_system | 178 } // namespace sync_file_system |
| OLD | NEW |