| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_STATE_STORE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_STATE_STORE_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_STATE_STORE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_STATE_STORE_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 12 #include "base/prefs/scoped_user_pref_update.h" |
| 11 | 13 |
| 12 class Profile; | 14 class Profile; |
| 13 | 15 |
| 14 namespace safe_browsing { | 16 namespace safe_browsing { |
| 15 | 17 |
| 16 enum class IncidentType : int32_t; | 18 enum class IncidentType : int32_t; |
| 17 | 19 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 32 ~Transaction(); | 34 ~Transaction(); |
| 33 | 35 |
| 34 // Marks the described incident as having been reported. | 36 // Marks the described incident as having been reported. |
| 35 void MarkAsReported(IncidentType type, | 37 void MarkAsReported(IncidentType type, |
| 36 const std::string& key, | 38 const std::string& key, |
| 37 IncidentDigest digest); | 39 IncidentDigest digest); |
| 38 | 40 |
| 39 // Clears all data associated with an incident type. | 41 // Clears all data associated with an incident type. |
| 40 void ClearForType(IncidentType type); | 42 void ClearForType(IncidentType type); |
| 41 | 43 |
| 44 // Clears all data in the store. |
| 45 void ClearAll(); |
| 46 |
| 42 private: | 47 private: |
| 48 friend class StateStore; |
| 49 |
| 43 // Returns a writable view on the incidents_sent preference. The act of | 50 // Returns a writable view on the incidents_sent preference. The act of |
| 44 // obtaining this view will cause a serialize-and-write operation to be | 51 // obtaining this view will cause a serialize-and-write operation to be |
| 45 // scheduled when the transaction terminates. Use the store's | 52 // scheduled when the transaction terminates. Use the store's |
| 46 // |incidents_sent_| member directly to simply query the preference. | 53 // |incidents_sent_| member directly to simply query the preference. |
| 47 base::DictionaryValue* GetPrefDict(); | 54 base::DictionaryValue* GetPrefDict(); |
| 48 | 55 |
| 56 // Replaces the contents of the underlying dictionary value. |
| 57 void ReplacePrefDict(scoped_ptr<base::DictionaryValue> pref_dict); |
| 58 |
| 49 // The store corresponding to this transaction. | 59 // The store corresponding to this transaction. |
| 50 StateStore* store_; | 60 StateStore* store_; |
| 51 | 61 |
| 52 // A ScopedUserPrefUpdate through which changes to the incidents_sent | 62 // A ScopedUserPrefUpdate through which changes to the incidents_sent |
| 53 // preference are made. | 63 // preference are made. |
| 54 scoped_ptr<DictionaryPrefUpdate> pref_update_; | 64 scoped_ptr<DictionaryPrefUpdate> pref_update_; |
| 55 | 65 |
| 56 DISALLOW_COPY_AND_ASSIGN(Transaction); | 66 DISALLOW_COPY_AND_ASSIGN(Transaction); |
| 57 }; | 67 }; |
| 58 | 68 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 78 // True when a Transaction instance is outstanding. | 88 // True when a Transaction instance is outstanding. |
| 79 bool has_transaction_; | 89 bool has_transaction_; |
| 80 #endif | 90 #endif |
| 81 | 91 |
| 82 DISALLOW_COPY_AND_ASSIGN(StateStore); | 92 DISALLOW_COPY_AND_ASSIGN(StateStore); |
| 83 }; | 93 }; |
| 84 | 94 |
| 85 } // namespace safe_browsing | 95 } // namespace safe_browsing |
| 86 | 96 |
| 87 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_STATE_STORE_H_ | 97 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_STATE_STORE_H_ |
| OLD | NEW |