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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "components/prefs/scoped_user_pref_update.h" | 15 #include "components/prefs/scoped_user_pref_update.h" |
16 | 16 |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace safe_browsing { | 19 namespace safe_browsing { |
20 | 20 |
21 enum class IncidentType : int32_t; | 21 enum class IncidentType : int32_t; |
22 | 22 |
23 // The storage to track which incidents have been reported for a profile. Only | 23 // The storage to track which incidents have been reported for a profile. Only |
24 // usable on the UI thread. | 24 // usable on the UI thread. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 private: | 63 private: |
64 friend class StateStore; | 64 friend class StateStore; |
65 | 65 |
66 // Returns a writable view on the incidents_sent preference. The act of | 66 // Returns a writable view on the incidents_sent preference. The act of |
67 // obtaining this view will cause a serialize-and-write operation to be | 67 // obtaining this view will cause a serialize-and-write operation to be |
68 // scheduled when the transaction terminates. Use the store's | 68 // scheduled when the transaction terminates. Use the store's |
69 // |incidents_sent_| member directly to simply query the preference. | 69 // |incidents_sent_| member directly to simply query the preference. |
70 base::DictionaryValue* GetPrefDict(); | 70 base::DictionaryValue* GetPrefDict(); |
71 | 71 |
72 // Replaces the contents of the underlying dictionary value. | 72 // Replaces the contents of the underlying dictionary value. |
73 void ReplacePrefDict(scoped_ptr<base::DictionaryValue> pref_dict); | 73 void ReplacePrefDict(std::unique_ptr<base::DictionaryValue> pref_dict); |
74 | 74 |
75 // The store corresponding to this transaction. | 75 // The store corresponding to this transaction. |
76 StateStore* store_; | 76 StateStore* store_; |
77 | 77 |
78 // A ScopedUserPrefUpdate through which changes to the incidents_sent | 78 // A ScopedUserPrefUpdate through which changes to the incidents_sent |
79 // preference are made. | 79 // preference are made. |
80 scoped_ptr<DictionaryPrefUpdate> pref_update_; | 80 std::unique_ptr<DictionaryPrefUpdate> pref_update_; |
81 | 81 |
82 DISALLOW_COPY_AND_ASSIGN(Transaction); | 82 DISALLOW_COPY_AND_ASSIGN(Transaction); |
83 }; | 83 }; |
84 | 84 |
85 explicit StateStore(Profile* profile); | 85 explicit StateStore(Profile* profile); |
86 ~StateStore(); | 86 ~StateStore(); |
87 | 87 |
88 // Returns true if the described incident has already been reported. | 88 // Returns true if the described incident has already been reported. |
89 bool HasBeenReported(IncidentType type, | 89 bool HasBeenReported(IncidentType type, |
90 const std::string& key, | 90 const std::string& key, |
(...skipping 13 matching lines...) Expand all Loading... |
104 // True when a Transaction instance is outstanding. | 104 // True when a Transaction instance is outstanding. |
105 bool has_transaction_; | 105 bool has_transaction_; |
106 #endif | 106 #endif |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(StateStore); | 108 DISALLOW_COPY_AND_ASSIGN(StateStore); |
109 }; | 109 }; |
110 | 110 |
111 } // namespace safe_browsing | 111 } // namespace safe_browsing |
112 | 112 |
113 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_STATE_STORE_H_ | 113 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_STATE_STORE_H_ |
OLD | NEW |