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

Side by Side Diff: chrome/browser/extensions/install_tracker.cc

Issue 2422963002: Remove FOR_EACH_OBSERVER macro usage in chrome/browser/extensions (Closed)
Patch Set: extensions Created 4 years, 2 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
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/extensions/install_tracker.h" 5 #include "chrome/browser/extensions/install_tracker.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/install_tracker_factory.h" 9 #include "chrome/browser/extensions/install_tracker_factory.h"
10 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 void InstallTracker::OnBeginExtensionInstall( 77 void InstallTracker::OnBeginExtensionInstall(
78 const InstallObserver::ExtensionInstallParams& params) { 78 const InstallObserver::ExtensionInstallParams& params) {
79 ActiveInstallsMap::iterator install_data = 79 ActiveInstallsMap::iterator install_data =
80 active_installs_.find(params.extension_id); 80 active_installs_.find(params.extension_id);
81 if (install_data == active_installs_.end()) { 81 if (install_data == active_installs_.end()) {
82 ActiveInstallData install_data(params.extension_id); 82 ActiveInstallData install_data(params.extension_id);
83 active_installs_.insert(std::make_pair(params.extension_id, install_data)); 83 active_installs_.insert(std::make_pair(params.extension_id, install_data));
84 } 84 }
85 85
86 FOR_EACH_OBSERVER(InstallObserver, observers_, 86 for (auto& observer : observers_)
87 OnBeginExtensionInstall(params)); 87 observer.OnBeginExtensionInstall(params);
88 } 88 }
89 89
90 void InstallTracker::OnBeginExtensionDownload(const std::string& extension_id) { 90 void InstallTracker::OnBeginExtensionDownload(const std::string& extension_id) {
91 FOR_EACH_OBSERVER( 91 for (auto& observer : observers_)
92 InstallObserver, observers_, OnBeginExtensionDownload(extension_id)); 92 observer.OnBeginExtensionDownload(extension_id);
93 } 93 }
94 94
95 void InstallTracker::OnDownloadProgress(const std::string& extension_id, 95 void InstallTracker::OnDownloadProgress(const std::string& extension_id,
96 int percent_downloaded) { 96 int percent_downloaded) {
97 ActiveInstallsMap::iterator install_data = 97 ActiveInstallsMap::iterator install_data =
98 active_installs_.find(extension_id); 98 active_installs_.find(extension_id);
99 if (install_data != active_installs_.end()) { 99 if (install_data != active_installs_.end()) {
100 install_data->second.percent_downloaded = percent_downloaded; 100 install_data->second.percent_downloaded = percent_downloaded;
101 } else { 101 } else {
102 NOTREACHED(); 102 NOTREACHED();
103 } 103 }
104 104
105 FOR_EACH_OBSERVER(InstallObserver, observers_, 105 for (auto& observer : observers_)
106 OnDownloadProgress(extension_id, percent_downloaded)); 106 observer.OnDownloadProgress(extension_id, percent_downloaded);
107 } 107 }
108 108
109 void InstallTracker::OnBeginCrxInstall(const std::string& extension_id) { 109 void InstallTracker::OnBeginCrxInstall(const std::string& extension_id) {
110 FOR_EACH_OBSERVER( 110 for (auto& observer : observers_)
111 InstallObserver, observers_, OnBeginCrxInstall(extension_id)); 111 observer.OnBeginCrxInstall(extension_id);
112 } 112 }
113 113
114 void InstallTracker::OnFinishCrxInstall(const std::string& extension_id, 114 void InstallTracker::OnFinishCrxInstall(const std::string& extension_id,
115 bool success) { 115 bool success) {
116 FOR_EACH_OBSERVER( 116 for (auto& observer : observers_)
117 InstallObserver, observers_, OnFinishCrxInstall(extension_id, success)); 117 observer.OnFinishCrxInstall(extension_id, success);
118 } 118 }
119 119
120 void InstallTracker::OnInstallFailure( 120 void InstallTracker::OnInstallFailure(
121 const std::string& extension_id) { 121 const std::string& extension_id) {
122 RemoveActiveInstall(extension_id); 122 RemoveActiveInstall(extension_id);
123 FOR_EACH_OBSERVER(InstallObserver, observers_, 123 for (auto& observer : observers_)
124 OnInstallFailure(extension_id)); 124 observer.OnInstallFailure(extension_id);
125 } 125 }
126 126
127 void InstallTracker::Shutdown() { 127 void InstallTracker::Shutdown() {
128 FOR_EACH_OBSERVER(InstallObserver, observers_, OnShutdown()); 128 for (auto& observer : observers_)
129 observer.OnShutdown();
129 } 130 }
130 131
131 void InstallTracker::Observe(int type, 132 void InstallTracker::Observe(int type,
132 const content::NotificationSource& source, 133 const content::NotificationSource& source,
133 const content::NotificationDetails& details) { 134 const content::NotificationDetails& details) {
134 switch (type) { 135 switch (type) {
135 case extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED: { 136 case extensions::NOTIFICATION_EXTENSION_UPDATE_DISABLED: {
136 const Extension* extension = 137 const Extension* extension =
137 content::Details<const Extension>(details).ptr(); 138 content::Details<const Extension>(details).ptr();
138 FOR_EACH_OBSERVER( 139 for (auto& observer : observers_)
139 InstallObserver, observers_, OnDisabledExtensionUpdated(extension)); 140 observer.OnDisabledExtensionUpdated(extension);
140 break; 141 break;
141 } 142 }
142 case chrome::NOTIFICATION_APP_LAUNCHER_REORDERED: { 143 case chrome::NOTIFICATION_APP_LAUNCHER_REORDERED: {
143 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); 144 for (auto& observer : observers_)
145 observer.OnAppsReordered();
144 break; 146 break;
145 } 147 }
146 default: 148 default:
147 NOTREACHED(); 149 NOTREACHED();
148 } 150 }
149 } 151 }
150 152
151 void InstallTracker::OnExtensionInstalled( 153 void InstallTracker::OnExtensionInstalled(
152 content::BrowserContext* browser_context, 154 content::BrowserContext* browser_context,
153 const Extension* extension, 155 const Extension* extension,
154 bool is_update) { 156 bool is_update) {
155 RemoveActiveInstall(extension->id()); 157 RemoveActiveInstall(extension->id());
156 } 158 }
157 159
158 void InstallTracker::OnAppsReordered() { 160 void InstallTracker::OnAppsReordered() {
159 FOR_EACH_OBSERVER(InstallObserver, observers_, OnAppsReordered()); 161 for (auto& observer : observers_)
162 observer.OnAppsReordered();
160 } 163 }
161 164
162 } // namespace extensions 165 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698