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

Side by Side Diff: chrome/browser/download/hyperbolic_download_item_notifier.cc

Issue 10974009: Rename HyperbolicDownloadItemNotifer -> AllDownloadItemNotifier (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/download/hyperbolic_download_item_notifier.h"
6
7 HyperbolicDownloadItemNotifier::HyperbolicDownloadItemNotifier(
8 content::DownloadManager* manager,
9 HyperbolicDownloadItemNotifier::Observer* observer)
10 : manager_(manager),
11 observer_(observer) {
12 DCHECK(observer_);
13 manager_->AddObserver(this);
14 content::DownloadManager::DownloadVector items;
15 manager_->GetAllDownloads(&items);
16 for (content::DownloadManager::DownloadVector::const_iterator it =
17 items.begin();
18 it != items.end(); ++it) {
19 (*it)->AddObserver(this);
20 observing_.insert(*it);
21 }
22 }
23
24 HyperbolicDownloadItemNotifier::~HyperbolicDownloadItemNotifier() {
25 if (manager_)
26 manager_->RemoveObserver(this);
27 for (std::set<content::DownloadItem*>::const_iterator it =
28 observing_.begin();
29 it != observing_.end(); ++it) {
30 (*it)->RemoveObserver(this);
31 }
32 observing_.clear();
33 }
34
35 void HyperbolicDownloadItemNotifier::ManagerGoingDown(
36 content::DownloadManager* manager) {
37 DCHECK_EQ(manager_, manager);
38 manager_->RemoveObserver(this);
39 manager_ = NULL;
40 }
41
42 void HyperbolicDownloadItemNotifier::OnDownloadCreated(
43 content::DownloadManager* manager,
44 content::DownloadItem* item) {
45 item->AddObserver(this);
46 observing_.insert(item);
47 observer_->OnDownloadCreated(manager, item);
48 }
49
50 void HyperbolicDownloadItemNotifier::OnDownloadUpdated(
51 content::DownloadItem* item) {
52 observer_->OnDownloadUpdated(manager_, item);
53 }
54
55 void HyperbolicDownloadItemNotifier::OnDownloadOpened(
56 content::DownloadItem* item) {
57 observer_->OnDownloadOpened(manager_, item);
58 }
59
60 void HyperbolicDownloadItemNotifier::OnDownloadRemoved(
61 content::DownloadItem* item) {
62 observer_->OnDownloadRemoved(manager_, item);
63 }
64
65 void HyperbolicDownloadItemNotifier::OnDownloadDestroyed(
66 content::DownloadItem* item) {
67 item->RemoveObserver(this);
68 observing_.erase(item);
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698