Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: chrome/browser/protector/protector_service.h

Issue 9968007: [protector] Support for collapsing multiple changes into a single one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tried to compile after merge. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ 5 #ifndef CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
6 #define CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ 6 #define CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 // Returns the most recent change instance or NULL if there are no changes. 65 // Returns the most recent change instance or NULL if there are no changes.
66 BaseSettingChange* GetLastChange(); 66 BaseSettingChange* GetLastChange();
67 67
68 // Returns the Profile instance for this service. 68 // Returns the Profile instance for this service.
69 Profile* profile() { return profile_; } 69 Profile* profile() { return profile_; }
70 70
71 private: 71 private:
72 friend class ProtectorServiceTest; 72 friend class ProtectorServiceTest;
73 73
74 // Pair of error and corresponding change instance. linked_ptr is used because 74 // Pair of error and corresponding change instance. linked_ptr is used because
whywhat 2012/04/06 16:28:32 It's not a pair anymore. BTW, maybe Items should b
Ivan Korotkov 2012/04/09 14:46:47 Fixed comment. It's easier actually to work with v
75 // Item instances are stored in a std::vector and must be copyable. 75 // Item instances are stored in a std::vector and must be copyable.
76 struct Item { 76 struct Item {
77 Item(); 77 Item();
78 ~Item(); 78 ~Item();
79 linked_ptr<BaseSettingChange> change; 79 linked_ptr<BaseSettingChange> change;
80 linked_ptr<SettingsChangeGlobalError> error; 80 linked_ptr<SettingsChangeGlobalError> error;
81 // When true, this means |change| was merged with another instance and
82 // |error| is in process of being removed from GlobalErrorService.
83 bool is_merging;
whywhat 2012/04/06 16:28:32 Why merging, not merged as in comment?
Ivan Korotkov 2012/04/09 14:46:47 Fixed
84 // Meaningful only when |merged| is true. In that case, true means that the
85 // new merged GlobalError instance will be immediately shown.
86 bool show_when_merged;
whywhat 2012/04/06 16:28:32 This makes three states represented with two boole
Ivan Korotkov 2012/04/09 14:46:47 Hm, it doesn't look like a tri-state flag to merge
whywhat 2012/04/10 09:55:44 Both booleans above define three states out of pos
Ivan Korotkov 2012/04/10 11:19:49 I meant that, enum would be good if those were 3 d
81 }; 87 };
82 88
89 typedef std::vector<Item> Items;
90
83 // Matches Item by |change| field. 91 // Matches Item by |change| field.
84 class MatchItemByChange { 92 class MatchItemByChange {
85 public: 93 public:
86 explicit MatchItemByChange(const BaseSettingChange* other); 94 explicit MatchItemByChange(const BaseSettingChange* other);
87 95
88 bool operator()(const Item& item); 96 bool operator()(const Item& item);
89 97
90 private: 98 private:
91 const BaseSettingChange* other_; 99 const BaseSettingChange* other_;
92 }; 100 };
93 101
94 // Matches Item by |error| field. 102 // Matches Item by |error| field.
95 class MatchItemByError { 103 class MatchItemByError {
96 public: 104 public:
97 explicit MatchItemByError(const SettingsChangeGlobalError* other); 105 explicit MatchItemByError(const SettingsChangeGlobalError* other);
98 106
99 bool operator()(const Item& item); 107 bool operator()(const Item& item);
100 108
101 private: 109 private:
102 const SettingsChangeGlobalError* other_; 110 const SettingsChangeGlobalError* other_;
103 }; 111 };
104 112
113 // Returns an Item instance whose change can be merged with |change|, if any.
whywhat 2012/04/06 16:28:32 What if there're multiple items that can be merged
Ivan Korotkov 2012/04/09 14:46:47 Merging strategy is (and should be) transitive so
114 // Otherwise returns |NULL|.
115 Item* FindItemToMergeWith(const BaseSettingChange* change);
116
105 // ProfileKeyedService implementation. 117 // ProfileKeyedService implementation.
106 virtual void Shutdown() OVERRIDE; 118 virtual void Shutdown() OVERRIDE;
107 119
108 // SettingsChangeGlobalErrorDelegate implementation. 120 // SettingsChangeGlobalErrorDelegate implementation.
109 virtual void OnApplyChange(SettingsChangeGlobalError* error, 121 virtual void OnApplyChange(SettingsChangeGlobalError* error,
110 Browser* browser) OVERRIDE; 122 Browser* browser) OVERRIDE;
111 virtual void OnDiscardChange(SettingsChangeGlobalError* error, 123 virtual void OnDiscardChange(SettingsChangeGlobalError* error,
112 Browser* browser) OVERRIDE; 124 Browser* browser) OVERRIDE;
113 virtual void OnDecisionTimeout(SettingsChangeGlobalError* error) OVERRIDE; 125 virtual void OnDecisionTimeout(SettingsChangeGlobalError* error) OVERRIDE;
114 virtual void OnRemovedFromProfile(SettingsChangeGlobalError* error) OVERRIDE; 126 virtual void OnRemovedFromProfile(SettingsChangeGlobalError* error) OVERRIDE;
115 127
116 // Pointers to error bubble controllers and corresponding changes in the order 128 // Pointers to error bubble controllers and corresponding changes in the order
117 // added. 129 // added.
118 std::vector<Item> items_; 130 Items items_;
119 131
120 // Profile which settings we are protecting. 132 // Profile which settings we are protecting.
121 Profile* profile_; 133 Profile* profile_;
122 134
123 // True if there is a change that has been shown and not yet accepted or 135 // True if there is a change that has been shown and not yet accepted or
124 // discarded by user. 136 // discarded by user.
125 bool has_active_change_; 137 bool has_active_change_;
126 138
127 // Observes changes to protected prefs and updates the backup. 139 // Observes changes to protected prefs and updates the backup.
128 scoped_ptr<ProtectedPrefsWatcher> prefs_watcher_; 140 scoped_ptr<ProtectedPrefsWatcher> prefs_watcher_;
129 141
130 DISALLOW_COPY_AND_ASSIGN(ProtectorService); 142 DISALLOW_COPY_AND_ASSIGN(ProtectorService);
131 }; 143 };
132 144
133 } // namespace protector 145 } // namespace protector
134 146
135 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_ 147 #endif // CHROME_BROWSER_PROTECTOR_PROTECTOR_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698