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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_operation_registry.h

Issue 10834027: Control the frequency of fileBrowserPrivate.onFileTransfersUpdated events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move the tap to operation registry. Created 8 years, 4 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_CHROMEOS_GDATA_GDATA_OPERATION_REGISTRY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATION_REGISTRY_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATION_REGISTRY_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATION_REGISTRY_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 bool CancelForFilePath(const FilePath& file_path); 136 bool CancelForFilePath(const FilePath& file_path);
137 137
138 // Obtains the list of currently active operations. 138 // Obtains the list of currently active operations.
139 ProgressStatusList GetProgressStatusList(); 139 ProgressStatusList GetProgressStatusList();
140 140
141 // Sets an observer. The registry do NOT own observers; before destruction 141 // Sets an observer. The registry do NOT own observers; before destruction
142 // they need to be removed from the registry. 142 // they need to be removed from the registry.
143 void AddObserver(Observer* observer); 143 void AddObserver(Observer* observer);
144 void RemoveObserver(Observer* observer); 144 void RemoveObserver(Observer* observer);
145 145
146 // Disables the notification suppression for testing purpose.
147 void DisableNotificationFrequencyControlForTest();
148
146 private: 149 private:
147 // Handlers for notifications from Operations. 150 // Handlers for notifications from Operations.
148 friend class Operation; 151 friend class Operation;
149 // Notifies that an operation has started. This method passes the ownership of 152 // Notifies that an operation has started. This method passes the ownership of
150 // the operation to the registry. A fresh operation ID is returned to *id. 153 // the operation to the registry. A fresh operation ID is returned to *id.
151 void OnOperationStart(Operation* operation, OperationID* id); 154 void OnOperationStart(Operation* operation, OperationID* id);
152 void OnOperationProgress(OperationID operation); 155 void OnOperationProgress(OperationID operation);
153 void OnOperationFinish(OperationID operation); 156 void OnOperationFinish(OperationID operation);
154 void OnOperationSuspend(OperationID operation); 157 void OnOperationSuspend(OperationID operation);
155 void OnOperationResume(Operation* operation, ProgressStatus* new_status); 158 void OnOperationResume(Operation* operation, ProgressStatus* new_status);
156 void OnOperationAuthFailed(); 159 void OnOperationAuthFailed();
157 160
158 bool IsFileTransferOperation(const Operation* operation) const; 161 bool IsFileTransferOperation(const Operation* operation) const;
159 162
163 // Controls the frequency of notifications, not to flood the listeners with
164 // too many events.
165 bool ShouldNotifyStatusNow(const ProgressStatusList& list);
166 // Sends notifications to the observers after checking that the frequency is
167 // not too high by ShouldNotifyStatusNow.
168 void NotifyStatusToObservers();
169
160 typedef IDMap<Operation, IDMapOwnPointer> OperationIDMap; 170 typedef IDMap<Operation, IDMapOwnPointer> OperationIDMap;
161 OperationIDMap in_flight_operations_; 171 OperationIDMap in_flight_operations_;
162 ObserverList<Observer> observer_list_; 172 ObserverList<Observer> observer_list_;
173 base::Time last_notification_;
174 bool do_notification_frequency_control_;
163 175
164 DISALLOW_COPY_AND_ASSIGN(GDataOperationRegistry); 176 DISALLOW_COPY_AND_ASSIGN(GDataOperationRegistry);
165 }; 177 };
166 178
167 } // namespace gdata 179 } // namespace gdata
168 180
169 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATION_REGISTRY_H_ 181 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_OPERATION_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698