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

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

Issue 10546167: Create and store persistent unique ids for sessionStorage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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_area.h" 5 #include "webkit/dom_storage/dom_storage_area.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 DomStorageArea::DomStorageArea( 55 DomStorageArea::DomStorageArea(
56 int64 namespace_id, const GURL& origin, 56 int64 namespace_id, const GURL& origin,
57 const FilePath& directory, DomStorageTaskRunner* task_runner) 57 const FilePath& directory, DomStorageTaskRunner* task_runner)
58 : namespace_id_(namespace_id), origin_(origin), 58 : namespace_id_(namespace_id), origin_(origin),
59 directory_(directory), 59 directory_(directory),
60 task_runner_(task_runner), 60 task_runner_(task_runner),
61 map_(new DomStorageMap(kPerAreaQuota + kPerAreaOverQuotaAllowance)), 61 map_(new DomStorageMap(kPerAreaQuota + kPerAreaOverQuotaAllowance)),
62 is_initial_import_done_(true), 62 is_initial_import_done_(true),
63 is_shutdown_(false), 63 is_shutdown_(false),
64 commit_batches_in_flight_(0) { 64 commit_batches_in_flight_(0) {
65 if (namespace_id == kLocalStorageNamespaceId && !directory.empty()) { 65 DCHECK_EQ(kLocalStorageNamespaceId, namespace_id);
66 if (!directory.empty()) {
66 FilePath path = directory.Append(DatabaseFileNameFromOrigin(origin_)); 67 FilePath path = directory.Append(DatabaseFileNameFromOrigin(origin_));
67 backing_.reset(new DomStorageDatabase(path)); 68 backing_.reset(new DomStorageDatabase(path));
68 is_initial_import_done_ = false; 69 is_initial_import_done_ = false;
69 } 70 }
70 } 71 }
71 72
73 DomStorageArea::DomStorageArea(
74 int64 namespace_id,
75 const std::string& persistent_namespace_id,
76 const GURL& origin,
77 DomStorageTaskRunner* task_runner)
78 : namespace_id_(namespace_id),
79 persistent_namespace_id_(persistent_namespace_id),
80 origin_(origin),
81 task_runner_(task_runner),
82 map_(new DomStorageMap(kPerAreaQuota)),
michaeln 2012/06/14 22:53:48 per some more recent changes this should be (kPerA
marja 2012/06/15 09:17:42 Done.
83 is_initial_import_done_(true),
84 is_shutdown_(false),
85 commit_batches_in_flight_(0) {
86 DCHECK(namespace_id != kLocalStorageNamespaceId);
87 }
88
72 DomStorageArea::~DomStorageArea() { 89 DomStorageArea::~DomStorageArea() {
73 } 90 }
74 91
75 void DomStorageArea::ExtractValues(ValuesMap* map) { 92 void DomStorageArea::ExtractValues(ValuesMap* map) {
76 if (is_shutdown_) 93 if (is_shutdown_)
77 return; 94 return;
78 InitialImportIfNeeded(); 95 InitialImportIfNeeded();
79 map_->ExtractValues(map); 96 map_->ExtractValues(map);
80 } 97 }
81 98
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 158
142 if (backing_.get()) { 159 if (backing_.get()) {
143 CommitBatch* commit_batch = CreateCommitBatchIfNeeded(); 160 CommitBatch* commit_batch = CreateCommitBatchIfNeeded();
144 commit_batch->clear_all_first = true; 161 commit_batch->clear_all_first = true;
145 commit_batch->changed_values.clear(); 162 commit_batch->changed_values.clear();
146 } 163 }
147 164
148 return true; 165 return true;
149 } 166 }
150 167
151 DomStorageArea* DomStorageArea::ShallowCopy(int64 destination_namespace_id) { 168 DomStorageArea* DomStorageArea::ShallowCopy(
169 int64 destination_namespace_id,
170 const std::string& destination_persistent_namespace_id) {
152 DCHECK_NE(kLocalStorageNamespaceId, namespace_id_); 171 DCHECK_NE(kLocalStorageNamespaceId, namespace_id_);
153 DCHECK_NE(kLocalStorageNamespaceId, destination_namespace_id); 172 DCHECK_NE(kLocalStorageNamespaceId, destination_namespace_id);
154 DCHECK(!backing_.get()); // SessionNamespaces aren't stored on disk. 173 DCHECK(!backing_.get()); // SessionNamespaces aren't stored on disk.
155 174
156 DomStorageArea* copy = new DomStorageArea(destination_namespace_id, origin_, 175 DomStorageArea* copy = new DomStorageArea(
157 FilePath(), task_runner_); 176 destination_namespace_id, destination_persistent_namespace_id, origin_,
177 task_runner_);
158 copy->map_ = map_; 178 copy->map_ = map_;
159 copy->is_shutdown_ = is_shutdown_; 179 copy->is_shutdown_ = is_shutdown_;
160 return copy; 180 return copy;
161 } 181 }
162 182
163 bool DomStorageArea::HasUncommittedChanges() const { 183 bool DomStorageArea::HasUncommittedChanges() const {
164 DCHECK(!is_shutdown_); 184 DCHECK(!is_shutdown_);
165 return commit_batch_.get() || commit_batches_in_flight_; 185 return commit_batch_.get() || commit_batches_in_flight_;
166 } 186 }
167 187
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 bool success = backing_->CommitChanges( 323 bool success = backing_->CommitChanges(
304 commit_batch_->clear_all_first, 324 commit_batch_->clear_all_first,
305 commit_batch_->changed_values); 325 commit_batch_->changed_values);
306 DCHECK(success); 326 DCHECK(success);
307 } 327 }
308 commit_batch_.reset(); 328 commit_batch_.reset();
309 backing_.reset(); 329 backing_.reset();
310 } 330 }
311 331
312 } // namespace dom_storage 332 } // namespace dom_storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698