Chromium Code Reviews| 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_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ | 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ |
| 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ | 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 : public base::RefCountedThreadSafe<DomStorageNamespace> { | 25 : public base::RefCountedThreadSafe<DomStorageNamespace> { |
| 26 public: | 26 public: |
| 27 // Constructor for a LocalStorage namespace with id of 0 | 27 // Constructor for a LocalStorage namespace with id of 0 |
| 28 // and an optional backing directory on disk. | 28 // and an optional backing directory on disk. |
| 29 DomStorageNamespace(const FilePath& directory, // may be empty | 29 DomStorageNamespace(const FilePath& directory, // may be empty |
| 30 DomStorageTaskRunner* task_runner); | 30 DomStorageTaskRunner* task_runner); |
| 31 | 31 |
| 32 // Constructor for a SessionStorage namespace with a non-zero id | 32 // Constructor for a SessionStorage namespace with a non-zero id |
| 33 // and no backing directory on disk. | 33 // and no backing directory on disk. |
| 34 DomStorageNamespace(int64 namespace_id, | 34 DomStorageNamespace(int64 namespace_id, |
| 35 const std::string& persistent_namespace_id, | |
| 35 DomStorageTaskRunner* task_runner); | 36 DomStorageTaskRunner* task_runner); |
| 36 | 37 |
| 37 int64 namespace_id() const { return namespace_id_; } | 38 int64 namespace_id() const { return namespace_id_; } |
| 39 std::string persistent_namespace_id() const { | |
|
michaeln
2012/06/14 22:53:48
could the return value here be const string&
marja
2012/06/15 09:17:42
I think so; it would be invalid if the string was
| |
| 40 return persistent_namespace_id_; | |
| 41 } | |
| 38 | 42 |
| 39 // Returns the storage area for the given origin, | 43 // Returns the storage area for the given origin, |
| 40 // creating instance if needed. Each call to open | 44 // creating instance if needed. Each call to open |
| 41 // must be balanced with a call to CloseStorageArea. | 45 // must be balanced with a call to CloseStorageArea. |
| 42 DomStorageArea* OpenStorageArea(const GURL& origin); | 46 DomStorageArea* OpenStorageArea(const GURL& origin); |
| 43 void CloseStorageArea(DomStorageArea* area); | 47 void CloseStorageArea(DomStorageArea* area); |
| 44 | 48 |
| 45 // Creates a clone of |this| namespace including | 49 // Creates a clone of |this| namespace including |
| 46 // shallow copies of all contained areas. | 50 // shallow copies of all contained areas. |
| 47 // Should only be called for session storage namespaces. | 51 // Should only be called for session storage namespaces. |
| 48 DomStorageNamespace* Clone(int64 clone_namespace_id); | 52 DomStorageNamespace* Clone(int64 clone_namespace_id, |
| 53 const std::string& clone_persistent_namespace_id); | |
| 49 | 54 |
| 50 void DeleteOrigin(const GURL& origin); | 55 void DeleteOrigin(const GURL& origin); |
| 51 void PurgeMemory(); | 56 void PurgeMemory(); |
| 52 void Shutdown(); | 57 void Shutdown(); |
| 53 | 58 |
| 54 private: | 59 private: |
| 55 friend class base::RefCountedThreadSafe<DomStorageNamespace>; | 60 friend class base::RefCountedThreadSafe<DomStorageNamespace>; |
| 56 | 61 |
| 57 // Struct to hold references to our contained areas and | 62 // Struct to hold references to our contained areas and |
| 58 // to keep track of how many tabs have a given area open. | 63 // to keep track of how many tabs have a given area open. |
| 59 struct AreaHolder { | 64 struct AreaHolder { |
| 60 scoped_refptr<DomStorageArea> area_; | 65 scoped_refptr<DomStorageArea> area_; |
| 61 int open_count_; | 66 int open_count_; |
| 62 AreaHolder(); | 67 AreaHolder(); |
| 63 AreaHolder(DomStorageArea* area, int count); | 68 AreaHolder(DomStorageArea* area, int count); |
| 64 ~AreaHolder(); | 69 ~AreaHolder(); |
| 65 }; | 70 }; |
| 66 typedef std::map<GURL, AreaHolder> AreaMap; | 71 typedef std::map<GURL, AreaHolder> AreaMap; |
| 67 | 72 |
| 68 ~DomStorageNamespace(); | 73 ~DomStorageNamespace(); |
| 69 | 74 |
| 70 // Returns a pointer to the area holder in our map or NULL. | 75 // Returns a pointer to the area holder in our map or NULL. |
| 71 AreaHolder* GetAreaHolder(const GURL& origin); | 76 AreaHolder* GetAreaHolder(const GURL& origin); |
| 72 | 77 |
| 73 int64 namespace_id_; | 78 int64 namespace_id_; |
| 79 std::string persistent_namespace_id_; | |
| 74 FilePath directory_; | 80 FilePath directory_; |
| 75 AreaMap areas_; | 81 AreaMap areas_; |
| 76 scoped_refptr<DomStorageTaskRunner> task_runner_; | 82 scoped_refptr<DomStorageTaskRunner> task_runner_; |
| 77 }; | 83 }; |
| 78 | 84 |
| 79 } // namespace dom_storage | 85 } // namespace dom_storage |
| 80 | 86 |
| 81 | 87 |
| 82 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ | 88 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_NAMESPACE_H_ |
| OLD | NEW |