Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: webkit/dom_storage/dom_storage_session.cc

Issue 9963107: Persist sessionStorage on disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 int64 clone_id = context_->AllocateSessionId(); 38 int64 clone_id = context_->AllocateSessionId();
39 std::string persistent_clone_id = context_->AllocatePersistentSessionId();
27 context_->task_runner()->PostTask( 40 context_->task_runner()->PostTask(
28 FROM_HERE, 41 FROM_HERE,
29 base::Bind(&DomStorageContext::CloneSessionNamespace, 42 base::Bind(&DomStorageContext::CloneSessionNamespace,
30 context_, namespace_id_, clone_id)); 43 context_, namespace_id_, clone_id, persistent_clone_id));
31 return new DomStorageSession(context_, clone_id); 44 return new DomStorageSession(context_, clone_id, persistent_clone_id);
32 } 45 }
33 46
34 DomStorageSession::DomStorageSession(DomStorageContext* context, 47 DomStorageSession::DomStorageSession(DomStorageContext* context,
35 int64 namespace_id) 48 int64 namespace_id,
49 const std::string& persistent_namespace_id)
36 : context_(context), 50 : context_(context),
37 namespace_id_(namespace_id) { 51 namespace_id_(namespace_id),
52 persistent_namespace_id_(persistent_namespace_id) {
38 // This ctor is intended for use by the Clone() method. 53 // This ctor is intended for use by the Clone() method.
39 } 54 }
40 55
41 DomStorageSession::~DomStorageSession() { 56 DomStorageSession::~DomStorageSession() {
42 context_->task_runner()->PostTask( 57 context_->task_runner()->PostTask(
43 FROM_HERE, 58 FROM_HERE,
44 base::Bind(&DomStorageContext::DeleteSessionNamespace, 59 base::Bind(&DomStorageContext::DeleteSessionNamespace,
45 context_, namespace_id_)); 60 context_, namespace_id_));
46 } 61 }
47 62
48 } // namespace dom_storage 63 } // namespace dom_storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698