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 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_DATABASE_ADAPTER_H_ 6 #define CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_DATABASE_ADAPTER_H_ 7 8 #include "base/gtest_prod_util.h" 9 #include "base/memory/scoped_ptr.h" 10 #include "content/browser/dom_storage/dom_storage_database_adapter.h" 11 #include "content/common/content_export.h" 12 13 namespace base { 14 class FilePath; 15 } 16 17 namespace content { 18 19 class DOMStorageDatabase; 20 21 class CONTENT_EXPORT LocalStorageDatabaseAdapter : 22 public DOMStorageDatabaseAdapter { 23 public: 24 explicit LocalStorageDatabaseAdapter(const base::FilePath& path); 25 virtual ~LocalStorageDatabaseAdapter(); 26 virtual void ReadAllValues(DOMStorageValuesMap* result) OVERRIDE; 27 virtual bool CommitChanges(bool clear_all_first, 28 const DOMStorageValuesMap& changes) OVERRIDE; 29 virtual void DeleteFiles() OVERRIDE; 30 virtual void Reset() OVERRIDE; 31 32 protected: 33 // Constructor that uses an in-memory sqlite database, for testing. 34 LocalStorageDatabaseAdapter(); 35 36 private: 37 FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, BackingDatabaseOpened); 38 FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, CommitChangesAtShutdown); 39 FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, CommitTasks); 40 FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, DeleteOrigin); 41 FRIEND_TEST_ALL_PREFIXES(DOMStorageAreaTest, PurgeMemory); 42 43 scoped_ptr<DOMStorageDatabase> db_; 44 45 DISALLOW_COPY_AND_ASSIGN(LocalStorageDatabaseAdapter); 46 }; 47 48 } // namespace content 49 50 #endif // CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_DATABASE_ADAPTER_H_ 51