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 CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // onCreated and onErased events. | 349 // onCreated and onErased events. |
350 class ExtensionDownloadsEventRouter : public content::DownloadManager::Observer, | 350 class ExtensionDownloadsEventRouter : public content::DownloadManager::Observer, |
351 public content::DownloadItem::Observer { | 351 public content::DownloadItem::Observer { |
352 public: | 352 public: |
353 explicit ExtensionDownloadsEventRouter(Profile* profile); | 353 explicit ExtensionDownloadsEventRouter(Profile* profile); |
354 virtual ~ExtensionDownloadsEventRouter(); | 354 virtual ~ExtensionDownloadsEventRouter(); |
355 | 355 |
356 virtual void ModelChanged(content::DownloadManager* manager) OVERRIDE; | 356 virtual void ModelChanged(content::DownloadManager* manager) OVERRIDE; |
357 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE; | 357 virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE; |
358 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; | 358 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; |
359 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; | 359 virtual void OnDownloadRemoved(content::DownloadItem* download) OVERRIDE; |
| 360 virtual void OnDownloadDestructed(content::DownloadItem* download) OVERRIDE; |
360 | 361 |
361 private: | 362 private: |
362 struct OnChangedStat { | 363 struct OnChangedStat { |
363 OnChangedStat(); | 364 OnChangedStat(); |
364 ~OnChangedStat(); | 365 ~OnChangedStat(); |
365 int fires; | 366 int fires; |
366 int total; | 367 int total; |
367 }; | 368 }; |
368 | 369 |
369 typedef std::map<int, content::DownloadItem*> ItemMap; | 370 typedef std::map<int, content::DownloadItem*> ItemMap; |
370 typedef std::map<int, base::DictionaryValue*> ItemJsonMap; | 371 typedef std::map<int, base::DictionaryValue*> ItemJsonMap; |
371 typedef std::map<int, OnChangedStat*> OnChangedStatMap; | 372 typedef std::map<int, OnChangedStat*> OnChangedStatMap; |
372 | 373 |
373 void Init(content::DownloadManager* manager); | 374 void Init(content::DownloadManager* manager); |
374 void DispatchEvent(const char* event_name, base::Value* json_arg); | 375 void DispatchEvent(const char* event_name, base::Value* json_arg); |
375 | 376 |
376 Profile* profile_; | 377 Profile* profile_; |
377 content::DownloadManager* manager_; | 378 content::DownloadManager* manager_; |
378 ItemMap downloads_; | 379 ItemMap downloads_; |
379 ItemJsonMap item_jsons_; | 380 ItemJsonMap item_jsons_; |
380 OnChangedStatMap on_changed_stats_; | 381 OnChangedStatMap on_changed_stats_; |
381 | 382 |
382 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); | 383 DISALLOW_COPY_AND_ASSIGN(ExtensionDownloadsEventRouter); |
383 }; | 384 }; |
384 | 385 |
385 #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ | 386 #endif // CHROME_BROWSER_EXTENSIONS_API_DOWNLOADS_DOWNLOADS_API_H_ |
OLD | NEW |