blob: a4aba1e91e1b4f384a0e0eaa9891b8d6e062965c [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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
3// found in the LICENSE file.
4
5#ifndef CONTENT_PUBLIC_BROWSER_DOM_STORAGE_CONTEXT_H_
6#define CONTENT_PUBLIC_BROWSER_DOM_STORAGE_CONTEXT_H_
7
8#include <string>
9#include <vector>
10
11#include "base/callback.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000012
13class GURL;
14
Torne (Richard Coles)58218062012-11-14 11:43:16 +000015namespace content {
16
17class BrowserContext;
Ben Murdochbb1529c2013-08-08 10:24:53 +010018struct LocalStorageUsageInfo;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000019class SessionStorageNamespace;
Ben Murdochbb1529c2013-08-08 10:24:53 +010020struct SessionStorageUsageInfo;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000021
22// Represents the per-BrowserContext Local Storage data.
23class DOMStorageContext {
24 public:
25 typedef base::Callback<
Ben Murdochbb1529c2013-08-08 10:24:53 +010026 void(const std::vector<LocalStorageUsageInfo>&)>
Torne (Richard Coles)58218062012-11-14 11:43:16 +000027 GetLocalStorageUsageCallback;
28
29 typedef base::Callback<
Ben Murdochbb1529c2013-08-08 10:24:53 +010030 void(const std::vector<SessionStorageUsageInfo>&)>
Torne (Richard Coles)58218062012-11-14 11:43:16 +000031 GetSessionStorageUsageCallback;
32
33 // Returns a collection of origins using local storage to the given callback.
34 virtual void GetLocalStorageUsage(
35 const GetLocalStorageUsageCallback& callback) = 0;
36
37 // Returns a collection of origins using session storage to the given
38 // callback.
39 virtual void GetSessionStorageUsage(
40 const GetSessionStorageUsageCallback& callback) = 0;
41
42 // Deletes the local storage data for the given origin.
43 virtual void DeleteLocalStorage(const GURL& origin) = 0;
44
45 // Deletes the session storage data identified by |usage_info|.
46 virtual void DeleteSessionStorage(
Ben Murdochbb1529c2013-08-08 10:24:53 +010047 const SessionStorageUsageInfo& usage_info) = 0;
Torne (Richard Coles)58218062012-11-14 11:43:16 +000048
49 // If this is called, sessionStorage data will be stored on disk, and can be
50 // restored after a browser restart (with RecreateSessionStorage). This
Ben Murdochbb1529c2013-08-08 10:24:53 +010051 // function must be called right after DOMStorageContextWrapper is created,
52 // and before it's used.
Torne (Richard Coles)58218062012-11-14 11:43:16 +000053 virtual void SetSaveSessionStorageOnDisk() = 0;
54
55 // Creates a SessionStorageNamespace with the given |persistent_id|. Used
56 // after tabs are restored by session restore. When created, the
57 // SessionStorageNamespace with the correct |persistent_id| will be
58 // associated with the persisted sessionStorage data.
59 virtual scoped_refptr<SessionStorageNamespace> RecreateSessionStorage(
60 const std::string& persistent_id) = 0;
61
62 // Starts deleting sessionStorages which don't have an associated
63 // SessionStorageNamespace alive. Called when SessionStorageNamespaces have
64 // been created after a session restore, or a session restore won't happen.
65 virtual void StartScavengingUnusedSessionStorage() = 0;
66
67 protected:
68 virtual ~DOMStorageContext() {}
69};
70
71} // namespace content
72
73#endif // CONTENT_PUBLIC_BROWSER_DOM_STORAGE_CONTEXT_H_