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_TOOLS_TEST_SHELL_SIMPLE_DOM_STORAGE_SYSTEM_H_ |
| 6 #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DOM_STORAGE_SYSTEM_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.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 |
| 15 namespace dom_storage { |
| 16 class DomStorageContext; |
| 17 class DomStorageHost; |
| 18 } |
| 19 namespace WebKit { |
| 20 class WebStorageNamespace; |
| 21 } |
| 22 |
| 23 // Class that composes dom_storage classes together for use |
| 24 // in simple single process environments like test_shell and DRT. |
| 25 class SimpleDomStorageSystem { |
| 26 public: |
| 27 static SimpleDomStorageSystem& instance() { return *g_instance_; } |
| 28 |
| 29 SimpleDomStorageSystem(); |
| 30 ~SimpleDomStorageSystem(); |
| 31 |
| 32 // The Create<<>> calls are bound to WebKit api that the embedder |
| 33 // is responsible for implementing. These factories are called strictly |
| 34 // on the 'main' webkit thread. Ditto the methods on the returned |
| 35 // objects. SimplDomStorageSystem manufactures implementations of the |
| 36 // WebStorageNamespace and WebStorageArea interfaces that ultimately |
| 37 // plumb Get, Set, Remove, and Clear javascript calls to the dom_storage |
| 38 // classes. The caller (webkit/webcore) takes ownership of the returned |
| 39 // instances and will delete them when done. |
| 40 WebKit::WebStorageNamespace* CreateLocalStorageNamespace(); |
| 41 WebKit::WebStorageNamespace* CreateSessionStorageNamespace(); |
| 42 |
| 43 private: |
| 44 // Inner classes that implement the WebKit WebStorageNamespace and |
| 45 // WebStorageArea interfaces in terms of dom_storage classes. |
| 46 class NamespaceImpl; |
| 47 class AreaImpl; |
| 48 |
| 49 base::WeakPtrFactory<SimpleDomStorageSystem> weak_factory_; |
| 50 scoped_refptr<dom_storage::DomStorageContext> context_; |
| 51 scoped_ptr<dom_storage::DomStorageHost> host_; |
| 52 |
| 53 static SimpleDomStorageSystem* g_instance_; |
| 54 }; |
| 55 |
| 56 #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DOM_STORAGE_SYSTEM_H_ |
OLD | NEW |