Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/dom_storage/dom_storage_session.h" | 5 #include "webkit/dom_storage/dom_storage_session.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/tracked_objects.h" | 10 #include "base/tracked_objects.h" |
| 11 #include "webkit/dom_storage/dom_storage_context.h" | 11 #include "webkit/dom_storage/dom_storage_context.h" |
| 12 #include "webkit/dom_storage/dom_storage_task_runner.h" | 12 #include "webkit/dom_storage/dom_storage_task_runner.h" |
| 13 | 13 |
| 14 namespace dom_storage { | 14 namespace dom_storage { |
| 15 | 15 |
| 16 DomStorageSession::DomStorageSession(DomStorageContext* context) | 16 DomStorageSession::DomStorageSession(DomStorageContext* context) |
| 17 : context_(context), | 17 : context_(context), |
| 18 namespace_id_(context->AllocateSessionId()) { | 18 namespace_id_(context->AllocateSessionId()), |
| 19 persistent_namespace_id_(context->AllocatePersistentSessionId()) { | |
| 19 context->task_runner()->PostTask( | 20 context->task_runner()->PostTask( |
| 20 FROM_HERE, | 21 FROM_HERE, |
| 21 base::Bind(&DomStorageContext::CreateSessionNamespace, | 22 base::Bind(&DomStorageContext::CreateSessionNamespace, |
| 22 context_, namespace_id_)); | 23 context_, namespace_id_, persistent_namespace_id_)); |
| 24 } | |
| 25 | |
| 26 DomStorageSession::DomStorageSession(DomStorageContext* context, | |
| 27 const std::string& persistent_namespace_id) | |
| 28 : context_(context), | |
| 29 namespace_id_(context->AllocateSessionId()), | |
| 30 persistent_namespace_id_(persistent_namespace_id) { | |
| 31 context->task_runner()->PostTask( | |
| 32 FROM_HERE, | |
| 33 base::Bind(&DomStorageContext::CreateSessionNamespace, | |
| 34 context_, namespace_id_, persistent_namespace_id_)); | |
| 23 } | 35 } |
| 24 | 36 |
| 25 DomStorageSession* DomStorageSession::Clone() { | 37 DomStorageSession* DomStorageSession::Clone() { |
| 26 return CloneFrom(context_, namespace_id_); | 38 return CloneFrom(context_, namespace_id_); |
| 27 } | 39 } |
| 28 | 40 |
| 29 // static | 41 // static |
| 30 DomStorageSession* DomStorageSession::CloneFrom(DomStorageContext* context, | 42 DomStorageSession* DomStorageSession::CloneFrom(DomStorageContext* context, |
| 31 int64 namepace_id_to_clone) { | 43 int64 namepace_id_to_clone) { |
| 32 int64 clone_id = context->AllocateSessionId(); | 44 int64 clone_id = context->AllocateSessionId(); |
| 45 std::string persistent_clone_id = context->AllocatePersistentSessionId(); | |
|
marja
2012/06/15 09:17:42
(This could also be const std::string& persistent_
| |
| 33 context->task_runner()->PostTask( | 46 context->task_runner()->PostTask( |
| 34 FROM_HERE, | 47 FROM_HERE, |
| 35 base::Bind(&DomStorageContext::CloneSessionNamespace, | 48 base::Bind(&DomStorageContext::CloneSessionNamespace, |
| 36 context, namepace_id_to_clone, clone_id)); | 49 context, namepace_id_to_clone, clone_id, persistent_clone_id)); |
| 37 return new DomStorageSession(context, clone_id); | 50 return new DomStorageSession(context, clone_id, persistent_clone_id); |
| 38 } | 51 } |
| 39 | 52 |
| 40 DomStorageSession::DomStorageSession(DomStorageContext* context, | 53 DomStorageSession::DomStorageSession(DomStorageContext* context, |
| 41 int64 namespace_id) | 54 int64 namespace_id, |
| 55 const std::string& persistent_namespace_id) | |
| 42 : context_(context), | 56 : context_(context), |
| 43 namespace_id_(namespace_id) { | 57 namespace_id_(namespace_id), |
| 58 persistent_namespace_id_(persistent_namespace_id) { | |
| 44 // This ctor is intended for use by the Clone() method. | 59 // This ctor is intended for use by the Clone() method. |
| 45 } | 60 } |
| 46 | 61 |
| 47 DomStorageSession::~DomStorageSession() { | 62 DomStorageSession::~DomStorageSession() { |
| 48 context_->task_runner()->PostTask( | 63 context_->task_runner()->PostTask( |
| 49 FROM_HERE, | 64 FROM_HERE, |
| 50 base::Bind(&DomStorageContext::DeleteSessionNamespace, | 65 base::Bind(&DomStorageContext::DeleteSessionNamespace, |
| 51 context_, namespace_id_)); | 66 context_, namespace_id_)); |
| 52 } | 67 } |
| 53 | 68 |
| 54 } // namespace dom_storage | 69 } // namespace dom_storage |
| OLD | NEW |