Add ICU message format support
[chromium-blink-merge.git] / content / browser / dom_storage / dom_storage_host.h
bloba6289076f876575951d48d3d53a4867ddaa858c4
1 // Copyright 2013 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.
5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_HOST_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_HOST_H_
8 #include <map>
10 #include "base/memory/ref_counted.h"
11 #include "base/strings/nullable_string16.h"
12 #include "base/strings/string16.h"
13 #include "content/common/content_export.h"
14 #include "content/common/dom_storage/dom_storage_types.h"
16 class GURL;
18 namespace content {
20 class DOMStorageContextImpl;
21 class DOMStorageHost;
22 class DOMStorageNamespace;
23 class DOMStorageArea;
25 // One instance is allocated in the main process for each client process.
26 // Used by DOMStorageMessageFilter in Chrome.
27 // This class is single threaded, and performs blocking file reads/writes,
28 // so it shouldn't be used on chrome's IO thread.
29 // See class comments for DOMStorageContextImpl for a larger overview.
30 class CONTENT_EXPORT DOMStorageHost {
31 public:
32 explicit DOMStorageHost(DOMStorageContextImpl* context);
33 ~DOMStorageHost();
35 bool OpenStorageArea(int connection_id, int namespace_id,
36 const GURL& origin);
37 void CloseStorageArea(int connection_id);
38 bool ExtractAreaValues(int connection_id, DOMStorageValuesMap* map);
39 unsigned GetAreaLength(int connection_id);
40 base::NullableString16 GetAreaKey(int connection_id, unsigned index);
41 base::NullableString16 GetAreaItem(int connection_id,
42 const base::string16& key);
43 bool SetAreaItem(int connection_id, const base::string16& key,
44 const base::string16& value, const GURL& page_url,
45 base::NullableString16* old_value);
46 bool RemoveAreaItem(int connection_id, const base::string16& key,
47 const GURL& page_url,
48 base::string16* old_value);
49 bool ClearArea(int connection_id, const GURL& page_url);
50 bool HasAreaOpen(int namespace_id, const GURL& origin) const;
52 private:
53 // Struct to hold references needed for areas that are open
54 // within our associated client process.
55 struct NamespaceAndArea {
56 scoped_refptr<DOMStorageNamespace> namespace_;
57 scoped_refptr<DOMStorageArea> area_;
58 NamespaceAndArea();
59 ~NamespaceAndArea();
61 typedef std::map<int, NamespaceAndArea > AreaMap;
63 DOMStorageArea* GetOpenArea(int connection_id);
64 DOMStorageNamespace* GetNamespace(int connection_id);
66 scoped_refptr<DOMStorageContextImpl> context_;
67 AreaMap connections_;
69 DISALLOW_COPY_AND_ASSIGN(DOMStorageHost);
72 } // namespace content
74 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_HOST_H_