blob: 3ddc29c195bc174e5ddfe7a31a15f28a9988d1f4 [file] [log] [blame]
[email protected]2a10f6812009-07-24 01:22:511// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2// source code is governed by a BSD-style license that can be found in the
3// LICENSE file.
4
5#include "chrome/renderer/renderer_webstoragearea_impl.h"
6
7#include "chrome/common/render_messages.h"
8#include "chrome/renderer/render_thread.h"
[email protected]ee2be5b32009-11-05 09:13:129#include "webkit/api/public/WebURL.h"
[email protected]2a10f6812009-07-24 01:22:5110
[email protected]15bf8712009-08-27 00:55:0211using WebKit::WebString;
[email protected]ee2be5b32009-11-05 09:13:1212using WebKit::WebURL;
[email protected]15bf8712009-08-27 00:55:0213
[email protected]2a10f6812009-07-24 01:22:5114RendererWebStorageAreaImpl::RendererWebStorageAreaImpl(
[email protected]3d392a6f2009-09-11 03:58:4515 int64 namespace_id, const WebString& origin) {
16 RenderThread::current()->Send(
17 new ViewHostMsg_DOMStorageStorageAreaId(namespace_id, origin,
18 &storage_area_id_));
[email protected]2a10f6812009-07-24 01:22:5119}
20
21RendererWebStorageAreaImpl::~RendererWebStorageAreaImpl() {
22}
23
[email protected]2a10f6812009-07-24 01:22:5124unsigned RendererWebStorageAreaImpl::length() {
[email protected]2a10f6812009-07-24 01:22:5125 unsigned length;
26 RenderThread::current()->Send(
27 new ViewHostMsg_DOMStorageLength(storage_area_id_, &length));
28 return length;
29}
30
[email protected]15bf8712009-08-27 00:55:0231WebString RendererWebStorageAreaImpl::key(unsigned index) {
[email protected]15bf8712009-08-27 00:55:0232 NullableString16 key;
[email protected]2a10f6812009-07-24 01:22:5133 RenderThread::current()->Send(
[email protected]15bf8712009-08-27 00:55:0234 new ViewHostMsg_DOMStorageKey(storage_area_id_, index, &key));
35 return key;
[email protected]2a10f6812009-07-24 01:22:5136}
37
[email protected]3d392a6f2009-09-11 03:58:4538WebString RendererWebStorageAreaImpl::getItem(const WebString& key) {
39 NullableString16 value;
[email protected]2a10f6812009-07-24 01:22:5140 RenderThread::current()->Send(
[email protected]3d392a6f2009-09-11 03:58:4541 new ViewHostMsg_DOMStorageGetItem(storage_area_id_, key, &value));
[email protected]2a10f6812009-07-24 01:22:5142 return value;
43}
44
[email protected]ee2be5b32009-11-05 09:13:1245void RendererWebStorageAreaImpl::setItem(
46 const WebString& key, const WebString& value, const WebURL& url,
47 bool& quota_exception) {
[email protected]2a10f6812009-07-24 01:22:5148 RenderThread::current()->Send(
[email protected]ee2be5b32009-11-05 09:13:1249 new ViewHostMsg_DOMStorageSetItem(storage_area_id_, key, value, url,
[email protected]75c91e642009-10-03 06:51:1550 &quota_exception));
[email protected]2a10f6812009-07-24 01:22:5151}
52
[email protected]ee2be5b32009-11-05 09:13:1253void RendererWebStorageAreaImpl::removeItem(const WebString& key,
54 const WebURL& url) {
[email protected]2a10f6812009-07-24 01:22:5155 RenderThread::current()->Send(
[email protected]ee2be5b32009-11-05 09:13:1256 new ViewHostMsg_DOMStorageRemoveItem(storage_area_id_, key, url));
[email protected]2a10f6812009-07-24 01:22:5157}
58
[email protected]ee2be5b32009-11-05 09:13:1259void RendererWebStorageAreaImpl::clear(const WebURL& url) {
[email protected]2a10f6812009-07-24 01:22:5160 RenderThread::current()->Send(
[email protected]ee2be5b32009-11-05 09:13:1261 new ViewHostMsg_DOMStorageClear(storage_area_id_, url));
[email protected]2a10f6812009-07-24 01:22:5162}