Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / dom_storage / local_storage_database_adapter.h
blobfca55d0c4e07973ee8a1ec251b316b2ff41f4bc1
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.
5 #ifndef CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_DATABASE_ADAPTER_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_DATABASE_ADAPTER_H_
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"
13 namespace base {
14 class FilePath;
17 namespace content {
19 class DOMStorageDatabase;
21 class CONTENT_EXPORT LocalStorageDatabaseAdapter :
22 public DOMStorageDatabaseAdapter {
23 public:
24 explicit LocalStorageDatabaseAdapter(const base::FilePath& path);
25 ~LocalStorageDatabaseAdapter() override;
26 void ReadAllValues(DOMStorageValuesMap* result) override;
27 bool CommitChanges(bool clear_all_first,
28 const DOMStorageValuesMap& changes) override;
29 void DeleteFiles() override;
30 void Reset() override;
32 protected:
33 // Constructor that uses an in-memory sqlite database, for testing.
34 LocalStorageDatabaseAdapter();
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);
43 scoped_ptr<DOMStorageDatabase> db_;
45 DISALLOW_COPY_AND_ASSIGN(LocalStorageDatabaseAdapter);
48 } // namespace content
50 #endif // CONTENT_BROWSER_DOM_STORAGE_LOCAL_STORAGE_DATABASE_ADAPTER_H_