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 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
7 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
8 #include "content/browser/dom_storage/dom_storage_session.h"
12 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl(
13 DOMStorageContextWrapper
* context
)
14 : session_(new DOMStorageSession(context
->context())) {
17 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl(
18 DOMStorageContextWrapper
* context
, int64 namepace_id_to_clone
)
19 : session_(DOMStorageSession::CloneFrom(context
->context(),
20 namepace_id_to_clone
)) {
23 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl(
24 DOMStorageContextWrapper
* context
, const std::string
& persistent_id
)
25 : session_(new DOMStorageSession(context
->context(), persistent_id
)) {
28 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl(
29 SessionStorageNamespaceImpl
* master_session_storage_namespace
)
30 : session_(new DOMStorageSession(
31 master_session_storage_namespace
->session_
.get())) {
35 int64
SessionStorageNamespaceImpl::id() const {
36 return session_
->namespace_id();
39 const std::string
& SessionStorageNamespaceImpl::persistent_id() const {
40 return session_
->persistent_namespace_id();
43 void SessionStorageNamespaceImpl::SetShouldPersist(bool should_persist
) {
44 session_
->SetShouldPersist(should_persist
);
47 bool SessionStorageNamespaceImpl::should_persist() const {
48 return session_
->should_persist();
51 SessionStorageNamespaceImpl
* SessionStorageNamespaceImpl::Clone() {
52 return new SessionStorageNamespaceImpl(session_
->Clone());
55 bool SessionStorageNamespaceImpl::IsFromContext(
56 DOMStorageContextWrapper
* context
) {
57 return session_
->IsFromContext(context
->context());
60 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl(
61 DOMStorageSession
* clone
)
65 SessionStorageNamespaceImpl::~SessionStorageNamespaceImpl() {
68 void SessionStorageNamespaceImpl::AddTransactionLogProcessId(int process_id
) {
69 session_
->AddTransactionLogProcessId(process_id
);
72 void SessionStorageNamespaceImpl::RemoveTransactionLogProcessId(
74 session_
->RemoveTransactionLogProcessId(process_id
);
77 void SessionStorageNamespaceImpl::Merge(
80 SessionStorageNamespace
* other
,
81 const MergeResultCallback
& callback
) {
82 SessionStorageNamespaceImpl
* other_impl
=
83 static_cast<SessionStorageNamespaceImpl
*>(other
);
85 actually_merge
, process_id
, other_impl
->session_
.get(), callback
);
88 bool SessionStorageNamespaceImpl::IsAliasOf(SessionStorageNamespace
* other
) {
89 return persistent_id() == other
->persistent_id();
92 SessionStorageNamespace
* SessionStorageNamespaceImpl::CreateAlias() {
93 return new SessionStorageNamespaceImpl(this);
96 } // namespace content