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

Unified Diff: webkit/dom_storage/dom_storage_area.cc

Issue 9146025: Framing for a DOMStorage backend that does not depend on in-process-webkit. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: webkit/dom_storage/dom_storage_area.cc
===================================================================
--- webkit/dom_storage/dom_storage_area.cc (revision 0)
+++ webkit/dom_storage/dom_storage_area.cc (working copy)
@@ -1,80 +1,67 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/browser/in_process_webkit/dom_storage_area.h"
+#include "webkit/dom_storage/dom_storage_area.h"
+#include "webkit/dom_storage/dom_storage_map.h"
+#include "webkit/dom_storage/dom_storage_namespace.h"
-#include "base/logging.h"
-#include "content/browser/in_process_webkit/dom_storage_context.h"
-#include "content/browser/in_process_webkit/dom_storage_namespace.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
-#include "webkit/glue/webkit_glue.h"
+namespace dom_storage {
-using WebKit::WebSecurityOrigin;
-using WebKit::WebStorageArea;
-using WebKit::WebString;
-using WebKit::WebURL;
-
-DOMStorageArea::DOMStorageArea(
- const string16& origin,
- int64 id,
- DOMStorageNamespace* owner)
- : origin_(origin),
- origin_url_(origin),
- id_(id),
- owner_(owner) {
- DCHECK(owner_);
+DomStorageArea::DomStorageArea(
+ int64 namespace_id, const GURL& origin,
+ const FilePath& directory, DomStorageTaskRunner* task_runner)
+ : namespace_id_(namespace_id), origin_(origin),
+ directory_(directory), task_runner_(task_runner),
+ map_(new DomStorageMap()) {
}
-DOMStorageArea::~DOMStorageArea() {
+DomStorageArea::~DomStorageArea() {
}
-unsigned DOMStorageArea::Length() {
- CreateWebStorageAreaIfNecessary();
- return storage_area_->length();
+unsigned DomStorageArea::Length() {
+ return map_->Length();
}
-NullableString16 DOMStorageArea::Key(unsigned index) {
- CreateWebStorageAreaIfNecessary();
- return storage_area_->key(index);
+NullableString16 DomStorageArea::Key(unsigned index) {
+ return map_->Key(index);
}
-NullableString16 DOMStorageArea::GetItem(const string16& key) {
- CreateWebStorageAreaIfNecessary();
- return storage_area_->getItem(key);
+NullableString16 DomStorageArea::GetItem(const string16& key) {
+ return map_->GetItem(key);
}
-NullableString16 DOMStorageArea::SetItem(
+bool DomStorageArea::SetItem(
const string16& key, const string16& value,
- WebStorageArea::Result* result) {
- CreateWebStorageAreaIfNecessary();
- WebString old_value;
- storage_area_->setItem(key, value, WebURL(), *result, old_value);
- return old_value;
+ NullableString16* old_value) {
+ if (!map_->HasOneRef())
+ map_ = map_->DeepCopy();
+ return map_->SetItem(key, value, old_value);
}
-NullableString16 DOMStorageArea::RemoveItem(const string16& key) {
- CreateWebStorageAreaIfNecessary();
- WebString old_value;
- storage_area_->removeItem(key, WebURL(), old_value);
- return old_value;
+bool DomStorageArea::RemoveItem(
+ const string16& key,
+ string16* old_value) {
+ if (!map_->HasOneRef())
+ map_ = map_->DeepCopy();
+ return map_->RemoveItem(key, old_value);
}
-bool DOMStorageArea::Clear() {
- CreateWebStorageAreaIfNecessary();
- bool somethingCleared;
- storage_area_->clear(WebURL(), somethingCleared);
- return somethingCleared;
+bool DomStorageArea::Clear() {
+ if (map_->Length() == 0)
+ return false;
+ map_ = new DomStorageMap();
+ return true;
}
-void DOMStorageArea::PurgeMemory() {
- storage_area_.reset();
+DomStorageArea* DomStorageArea::ShallowCopy(int64 destination_namespace_id) {
+ DCHECK_NE(kLocalStorageNamespaceId, namespace_id_);
+ DCHECK_NE(kLocalStorageNamespaceId, destination_namespace_id);
+ // SessionNamespaces aren't backed by files on disk.
+ DomStorageArea* copy = new DomStorageArea(destination_namespace_id, origin_,
+ FilePath(), task_runner_);
+ copy->map_ = map_;
+ return copy;
}
-void DOMStorageArea::CreateWebStorageAreaIfNecessary() {
- if (!storage_area_.get())
- storage_area_.reset(owner_->CreateWebStorageArea(origin_));
-}
+} // namespace dom_storage

Powered by Google App Engine
This is Rietveld 408576698