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