2011-05-16 18:56:12 +02:00
|
|
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
2010-11-17 18:28:32 +01:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#ifndef CEF_LIBCEF_DOM_STORAGE_AREA_H_
|
|
|
|
#define CEF_LIBCEF_DOM_STORAGE_AREA_H_
|
2011-05-16 18:56:12 +02:00
|
|
|
#pragma once
|
2010-11-17 18:28:32 +01:00
|
|
|
|
|
|
|
#include "base/hash_tables.h"
|
2011-04-05 18:17:33 +02:00
|
|
|
#include "base/memory/ref_counted.h"
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
2010-11-17 18:28:32 +01:00
|
|
|
#include "base/nullable_string16.h"
|
|
|
|
#include "base/string16.h"
|
|
|
|
#include "googleurl/src/gurl.h"
|
2011-02-15 19:07:24 +01:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h"
|
2010-11-17 18:28:32 +01:00
|
|
|
|
|
|
|
class DOMStorageNamespace;
|
|
|
|
// Only use on the WebKit thread. DOMStorageNamespace manages our registration
|
|
|
|
// with DOMStorageContext.
|
|
|
|
class DOMStorageArea {
|
|
|
|
public:
|
|
|
|
DOMStorageArea(const string16& origin,
|
|
|
|
int64 id,
|
|
|
|
DOMStorageNamespace* owner);
|
|
|
|
~DOMStorageArea();
|
|
|
|
|
|
|
|
unsigned Length();
|
|
|
|
NullableString16 Key(unsigned index);
|
|
|
|
NullableString16 GetItem(const string16& key);
|
|
|
|
NullableString16 SetItem(
|
|
|
|
const string16& key, const string16& value,
|
|
|
|
WebKit::WebStorageArea::Result* result);
|
|
|
|
NullableString16 RemoveItem(const string16& key);
|
|
|
|
bool Clear();
|
|
|
|
void PurgeMemory();
|
|
|
|
|
|
|
|
int64 id() const { return id_; }
|
|
|
|
|
|
|
|
DOMStorageNamespace* owner() const { return owner_; }
|
2011-10-06 15:34:47 +02:00
|
|
|
const string16& origin() const { return origin_; }
|
2010-11-17 18:28:32 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Creates the underlying WebStorageArea on demand.
|
|
|
|
void CreateWebStorageAreaIfNecessary();
|
|
|
|
|
|
|
|
// The origin this storage area represents.
|
|
|
|
string16 origin_;
|
|
|
|
GURL origin_url_;
|
|
|
|
|
|
|
|
// The storage area we wrap.
|
|
|
|
scoped_ptr<WebKit::WebStorageArea> storage_area_;
|
|
|
|
|
|
|
|
// Our storage area id. Unique to our parent context.
|
|
|
|
int64 id_;
|
|
|
|
|
|
|
|
// The DOMStorageNamespace that owns us.
|
|
|
|
DOMStorageNamespace* owner_;
|
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea);
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(COMPILER_GCC)
|
2012-02-17 15:51:20 +01:00
|
|
|
#if defined(OS_ANDROID)
|
|
|
|
// Android stlport uses std namespace
|
|
|
|
namespace std {
|
|
|
|
#else
|
2010-11-17 18:28:32 +01:00
|
|
|
namespace __gnu_cxx {
|
2012-02-17 15:51:20 +01:00
|
|
|
#endif
|
2010-11-17 18:28:32 +01:00
|
|
|
|
|
|
|
template<>
|
|
|
|
struct hash<DOMStorageArea*> {
|
|
|
|
std::size_t operator()(DOMStorageArea* const& p) const {
|
|
|
|
return reinterpret_cast<std::size_t>(p);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace __gnu_cxx
|
|
|
|
#endif
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#endif // CEF_LIBCEF_DOM_STORAGE_AREA_H_
|