OLD | NEW |
1 // Copyright (c) 2011 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 "content/browser/in_process_webkit/session_storage_namespace.h" | 5 #include "webkit/dom_storage/dom_storage_session.h" |
6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "content/browser/in_process_webkit/dom_storage_context.h" | 10 #include "webkit/dom_storage/dom_storage_context.h" |
9 #include "content/browser/in_process_webkit/webkit_context.h" | 11 #include "webkit/dom_storage/dom_storage_task_runner.h" |
10 | 12 |
11 SessionStorageNamespace::SessionStorageNamespace(WebKitContext* webkit_context) | 13 namespace dom_storage { |
12 : webkit_context_(webkit_context), | 14 |
13 id_(webkit_context_->dom_storage_context() | 15 DomStorageSession::DomStorageSession(DomStorageContext* context) |
14 ->AllocateSessionStorageNamespaceId()) { | 16 : context_(context), |
| 17 namespace_id_(context->AllocateSessionId()) { |
| 18 context->task_runner()->PostTask( |
| 19 FROM_HERE, |
| 20 base::Bind(&DomStorageContext::CreateSessionNamespace, |
| 21 context_, namespace_id_)); |
15 } | 22 } |
16 | 23 |
17 SessionStorageNamespace::SessionStorageNamespace(WebKitContext* webkit_context, | 24 DomStorageSession* DomStorageSession::Clone() { |
18 int64 id) | 25 int64 clone_id = context_->AllocateSessionId(); |
19 : webkit_context_(webkit_context), | 26 context_->task_runner()->PostTask( |
20 id_(id) { | 27 FROM_HERE, |
21 DCHECK(webkit_context_); | 28 base::Bind(&DomStorageContext::CloneSessionNamespace, |
| 29 context_, namespace_id_, clone_id)); |
| 30 return new DomStorageSession(context_, clone_id); |
22 } | 31 } |
23 | 32 |
24 SessionStorageNamespace::~SessionStorageNamespace() { | 33 DomStorageSession::DomStorageSession(DomStorageContext* context, |
25 webkit_context_->DeleteSessionStorageNamespace(id_); | 34 int64 namespace_id) |
| 35 : context_(context), |
| 36 namespace_id_(namespace_id) { |
| 37 // This ctor is intended for use by the Clone() method. |
26 } | 38 } |
27 | 39 |
28 SessionStorageNamespace* SessionStorageNamespace::Clone() { | 40 DomStorageSession::~DomStorageSession() { |
29 return new SessionStorageNamespace( | 41 context_->task_runner()->PostTask( |
30 webkit_context_, | 42 FROM_HERE, |
31 webkit_context_->dom_storage_context()->CloneSessionStorage(id_)); | 43 base::Bind(&DomStorageContext::DeleteSessionNamespace, |
| 44 context_, namespace_id_)); |
32 } | 45 } |
| 46 |
| 47 } // namespace dom_storage |
OLD | NEW |