| 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_SUPPORT_SIMPLE_DOM_STORAGE_SYSTEM_H_ | |
| 6 #define WEBKIT_SUPPORT_SIMPLE_DOM_STORAGE_SYSTEM_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "webkit/browser/dom_storage/dom_storage_context.h" | |
| 11 | |
| 12 namespace dom_storage { | |
| 13 class DomStorageHost; | |
| 14 } | |
| 15 namespace WebKit { | |
| 16 class WebStorageNamespace; | |
| 17 } | |
| 18 | |
| 19 // Class that composes dom_storage classes together for use | |
| 20 // in simple single process environments like test_shell and DRT. | |
| 21 class SimpleDomStorageSystem | |
| 22 : public dom_storage::DomStorageContext::EventObserver { | |
| 23 public: | |
| 24 static SimpleDomStorageSystem& instance() { return *g_instance_; } | |
| 25 | |
| 26 SimpleDomStorageSystem(); | |
| 27 virtual ~SimpleDomStorageSystem(); | |
| 28 | |
| 29 // The Create<<>> calls are bound to WebKit api that the embedder | |
| 30 // is responsible for implementing. These factories are called strictly | |
| 31 // on the 'main' webkit thread. Ditto the methods on the returned | |
| 32 // objects. SimplDomStorageSystem manufactures implementations of the | |
| 33 // WebStorageNamespace and WebStorageArea interfaces that ultimately | |
| 34 // plumb Get, Set, Remove, and Clear javascript calls to the dom_storage | |
| 35 // classes. The caller (webkit/webcore) takes ownership of the returned | |
| 36 // instances and will delete them when done. | |
| 37 WebKit::WebStorageNamespace* CreateLocalStorageNamespace(); | |
| 38 WebKit::WebStorageNamespace* CreateSessionStorageNamespace(); | |
| 39 | |
| 40 private: | |
| 41 // Inner classes that implement the WebKit WebStorageNamespace and | |
| 42 // WebStorageArea interfaces in terms of dom_storage classes. | |
| 43 class NamespaceImpl; | |
| 44 class AreaImpl; | |
| 45 | |
| 46 // DomStorageContext::EventObserver implementation which | |
| 47 // calls into webkit/webcore to dispatch events. | |
| 48 virtual void OnDomStorageItemSet( | |
| 49 const dom_storage::DomStorageArea* area, | |
| 50 const base::string16& key, | |
| 51 const base::string16& new_value, | |
| 52 const base::NullableString16& old_value, | |
| 53 const GURL& page_url) OVERRIDE; | |
| 54 virtual void OnDomStorageItemRemoved( | |
| 55 const dom_storage::DomStorageArea* area, | |
| 56 const base::string16& key, | |
| 57 const base::string16& old_value, | |
| 58 const GURL& page_url) OVERRIDE; | |
| 59 virtual void OnDomStorageAreaCleared( | |
| 60 const dom_storage::DomStorageArea* area, | |
| 61 const GURL& page_url) OVERRIDE; | |
| 62 | |
| 63 void DispatchDomStorageEvent( | |
| 64 const dom_storage::DomStorageArea* area, | |
| 65 const GURL& page_url, | |
| 66 const base::NullableString16& key, | |
| 67 const base::NullableString16& new_value, | |
| 68 const base::NullableString16& old_value); | |
| 69 | |
| 70 base::WeakPtrFactory<SimpleDomStorageSystem> weak_factory_; | |
| 71 scoped_refptr<dom_storage::DomStorageContext> context_; | |
| 72 scoped_ptr<dom_storage::DomStorageHost> host_; | |
| 73 AreaImpl* area_being_processed_; | |
| 74 int next_connection_id_; | |
| 75 | |
| 76 static SimpleDomStorageSystem* g_instance_; | |
| 77 }; | |
| 78 | |
| 79 #endif // WEBKIT_SUPPORT_SIMPLE_DOM_STORAGE_SYSTEM_H_ | |
| OLD | NEW |