| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/fileapi/file_system_origin_database.h" | 5 #include "webkit/fileapi/file_system_origin_database.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 if (origin.empty()) | 222 if (origin.empty()) |
| 223 return false; | 223 return false; |
| 224 std::string path_string; | 224 std::string path_string; |
| 225 std::string origin_key = OriginToOriginKey(origin); | 225 std::string origin_key = OriginToOriginKey(origin); |
| 226 leveldb::Status status = | 226 leveldb::Status status = |
| 227 db_->Get(leveldb::ReadOptions(), origin_key, &path_string); | 227 db_->Get(leveldb::ReadOptions(), origin_key, &path_string); |
| 228 if (status.IsNotFound()) { | 228 if (status.IsNotFound()) { |
| 229 int last_path_number; | 229 int last_path_number; |
| 230 if (!GetLastPathNumber(&last_path_number)) | 230 if (!GetLastPathNumber(&last_path_number)) |
| 231 return false; | 231 return false; |
| 232 path_string = StringPrintf("%03u", last_path_number + 1); | 232 path_string = base::StringPrintf("%03u", last_path_number + 1); |
| 233 // store both back as a single transaction | 233 // store both back as a single transaction |
| 234 leveldb::WriteBatch batch; | 234 leveldb::WriteBatch batch; |
| 235 batch.Put(LastPathKey(), path_string); | 235 batch.Put(LastPathKey(), path_string); |
| 236 batch.Put(origin_key, path_string); | 236 batch.Put(origin_key, path_string); |
| 237 status = db_->Write(leveldb::WriteOptions(), &batch); | 237 status = db_->Write(leveldb::WriteOptions(), &batch); |
| 238 if (!status.ok()) { | 238 if (!status.ok()) { |
| 239 HandleError(FROM_HERE, status); | 239 HandleError(FROM_HERE, status); |
| 240 return false; | 240 return false; |
| 241 } | 241 } |
| 242 } | 242 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); | 309 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); |
| 310 if (!status.ok()) { | 310 if (!status.ok()) { |
| 311 HandleError(FROM_HERE, status); | 311 HandleError(FROM_HERE, status); |
| 312 return false; | 312 return false; |
| 313 } | 313 } |
| 314 *number = -1; | 314 *number = -1; |
| 315 return true; | 315 return true; |
| 316 } | 316 } |
| 317 | 317 |
| 318 } // namespace fileapi | 318 } // namespace fileapi |
| OLD | NEW |