| OLD | NEW |
| 1 // Copyright (c) 2010 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/renderer/renderer_webstoragenamespace_impl.h" | 5 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/renderer_webstoragearea_impl.h" | 8 #include "content/renderer/dom_storage/webstoragearea_impl.h" |
| 9 #include "googleurl/src/gurl.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 9 #include "webkit/dom_storage/dom_storage_types.h" | 11 #include "webkit/dom_storage/dom_storage_types.h" |
| 10 | 12 |
| 11 using WebKit::WebStorageArea; | 13 using WebKit::WebStorageArea; |
| 12 using WebKit::WebStorageNamespace; | 14 using WebKit::WebStorageNamespace; |
| 13 using WebKit::WebString; | 15 using WebKit::WebString; |
| 14 | 16 |
| 15 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl() | 17 WebStorageNamespaceImpl::WebStorageNamespaceImpl() |
| 16 : namespace_id_(dom_storage::kLocalStorageNamespaceId) { | 18 : namespace_id_(dom_storage::kLocalStorageNamespaceId) { |
| 17 } | 19 } |
| 18 | 20 |
| 19 RendererWebStorageNamespaceImpl::RendererWebStorageNamespaceImpl( | 21 WebStorageNamespaceImpl::WebStorageNamespaceImpl( |
| 20 int64 namespace_id) | 22 int64 namespace_id) |
| 21 : namespace_id_(namespace_id) { | 23 : namespace_id_(namespace_id) { |
| 22 DCHECK_NE(dom_storage::kInvalidSessionStorageNamespaceId, namespace_id); | 24 DCHECK_NE(dom_storage::kInvalidSessionStorageNamespaceId, namespace_id); |
| 23 } | 25 } |
| 24 | 26 |
| 25 RendererWebStorageNamespaceImpl::~RendererWebStorageNamespaceImpl() { | 27 WebStorageNamespaceImpl::~WebStorageNamespaceImpl() { |
| 26 } | 28 } |
| 27 | 29 |
| 28 WebStorageArea* RendererWebStorageNamespaceImpl::createStorageArea( | 30 WebStorageArea* WebStorageNamespaceImpl::createStorageArea( |
| 29 const WebString& origin) { | 31 const WebString& origin) { |
| 30 return new RendererWebStorageAreaImpl(namespace_id_, origin); | 32 return new WebStorageAreaImpl(namespace_id_, GURL(origin)); |
| 31 } | 33 } |
| 32 | 34 |
| 33 WebStorageNamespace* RendererWebStorageNamespaceImpl::copy() { | 35 WebStorageNamespace* WebStorageNamespaceImpl::copy() { |
| 34 // By returning NULL, we're telling WebKit to lazily fetch it the next time | 36 // By returning NULL, we're telling WebKit to lazily fetch it the next time |
| 35 // session storage is used. In the WebViewClient::createView, we do the | 37 // session storage is used. In the WebViewClient::createView, we do the |
| 36 // book-keeping necessary to make it a true copy-on-write despite not doing | 38 // book-keeping necessary to make it a true copy-on-write despite not doing |
| 37 // anything here, now. | 39 // anything here, now. |
| 38 return NULL; | 40 return NULL; |
| 39 } | 41 } |
| 40 | 42 |
| 41 bool RendererWebStorageNamespaceImpl::isSameNamespace( | 43 bool WebStorageNamespaceImpl::isSameNamespace( |
| 42 const WebStorageNamespace& other) const { | 44 const WebStorageNamespace& other) const { |
| 43 const RendererWebStorageNamespaceImpl* other_impl = | 45 const WebStorageNamespaceImpl* other_impl = |
| 44 static_cast<const RendererWebStorageNamespaceImpl*>(&other); | 46 static_cast<const WebStorageNamespaceImpl*>(&other); |
| 45 return namespace_id_ == other_impl->namespace_id_; | 47 return namespace_id_ == other_impl->namespace_id_; |
| 46 } | 48 } |
| OLD | NEW |