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 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 6 7 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" 8 #include "content/browser/dom_storage/dom_storage_session.h" 9 10 namespace content { 11 12 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl( 13 DOMStorageContextWrapper* context) 14 : session_(new DOMStorageSession(context->context())) { 15 } 16 17 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl( 18 DOMStorageContextWrapper* context, int64 namepace_id_to_clone) 19 : session_(DOMStorageSession::CloneFrom(context->context(), 20 namepace_id_to_clone)) { 21 } 22 23 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl( 24 DOMStorageContextWrapper* context, const std::string& persistent_id) 25 : session_(new DOMStorageSession(context->context(), persistent_id)) { 26 } 27 28 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl( 29 SessionStorageNamespaceImpl* master_session_storage_namespace) 30 : session_(new DOMStorageSession( 31 master_session_storage_namespace->session_)) { 32 } 33 34 35 int64 SessionStorageNamespaceImpl::id() const { 36 return session_->namespace_id(); 37 } 38 39 const std::string& SessionStorageNamespaceImpl::persistent_id() const { 40 return session_->persistent_namespace_id(); 41 } 42 43 void SessionStorageNamespaceImpl::SetShouldPersist(bool should_persist) { 44 session_->SetShouldPersist(should_persist); 45 } 46 47 bool SessionStorageNamespaceImpl::should_persist() const { 48 return session_->should_persist(); 49 } 50 51 SessionStorageNamespaceImpl* SessionStorageNamespaceImpl::Clone() { 52 return new SessionStorageNamespaceImpl(session_->Clone()); 53 } 54 55 bool SessionStorageNamespaceImpl::IsFromContext( 56 DOMStorageContextWrapper* context) { 57 return session_->IsFromContext(context->context()); 58 } 59 60 SessionStorageNamespaceImpl::SessionStorageNamespaceImpl( 61 DOMStorageSession* clone) 62 : session_(clone) { 63 } 64 65 SessionStorageNamespaceImpl::~SessionStorageNamespaceImpl() { 66 } 67 68 void SessionStorageNamespaceImpl::AddTransactionLogProcessId(int process_id) { 69 session_->AddTransactionLogProcessId(process_id); 70 } 71 72 void SessionStorageNamespaceImpl::RemoveTransactionLogProcessId( 73 int process_id) { 74 session_->RemoveTransactionLogProcessId(process_id); 75 } 76 77 void SessionStorageNamespaceImpl::Merge( 78 bool actually_merge, 79 int process_id, 80 SessionStorageNamespace* other, 81 const MergeResultCallback& callback) { 82 SessionStorageNamespaceImpl* other_impl = 83 static_cast<SessionStorageNamespaceImpl*>(other); 84 session_->Merge(actually_merge, process_id, other_impl->session_, callback); 85 } 86 87 bool SessionStorageNamespaceImpl::IsAliasOf(SessionStorageNamespace* other) { 88 return persistent_id() == other->persistent_id(); 89 } 90 91 SessionStorageNamespace* SessionStorageNamespaceImpl::CreateAlias() { 92 return new SessionStorageNamespaceImpl(this); 93 } 94 95 } // namespace content 96