Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: content/browser/dom_storage/session_storage_database.cc

Issue 968103002: Do not try to open DB in SessionStorageDatabase::DeleteNamespace() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/dom_storage/session_storage_database.h" 5 #include "content/browser/dom_storage/session_storage_database.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 DBOperation operation(this); 230 DBOperation operation(this);
231 leveldb::WriteBatch batch; 231 leveldb::WriteBatch batch;
232 if (!DeleteAreaHelper(namespace_id, origin.spec(), &batch)) 232 if (!DeleteAreaHelper(namespace_id, origin.spec(), &batch))
233 return false; 233 return false;
234 leveldb::Status s = db_->Write(leveldb::WriteOptions(), &batch); 234 leveldb::Status s = db_->Write(leveldb::WriteOptions(), &batch);
235 return DatabaseErrorCheck(s.ok()); 235 return DatabaseErrorCheck(s.ok());
236 } 236 }
237 237
238 bool SessionStorageDatabase::DeleteNamespace(const std::string& namespace_id) { 238 bool SessionStorageDatabase::DeleteNamespace(const std::string& namespace_id) {
239 if (!LazyOpen(false)) { 239 {
240 // No need to create the database if it doesn't exist. 240 // The caller should have called other methods to open the DB before this
241 return true; 241 // function. Otherwise, DB stores nothing interesting related to the
242 // specified namespace.
243 // Do nothing if the DB is not open (or we know it has failed already),
244 base::AutoLock auto_lock(db_lock_);
245 if (!IsOpen() || db_error_ || is_inconsistent_)
246 return false;
242 } 247 }
243 DBOperation operation(this); 248 DBOperation operation(this);
244 // Itereate through the areas in the namespace. 249 // Itereate through the areas in the namespace.
245 leveldb::WriteBatch batch; 250 leveldb::WriteBatch batch;
246 std::map<std::string, std::string> areas; 251 std::map<std::string, std::string> areas;
247 if (!GetAreasInNamespace(namespace_id, &areas)) 252 if (!GetAreasInNamespace(namespace_id, &areas))
248 return false; 253 return false;
249 for (std::map<std::string, std::string>::const_iterator it = areas.begin(); 254 for (std::map<std::string, std::string>::const_iterator it = areas.begin();
250 it != areas.end(); ++it) { 255 it != areas.end(); ++it) {
251 const std::string& origin = it->first; 256 const std::string& origin = it->first;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 std::string SessionStorageDatabase::MapKey(const std::string& map_id, 725 std::string SessionStorageDatabase::MapKey(const std::string& map_id,
721 const std::string& key) { 726 const std::string& key) {
722 return base::StringPrintf("map-%s-%s", map_id.c_str(), key.c_str()); 727 return base::StringPrintf("map-%s-%s", map_id.c_str(), key.c_str());
723 } 728 }
724 729
725 const char* SessionStorageDatabase::NextMapIdKey() { 730 const char* SessionStorageDatabase::NextMapIdKey() {
726 return "next-map-id"; 731 return "next-map-id";
727 } 732 }
728 733
729 } // namespace content 734 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698