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

Side by Side Diff: content/public/test/download_test_observer.h

Issue 1784433003: Track CTR of uncommon download warning. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 9 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
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 CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_ 5 #ifndef CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_
6 #define CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_ 6 #define CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void OnDownloadDestroyed(DownloadItem* download) override; 90 void OnDownloadDestroyed(DownloadItem* download) override;
91 91
92 // DownloadManager::Observer 92 // DownloadManager::Observer
93 void OnDownloadCreated(DownloadManager* manager, DownloadItem* item) override; 93 void OnDownloadCreated(DownloadManager* manager, DownloadItem* item) override;
94 void ManagerGoingDown(DownloadManager* manager) override; 94 void ManagerGoingDown(DownloadManager* manager) override;
95 95
96 size_t NumDangerousDownloadsSeen() const; 96 size_t NumDangerousDownloadsSeen() const;
97 97
98 size_t NumDownloadsSeenInState(DownloadItem::DownloadState state) const; 98 size_t NumDownloadsSeenInState(DownloadItem::DownloadState state) const;
99 99
100 DownloadManager* download_manager();
101
102 DangerousDownloadAction dangerous_download_action();
103
104 std::set<uint32_t>& dangerous_downloads_seen();
105
100 protected: 106 protected:
101 // Only to be called by derived classes' constructors. 107 // Only to be called by derived classes' constructors.
102 virtual void Init(); 108 virtual void Init();
103 109
104 // Called to see if a download item is in a final state. 110 // Called to see if a download item is in a final state.
105 virtual bool IsDownloadInFinalState(DownloadItem* download) = 0; 111 virtual bool IsDownloadInFinalState(DownloadItem* download) = 0;
106 112
113 // Called when we know that a download item is in a final state.
114 // Note that this is not the same as it first transitioning in to the
115 // final state; multiple notifications may occur once the item is in
116 // that state. So we keep our own track of transitions into final.
117 void DownloadInFinalState(DownloadItem* download);
118
107 private: 119 private:
108 typedef std::set<DownloadItem*> DownloadSet; 120 typedef std::set<DownloadItem*> DownloadSet;
109 121
110 // Maps states to the number of times they have been encountered 122 // Maps states to the number of times they have been encountered
111 typedef std::map<DownloadItem::DownloadState, size_t> StateMap; 123 typedef std::map<DownloadItem::DownloadState, size_t> StateMap;
112 124
113 // Called when we know that a download item is in a final state.
114 // Note that this is not the same as it first transitioning in to the
115 // final state; multiple notifications may occur once the item is in
116 // that state. So we keep our own track of transitions into final.
117 void DownloadInFinalState(DownloadItem* download);
118
119 void SignalIfFinished(); 125 void SignalIfFinished();
120 126
121 // Fake user click on "Accept". 127 // Fake user click on "Accept".
122 void AcceptDangerousDownload(uint32_t download_id); 128 void AcceptDangerousDownload(uint32_t download_id);
123 129
124 // Fake user click on "Deny". 130 // Fake user click on "Deny".
125 void DenyDangerousDownload(uint32_t download_id); 131 void DenyDangerousDownload(uint32_t download_id);
126 132
127 // The observed download manager. 133 // The observed download manager.
128 DownloadManager* download_manager_; 134 DownloadManager* download_manager_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Create an object that will be considered finished when |wait_count| 181 // Create an object that will be considered finished when |wait_count|
176 // download items have entered a terminal state (DownloadItem::IsDone() is 182 // download items have entered a terminal state (DownloadItem::IsDone() is
177 // true). 183 // true).
178 DownloadTestObserverTerminal( 184 DownloadTestObserverTerminal(
179 DownloadManager* download_manager, 185 DownloadManager* download_manager,
180 size_t wait_count, 186 size_t wait_count,
181 DangerousDownloadAction dangerous_download_action); 187 DangerousDownloadAction dangerous_download_action);
182 188
183 ~DownloadTestObserverTerminal() override; 189 ~DownloadTestObserverTerminal() override;
184 190
185 private: 191 protected:
186 bool IsDownloadInFinalState(DownloadItem* download) override; 192 bool IsDownloadInFinalState(DownloadItem* download) override;
187 193
188 DISALLOW_COPY_AND_ASSIGN(DownloadTestObserverTerminal); 194 DISALLOW_COPY_AND_ASSIGN(DownloadTestObserverTerminal);
189 }; 195 };
190 196
191 // Detects changes to the downloads after construction. 197 // Detects changes to the downloads after construction.
192 // Finishes when a specified number of downloads change to the 198 // Finishes when a specified number of downloads change to the
193 // IN_PROGRESS state, or when the download manager is destroyed. 199 // IN_PROGRESS state, or when the download manager is destroyed.
194 // Dangerous downloads are accepted. 200 // Dangerous downloads are accepted.
195 // Callers may either probe for the finished state, or wait on it. 201 // Callers may either probe for the finished state, or wait on it.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 313
308 // We are in the message loop. 314 // We are in the message loop.
309 bool waiting_; 315 bool waiting_;
310 316
311 DISALLOW_COPY_AND_ASSIGN(DownloadTestItemCreationObserver); 317 DISALLOW_COPY_AND_ASSIGN(DownloadTestItemCreationObserver);
312 }; 318 };
313 319
314 } // namespace content` 320 } // namespace content`
315 321
316 #endif // CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_ 322 #endif // CONTENT_PUBLIC_TEST_DOWNLOAD_TEST_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698