blob: d5f1dc5bc8e3c36f6ecc42ce04429aeedd2d8004 [file] [log] [blame]
Torne (Richard Coles)58218062012-11-14 11:43:16 +00001// 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
3// found in the LICENSE file.
4
5#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
6
7#include "base/logging.h"
Ben Murdochbb1529c2013-08-08 10:24:53 +01008#include "content/common/dom_storage/dom_storage_types.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +00009#include "content/renderer/dom_storage/webstoragearea_impl.h"
Torne (Richard Coles)868fa2f2013-06-11 10:57:03 +010010#include "third_party/WebKit/public/platform/WebString.h"
Ben Murdoch7dbb3d52013-07-17 14:55:54 +010011#include "url/gurl.h"
Torne (Richard Coles)58218062012-11-14 11:43:16 +000012
13using WebKit::WebStorageArea;
14using WebKit::WebStorageNamespace;
15using WebKit::WebString;
16
17namespace content {
18
19WebStorageNamespaceImpl::WebStorageNamespaceImpl()
Ben Murdochbb1529c2013-08-08 10:24:53 +010020 : namespace_id_(kLocalStorageNamespaceId) {
Torne (Richard Coles)58218062012-11-14 11:43:16 +000021}
22
23WebStorageNamespaceImpl::WebStorageNamespaceImpl(
24 int64 namespace_id)
25 : namespace_id_(namespace_id) {
Ben Murdochbb1529c2013-08-08 10:24:53 +010026 DCHECK_NE(kInvalidSessionStorageNamespaceId, namespace_id);
Torne (Richard Coles)58218062012-11-14 11:43:16 +000027}
28
29WebStorageNamespaceImpl::~WebStorageNamespaceImpl() {
30}
31
32WebStorageArea* WebStorageNamespaceImpl::createStorageArea(
33 const WebString& origin) {
34 return new WebStorageAreaImpl(namespace_id_, GURL(origin));
35}
36
37WebStorageNamespace* WebStorageNamespaceImpl::copy() {
38 // By returning NULL, we're telling WebKit to lazily fetch it the next time
39 // session storage is used. In the WebViewClient::createView, we do the
40 // book-keeping necessary to make it a true copy-on-write despite not doing
41 // anything here, now.
42 return NULL;
43}
44
45bool WebStorageNamespaceImpl::isSameNamespace(
46 const WebStorageNamespace& other) const {
47 const WebStorageNamespaceImpl* other_impl =
48 static_cast<const WebStorageNamespaceImpl*>(&other);
49 return namespace_id_ == other_impl->namespace_id_;
50}
51
52} // namespace content