| 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_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ | 5 #ifndef WEBKIT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ |
| 6 #define WEBKIT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ | 6 #define WEBKIT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/atomic_sequence_num.h" | 12 #include "base/atomic_sequence_num.h" |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 20 #include "webkit/storage/webkit_storage_export.h" | 20 #include "webkit/storage/webkit_storage_export.h" |
| 21 | 21 |
| 22 class NullableString16; | |
| 23 | |
| 24 namespace base { | 22 namespace base { |
| 25 class FilePath; | 23 class FilePath; |
| 24 class NullableString16; |
| 26 class Time; | 25 class Time; |
| 27 } | 26 } |
| 28 | 27 |
| 29 namespace quota { | 28 namespace quota { |
| 30 class SpecialStoragePolicy; | 29 class SpecialStoragePolicy; |
| 31 } | 30 } |
| 32 | 31 |
| 33 namespace dom_storage { | 32 namespace dom_storage { |
| 34 | 33 |
| 35 class DomStorageArea; | 34 class DomStorageArea; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 63 : public base::RefCountedThreadSafe<DomStorageContext> { | 62 : public base::RefCountedThreadSafe<DomStorageContext> { |
| 64 public: | 63 public: |
| 65 // An interface for observing Local and Session Storage events on the | 64 // An interface for observing Local and Session Storage events on the |
| 66 // background thread. | 65 // background thread. |
| 67 class EventObserver { | 66 class EventObserver { |
| 68 public: | 67 public: |
| 69 virtual void OnDomStorageItemSet( | 68 virtual void OnDomStorageItemSet( |
| 70 const DomStorageArea* area, | 69 const DomStorageArea* area, |
| 71 const base::string16& key, | 70 const base::string16& key, |
| 72 const base::string16& new_value, | 71 const base::string16& new_value, |
| 73 const NullableString16& old_value, // may be null on initial insert | 72 const base::NullableString16& old_value, // may be null on initial inse
rt |
| 74 const GURL& page_url) = 0; | 73 const GURL& page_url) = 0; |
| 75 virtual void OnDomStorageItemRemoved( | 74 virtual void OnDomStorageItemRemoved( |
| 76 const DomStorageArea* area, | 75 const DomStorageArea* area, |
| 77 const base::string16& key, | 76 const base::string16& key, |
| 78 const base::string16& old_value, | 77 const base::string16& old_value, |
| 79 const GURL& page_url) = 0; | 78 const GURL& page_url) = 0; |
| 80 virtual void OnDomStorageAreaCleared( | 79 virtual void OnDomStorageAreaCleared( |
| 81 const DomStorageArea* area, | 80 const DomStorageArea* area, |
| 82 const GURL& page_url) = 0; | 81 const GURL& page_url) = 0; |
| 83 | 82 |
| 84 protected: | 83 protected: |
| 85 virtual ~EventObserver() {} | 84 virtual ~EventObserver() {} |
| 86 }; | 85 }; |
| 87 | 86 |
| 88 DomStorageContext( | 87 DomStorageContext( |
| 89 const base::FilePath& localstorage_directory, // empty for incognito prof
iles | 88 const base::FilePath& localstorage_directory, // empty for incognito prof
iles |
| 90 const base::FilePath& sessionstorage_directory, // empty for incognito pr
ofiles | 89 const base::FilePath& sessionstorage_directory, // empty for incognito pr
ofiles |
| 91 quota::SpecialStoragePolicy* special_storage_policy, | 90 quota::SpecialStoragePolicy* special_storage_policy, |
| 92 DomStorageTaskRunner* task_runner); | 91 DomStorageTaskRunner* task_runner); |
| 93 | 92 |
| 94 // Returns the directory path for localStorage, or an empty directory, if | 93 // Returns the directory path for localStorage, or an empty directory, if |
| 95 // there is no backing on disk. | 94 // there is no backing on disk. |
| 96 const base::FilePath& localstorage_directory() { return localstorage_directory
_; } | 95 const base::FilePath& localstorage_directory() { |
| 96 return localstorage_directory_; |
| 97 } |
| 97 | 98 |
| 98 // Returns the directory path for sessionStorage, or an empty directory, if | 99 // Returns the directory path for sessionStorage, or an empty directory, if |
| 99 // there is no backing on disk. | 100 // there is no backing on disk. |
| 100 const base::FilePath& sessionstorage_directory() { | 101 const base::FilePath& sessionstorage_directory() { |
| 101 return sessionstorage_directory_; | 102 return sessionstorage_directory_; |
| 102 } | 103 } |
| 103 | 104 |
| 104 DomStorageTaskRunner* task_runner() const { return task_runner_.get(); } | 105 DomStorageTaskRunner* task_runner() const { return task_runner_.get(); } |
| 105 DomStorageNamespace* GetStorageNamespace(int64 namespace_id); | 106 DomStorageNamespace* GetStorageNamespace(int64 namespace_id); |
| 106 | 107 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 126 // this method has been called. | 127 // this method has been called. |
| 127 void Shutdown(); | 128 void Shutdown(); |
| 128 | 129 |
| 129 // Methods to add, remove, and notify EventObservers. | 130 // Methods to add, remove, and notify EventObservers. |
| 130 void AddEventObserver(EventObserver* observer); | 131 void AddEventObserver(EventObserver* observer); |
| 131 void RemoveEventObserver(EventObserver* observer); | 132 void RemoveEventObserver(EventObserver* observer); |
| 132 void NotifyItemSet( | 133 void NotifyItemSet( |
| 133 const DomStorageArea* area, | 134 const DomStorageArea* area, |
| 134 const base::string16& key, | 135 const base::string16& key, |
| 135 const base::string16& new_value, | 136 const base::string16& new_value, |
| 136 const NullableString16& old_value, | 137 const base::NullableString16& old_value, |
| 137 const GURL& page_url); | 138 const GURL& page_url); |
| 138 void NotifyItemRemoved( | 139 void NotifyItemRemoved( |
| 139 const DomStorageArea* area, | 140 const DomStorageArea* area, |
| 140 const base::string16& key, | 141 const base::string16& key, |
| 141 const base::string16& old_value, | 142 const base::string16& old_value, |
| 142 const GURL& page_url); | 143 const GURL& page_url); |
| 143 void NotifyAreaCleared( | 144 void NotifyAreaCleared( |
| 144 const DomStorageArea* area, | 145 const DomStorageArea* area, |
| 145 const GURL& page_url); | 146 const GURL& page_url); |
| 146 | 147 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 std::set<std::string> protected_persistent_session_ids_; | 222 std::set<std::string> protected_persistent_session_ids_; |
| 222 | 223 |
| 223 // Mapping between persistent namespace IDs and namespace IDs for | 224 // Mapping between persistent namespace IDs and namespace IDs for |
| 224 // sessionStorage. | 225 // sessionStorage. |
| 225 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; | 226 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; |
| 226 }; | 227 }; |
| 227 | 228 |
| 228 } // namespace dom_storage | 229 } // namespace dom_storage |
| 229 | 230 |
| 230 #endif // WEBKIT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ | 231 #endif // WEBKIT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ |
| OLD | NEW |