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/browser/dom_storage/session_storage_database.h" | 5 #include "webkit/browser/dom_storage/session_storage_database.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 } | 289 } |
290 | 290 |
291 leveldb::DB* db; | 291 leveldb::DB* db; |
292 leveldb::Status s = TryToOpen(&db); | 292 leveldb::Status s = TryToOpen(&db); |
293 if (!s.ok()) { | 293 if (!s.ok()) { |
294 LOG(WARNING) << "Failed to open leveldb in " << file_path_.value() | 294 LOG(WARNING) << "Failed to open leveldb in " << file_path_.value() |
295 << ", error: " << s.ToString(); | 295 << ", error: " << s.ToString(); |
296 DCHECK(db == NULL); | 296 DCHECK(db == NULL); |
297 | 297 |
298 // Clear the directory and try again. | 298 // Clear the directory and try again. |
299 base::Delete(file_path_, true); | 299 base::DeleteFile(file_path_, true); |
300 s = TryToOpen(&db); | 300 s = TryToOpen(&db); |
301 if (!s.ok()) { | 301 if (!s.ok()) { |
302 LOG(WARNING) << "Failed to open leveldb in " << file_path_.value() | 302 LOG(WARNING) << "Failed to open leveldb in " << file_path_.value() |
303 << ", error: " << s.ToString(); | 303 << ", error: " << s.ToString(); |
304 UMA_HISTOGRAM_ENUMERATION(session_storage_uma_name, | 304 UMA_HISTOGRAM_ENUMERATION(session_storage_uma_name, |
305 SESSION_STORAGE_UMA_FAIL, | 305 SESSION_STORAGE_UMA_FAIL, |
306 SESSION_STORAGE_UMA_MAX); | 306 SESSION_STORAGE_UMA_MAX); |
307 DCHECK(db == NULL); | 307 DCHECK(db == NULL); |
308 db_error_ = true; | 308 db_error_ = true; |
309 return false; | 309 return false; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 std::string SessionStorageDatabase::MapKey(const std::string& map_id, | 667 std::string SessionStorageDatabase::MapKey(const std::string& map_id, |
668 const std::string& key) { | 668 const std::string& key) { |
669 return base::StringPrintf("map-%s-%s", map_id.c_str(), key.c_str()); | 669 return base::StringPrintf("map-%s-%s", map_id.c_str(), key.c_str()); |
670 } | 670 } |
671 | 671 |
672 const char* SessionStorageDatabase::NextMapIdKey() { | 672 const char* SessionStorageDatabase::NextMapIdKey() { |
673 return "next-map-id"; | 673 return "next-map-id"; |
674 } | 674 } |
675 | 675 |
676 } // namespace dom_storage | 676 } // namespace dom_storage |
OLD | NEW |