OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_HOST_H_ |
| 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_HOST_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <map> |
| 10 |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/nullable_string16.h" |
| 13 #include "base/string16.h" |
| 14 |
| 15 class GURL; |
| 16 |
| 17 namespace dom_storage { |
| 18 |
| 19 class DOMStorageContext; |
| 20 class DOMStorageHost; |
| 21 class DOMStorageNamespace; |
| 22 class DOMStorageArea; |
| 23 |
| 24 // One instance is allocated in the main process for each client process. |
| 25 // Used by DOMStorageMessageFilter in Chrome and by SimpleDOMStorage in DRT. |
| 26 // This class is single threaded, and performs blocking file reads/writes, |
| 27 // so it shouldn't be used on chrome's IO thread. |
| 28 class DOMStorageHost { |
| 29 public: |
| 30 DOMStorageHost(DOMStorageContext* context); |
| 31 ~DOMStorageHost(); |
| 32 |
| 33 int OpenStorageArea(int namespace_id, const GURL& origin); |
| 34 void CloseStorageArea(int connection_id); |
| 35 |
| 36 int GetAreaLength(int connection_id); |
| 37 NullableString16 GetKey(int connection_id, int index); |
| 38 NullableString16 GetItem(int connection_id, const string16& key); |
| 39 bool SetItem(int connection_id, const string16& key, |
| 40 const string16& value, const GURL& page_url, |
| 41 NullableString16* old_value); |
| 42 bool RemoveItem(int connection_id, const string16& key, |
| 43 const GURL& page_url, |
| 44 NullableString16* old_value); |
| 45 bool ClearArea(int connection_id, const GURL& page_url); |
| 46 |
| 47 private: |
| 48 typedef std::map<int, scoped_refptr<DOMStorageArea> > AreaMap; |
| 49 |
| 50 DOMStorageArea* GetOpenArea(int connection_id); |
| 51 |
| 52 int last_connection_id_; |
| 53 scoped_refptr<DOMStorageContext> context_; |
| 54 AreaMap connections_; |
| 55 }; |
| 56 |
| 57 } // namespace dom_storage |
| 58 |
| 59 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_HOST_H_ |
OLD | NEW |