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.
5 #ifndef CONTENT_PUBLIC_BROWSER_SESSION_STORAGE_NAMESPACE_H_
6 #define CONTENT_PUBLIC_BROWSER_SESSION_STORAGE_NAMESPACE_H_
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
16 // This is a ref-counted class that represents a SessionStorageNamespace.
17 // On destruction it ensures that the storage namespace is destroyed.
18 class SessionStorageNamespace
19 : public base::RefCountedThreadSafe<SessionStorageNamespace> {
21 // Returns the ID of the |SessionStorageNamespace|. The ID is unique among all
22 // SessionStorageNamespace objects, but not unique across browser runs.
23 virtual int64 id() const = 0;
25 // Returns the persistent ID for the |SessionStorageNamespace|. The ID is
26 // unique across browser runs.
27 virtual const std::string& persistent_id() const = 0;
29 // For marking that the sessionStorage will be needed or won't be needed by
31 virtual void SetShouldPersist(bool should_persist) = 0;
33 virtual bool should_persist() const = 0;
35 // SessionStorageNamespaces can be merged. These merges happen based on
36 // a transaction log of operations on the session storage namespace since
37 // this function has been called. Transaction logging will be restricted
38 // to the processes indicated.
39 virtual void AddTransactionLogProcessId(int process_id) = 0;
40 // When transaction logging for a process is no longer required, the log
41 // can be removed to save space.
42 virtual void RemoveTransactionLogProcessId(int process_id) = 0;
45 MERGE_RESULT_NAMESPACE_NOT_FOUND,
46 MERGE_RESULT_NOT_LOGGING,
47 MERGE_RESULT_NO_TRANSACTIONS,
48 MERGE_RESULT_TOO_MANY_TRANSACTIONS,
49 MERGE_RESULT_NOT_MERGEABLE,
50 MERGE_RESULT_MERGEABLE,
51 MERGE_RESULT_MAX_VALUE
54 typedef base::Callback<void(MergeResult)> MergeResultCallback;
56 // Determines whether the transaction log for the process specified can
57 // be merged into the other session storage namespace supplied.
58 virtual void CanMerge(int process_id,
59 SessionStorageNamespace* other,
60 const MergeResultCallback& callback) = 0;
63 friend class base::RefCountedThreadSafe<SessionStorageNamespace>;
64 virtual ~SessionStorageNamespace() {}
67 } // namespace content
69 #endif // CONTENT_PUBLIC_BROWSER_SESSION_STORAGE_NAMESPACE_H_