Home | History | Annotate | Download | only in browser
      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
      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"
     12 
     13 class GURL;
     14 
     15 namespace content {
     16 
     17 class BrowserContext;
     18 struct LocalStorageUsageInfo;
     19 class SessionStorageNamespace;
     20 struct SessionStorageUsageInfo;
     21 
     22 // Represents the per-BrowserContext Local Storage data.
     23 class DOMStorageContext {
     24  public:
     25   typedef base::Callback<
     26       void(const std::vector<LocalStorageUsageInfo>&)>
     27           GetLocalStorageUsageCallback;
     28 
     29   typedef base::Callback<
     30       void(const std::vector<SessionStorageUsageInfo>&)>
     31           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(
     47       const SessionStorageUsageInfo& usage_info) = 0;
     48 
     49   // If this is called, sessionStorage data will be stored on disk, and can be
     50   // restored after a browser restart (with RecreateSessionStorage). This
     51   // function must be called right after DOMStorageContextWrapper is created,
     52   // and before it's used.
     53   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_
     74