2010-11-17 18:28:32 +01:00
|
|
|
// Copyright (c) 2010 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.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#ifndef CEF_LIBCEF_DOM_STORAGE_NAMESPACE_H_
|
|
|
|
#define CEF_LIBCEF_DOM_STORAGE_NAMESPACE_H_
|
|
|
|
#pragma once
|
2010-11-17 18:28:32 +01:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/dom_storage_common.h"
|
|
|
|
|
|
|
|
#include <vector>
|
2010-11-17 18:28:32 +01:00
|
|
|
|
|
|
|
#include "base/hash_tables.h"
|
2011-09-23 02:16:03 +02:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
2010-11-17 18:28:32 +01:00
|
|
|
#include "base/string16.h"
|
2011-12-16 15:51:10 +01:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
|
2010-11-17 18:28:32 +01:00
|
|
|
|
|
|
|
class DOMStorageArea;
|
|
|
|
class DOMStorageContext;
|
|
|
|
class FilePath;
|
|
|
|
|
|
|
|
namespace WebKit {
|
|
|
|
class WebStorageArea;
|
|
|
|
class WebStorageNamespace;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only to be used on the WebKit thread.
|
|
|
|
class DOMStorageNamespace {
|
|
|
|
public:
|
|
|
|
static DOMStorageNamespace* CreateLocalStorageNamespace(
|
|
|
|
DOMStorageContext* dom_storage_context, const FilePath& data_dir_path);
|
|
|
|
static DOMStorageNamespace* CreateSessionStorageNamespace(
|
|
|
|
DOMStorageContext* dom_storage_context, int64 namespace_id);
|
|
|
|
|
|
|
|
~DOMStorageNamespace();
|
|
|
|
|
2011-10-06 15:34:47 +02:00
|
|
|
DOMStorageArea* GetStorageArea(const string16& origin,
|
|
|
|
bool allocation_allowed);
|
2010-11-17 18:28:32 +01:00
|
|
|
DOMStorageNamespace* Copy(int64 clone_namespace_id);
|
|
|
|
|
2011-10-06 15:34:47 +02:00
|
|
|
void GetStorageAreas(std::vector<DOMStorageArea*>& areas,
|
|
|
|
bool skip_empty) const;
|
|
|
|
|
2010-11-17 18:28:32 +01:00
|
|
|
void PurgeMemory();
|
|
|
|
|
|
|
|
const DOMStorageContext* dom_storage_context() const {
|
|
|
|
return dom_storage_context_;
|
|
|
|
}
|
|
|
|
int64 id() const { return id_; }
|
|
|
|
const WebKit::WebString& data_dir_path() const { return data_dir_path_; }
|
|
|
|
DOMStorageType dom_storage_type() const { return dom_storage_type_; }
|
|
|
|
|
|
|
|
// Creates a WebStorageArea for the given origin. This should only be called
|
|
|
|
// by an owned DOMStorageArea.
|
|
|
|
WebKit::WebStorageArea* CreateWebStorageArea(const string16& origin);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Called by the static factory methods above.
|
|
|
|
DOMStorageNamespace(DOMStorageContext* dom_storage_context,
|
|
|
|
int64 id,
|
|
|
|
const WebKit::WebString& data_dir_path,
|
|
|
|
DOMStorageType storage_type);
|
|
|
|
|
|
|
|
// Creates the underlying WebStorageNamespace on demand.
|
|
|
|
void CreateWebStorageNamespaceIfNecessary();
|
|
|
|
|
|
|
|
// All the storage areas we own.
|
2012-01-10 00:46:23 +01:00
|
|
|
typedef base::hash_map<string16, // NOLINT(build/include_what_you_use)
|
|
|
|
DOMStorageArea*> OriginToStorageAreaMap;
|
2010-11-17 18:28:32 +01:00
|
|
|
OriginToStorageAreaMap origin_to_storage_area_;
|
|
|
|
|
|
|
|
// The DOMStorageContext that owns us.
|
|
|
|
DOMStorageContext* dom_storage_context_;
|
|
|
|
|
|
|
|
// The WebKit storage namespace we manage.
|
|
|
|
scoped_ptr<WebKit::WebStorageNamespace> storage_namespace_;
|
|
|
|
|
|
|
|
// Our id. Unique to our parent context class.
|
|
|
|
int64 id_;
|
|
|
|
|
|
|
|
// The path used to create us, so we can recreate our WebStorageNamespace on
|
|
|
|
// demand.
|
|
|
|
WebKit::WebString data_dir_path_;
|
|
|
|
|
|
|
|
// SessionStorage vs. LocalStorage.
|
|
|
|
const DOMStorageType dom_storage_type_;
|
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageNamespace);
|
|
|
|
};
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#endif // CEF_LIBCEF_DOM_STORAGE_NAMESPACE_H_
|