OLD | NEW |
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_TEST_DOWNLOAD_TEST_OBSERVER_H_ | 5 #ifndef CONTENT_TEST_DOWNLOAD_TEST_OBSERVER_H_ |
6 #define CONTENT_TEST_DOWNLOAD_TEST_OBSERVER_H_ | 6 #define CONTENT_TEST_DOWNLOAD_TEST_OBSERVER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 // Waits for a callback indicating that the DownloadItem is about to be created, | 255 // Waits for a callback indicating that the DownloadItem is about to be created, |
256 // or that an error occurred and it won't be created. | 256 // or that an error occurred and it won't be created. |
257 class DownloadTestItemCreationObserver | 257 class DownloadTestItemCreationObserver |
258 : public base::RefCountedThreadSafe<DownloadTestItemCreationObserver> { | 258 : public base::RefCountedThreadSafe<DownloadTestItemCreationObserver> { |
259 public: | 259 public: |
260 DownloadTestItemCreationObserver(); | 260 DownloadTestItemCreationObserver(); |
261 | 261 |
262 void WaitForDownloadItemCreation(); | 262 void WaitForDownloadItemCreation(); |
263 | 263 |
264 DownloadId download_id() const { return download_id_; } | 264 int download_id() const { return download_id_; } |
265 net::Error error() const { return error_; } | 265 net::Error error() const { return error_; } |
266 bool started() const { return called_back_count_ > 0; } | 266 bool started() const { return called_back_count_ > 0; } |
267 bool succeeded() const { return started() && (error_ == net::OK); } | 267 bool succeeded() const { return started() && (error_ == net::OK); } |
268 | 268 |
269 const DownloadUrlParameters::OnStartedCallback callback(); | 269 const DownloadUrlParameters::OnStartedCallback callback(); |
270 | 270 |
271 private: | 271 private: |
272 friend class base::RefCountedThreadSafe<DownloadTestItemCreationObserver>; | 272 friend class base::RefCountedThreadSafe<DownloadTestItemCreationObserver>; |
273 | 273 |
274 ~DownloadTestItemCreationObserver(); | 274 ~DownloadTestItemCreationObserver(); |
275 | 275 |
276 void DownloadItemCreationCallback(DownloadId download_id, | 276 void DownloadItemCreationCallback(DownloadItem* item, net::Error error); |
277 net::Error error); | |
278 | 277 |
279 // The download creation information we received. | 278 // The download creation information we received. |
280 DownloadId download_id_; | 279 int download_id_; |
281 | |
282 net::Error error_; | 280 net::Error error_; |
283 | 281 |
284 // Count of callbacks. | 282 // Count of callbacks. |
285 size_t called_back_count_; | 283 size_t called_back_count_; |
286 | 284 |
287 // We are in the message loop. | 285 // We are in the message loop. |
288 bool waiting_; | 286 bool waiting_; |
289 | 287 |
290 DISALLOW_COPY_AND_ASSIGN(DownloadTestItemCreationObserver); | 288 DISALLOW_COPY_AND_ASSIGN(DownloadTestItemCreationObserver); |
291 }; | 289 }; |
292 | 290 |
293 } // namespace content` | 291 } // namespace content` |
294 | 292 |
295 #endif // CONTENT_TEST_DOWNLOAD_TEST_OBSERVER_H_ | 293 #endif // CONTENT_TEST_DOWNLOAD_TEST_OBSERVER_H_ |
OLD | NEW |