| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #ifndef WebStorageArea_h | 31 #ifndef WebStorageArea_h |
| 32 #define WebStorageArea_h | 32 #define WebStorageArea_h |
| 33 | 33 |
| 34 #include "platform/WebCommon.h" | 34 #include "platform/WebCommon.h" |
| 35 #include "platform/WebString.h" | 35 #include "platform/WebString.h" |
| 36 | 36 |
| 37 namespace WebKit { | 37 namespace WebKit { |
| 38 | 38 |
| 39 class WebURL; | 39 class WebURL; |
| 40 | 40 |
| 41 // In WebCore, there's one distinct StorageArea per origin per StorageNamespace.
This |
| 42 // class wraps a StorageArea. All the methods have obvious connections to the s
pec: |
| 43 // http://dev.w3.org/html5/webstorage/ |
| 41 class WebStorageArea { | 44 class WebStorageArea { |
| 42 public: | 45 public: |
| 43 virtual ~WebStorageArea() { } | 46 virtual ~WebStorageArea() { } |
| 44 | 47 |
| 45 enum Result { | 48 enum Result { |
| 46 ResultOK = 0, | 49 ResultOK = 0, |
| 47 ResultBlockedByQuota | 50 ResultBlockedByQuota |
| 48 }; | 51 }; |
| 49 | 52 |
| 50 // The number of key/value pairs in the storage area. | 53 // The number of key/value pairs in the storage area. |
| 51 virtual unsigned length() = 0; | 54 virtual unsigned length() = 0; |
| 52 | 55 |
| 53 // Get a value for a specific key. Valid key indices are 0 through length()
- 1. | 56 // Get a value for a specific key. Valid key indices are 0 through length()
- 1. |
| 54 // Indexes may change on any set/removeItem call. Will return null if the in
dex | 57 // Indexes may change on any set/removeItem call. Will return null if the in
dex |
| 55 // provided is out of range. | 58 // provided is out of range. |
| 56 virtual WebString key(unsigned index) = 0; | 59 virtual WebString key(unsigned index) = 0; |
| 57 | 60 |
| 58 // Get the value that corresponds to a specific key. This returns null if th
ere is | 61 // Get the value that corresponds to a specific key. This returns null if th
ere is |
| 59 // no entry for that key. | 62 // no entry for that key. |
| 60 virtual WebString getItem(const WebString& key) = 0; | 63 virtual WebString getItem(const WebString& key) = 0; |
| 61 | 64 |
| 62 // Set the value that corresponds to a specific key. Result will either be R
esultOK | 65 // Set the value that corresponds to a specific key. Result will either be R
esultOK |
| 63 // or some particular error. The value is NOT set when there's an error. |pa
geUrl| is the | 66 // or some particular error. The value is NOT set when there's an error. ur
l is the |
| 64 // url that should be used if a storage event fires. | 67 // url that should be used if a storage event fires. |
| 65 virtual void setItem(const WebString& key, const WebString& newValue, const
WebURL& pageUrl, Result& result) | 68 virtual void setItem(const WebString& key, const WebString& newValue, const
WebURL&, Result&, WebString& oldValue) = 0; |
| 66 { | |
| 67 WebString unused; | |
| 68 setItem(key, newValue, pageUrl, result, unused); | |
| 69 } | |
| 70 | 69 |
| 70 // Remove the value associated with a particular key. url is the url that s
hould be used |
| 71 // if a storage event fires. |
| 72 virtual void removeItem(const WebString& key, const WebURL& url, WebString&
oldValue) = 0; |
| 71 | 73 |
| 72 // Remove the value associated with a particular key. |pageUrl| is the url t
hat should be used | 74 // Clear all key/value pairs. url is the url that should be used if a stora
ge event fires. |
| 73 // if a storage event fires. | 75 virtual void clear(const WebURL& url, bool& somethingCleared) = 0; |
| 74 virtual void removeItem(const WebString& key, const WebURL& pageUrl) | |
| 75 { | |
| 76 WebString unused; | |
| 77 removeItem(key, pageUrl, unused); | |
| 78 } | |
| 79 | |
| 80 // Clear all key/value pairs. |pageUrl| is the url that should be used if a
storage event fires. | |
| 81 virtual void clear(const WebURL& pageUrl) | |
| 82 { | |
| 83 bool unused; | |
| 84 clear(pageUrl, unused); | |
| 85 } | |
| 86 | |
| 87 // DEPRECATED - being replaced by the async variants above which do not retu
rn oldValues or block until completion. | |
| 88 virtual void setItem(const WebString& key, const WebString& newValue, const
WebURL&, Result&, WebString& oldValue) = 0; | |
| 89 virtual void removeItem(const WebString& key, const WebURL& pageUrl, WebStri
ng& oldValue) = 0; | |
| 90 virtual void clear(const WebURL& pageUrl, bool& somethingCleared) = 0; | |
| 91 }; | 76 }; |
| 92 | 77 |
| 93 } // namespace WebKit | 78 } // namespace WebKit |
| 94 | 79 |
| 95 #endif // WebStorageArea_h | 80 #endif // WebStorageArea_h |
| OLD | NEW |