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

Side by Side Diff: chrome/browser/plugins/plugin_installer.cc

Issue 22918027: Remove calls to ObserverList::size() from PluginInstaller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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
« no previous file with comments | « chrome/browser/plugins/plugin_installer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/plugins/plugin_installer.h" 5 #include "chrome/browser/plugins/plugin_installer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/process/process.h" 9 #include "base/process/process.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if (error != net::OK) { 60 if (error != net::OK) {
61 BrowserThread::PostTask( 61 BrowserThread::PostTask(
62 BrowserThread::UI, FROM_HERE, 62 BrowserThread::UI, FROM_HERE,
63 base::Bind(callback, static_cast<DownloadItem*>(NULL), error)); 63 base::Bind(callback, static_cast<DownloadItem*>(NULL), error));
64 } 64 }
65 } 65 }
66 66
67 } // namespace 67 } // namespace
68 68
69 PluginInstaller::PluginInstaller() 69 PluginInstaller::PluginInstaller()
70 : state_(INSTALLER_STATE_IDLE) { 70 : state_(INSTALLER_STATE_IDLE),
71 strong_observer_count_(0) {
71 } 72 }
72 73
73 PluginInstaller::~PluginInstaller() { 74 PluginInstaller::~PluginInstaller() {
74 } 75 }
75 76
76 void PluginInstaller::OnDownloadUpdated(DownloadItem* download) { 77 void PluginInstaller::OnDownloadUpdated(DownloadItem* download) {
77 DownloadItem::DownloadState state = download->GetState(); 78 DownloadItem::DownloadState state = download->GetState();
78 switch (state) { 79 switch (state) {
79 case DownloadItem::IN_PROGRESS: 80 case DownloadItem::IN_PROGRESS:
80 return; 81 return;
(...skipping 21 matching lines...) Expand all
102 download->RemoveObserver(this); 103 download->RemoveObserver(this);
103 } 104 }
104 105
105 void PluginInstaller::OnDownloadDestroyed(DownloadItem* download) { 106 void PluginInstaller::OnDownloadDestroyed(DownloadItem* download) {
106 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 107 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
107 state_ = INSTALLER_STATE_IDLE; 108 state_ = INSTALLER_STATE_IDLE;
108 download->RemoveObserver(this); 109 download->RemoveObserver(this);
109 } 110 }
110 111
111 void PluginInstaller::AddObserver(PluginInstallerObserver* observer) { 112 void PluginInstaller::AddObserver(PluginInstallerObserver* observer) {
113 strong_observer_count_++;
112 observers_.AddObserver(observer); 114 observers_.AddObserver(observer);
113 } 115 }
114 116
115 void PluginInstaller::RemoveObserver(PluginInstallerObserver* observer) { 117 void PluginInstaller::RemoveObserver(PluginInstallerObserver* observer) {
118 strong_observer_count_--;
116 observers_.RemoveObserver(observer); 119 observers_.RemoveObserver(observer);
117 if (observers_.size() == weak_observers_.size()) { 120 if (strong_observer_count_ == 0) {
118 FOR_EACH_OBSERVER(WeakPluginInstallerObserver, weak_observers_, 121 FOR_EACH_OBSERVER(WeakPluginInstallerObserver, weak_observers_,
119 OnlyWeakObserversLeft()); 122 OnlyWeakObserversLeft());
120 } 123 }
121 } 124 }
122 125
123 void PluginInstaller::AddWeakObserver(WeakPluginInstallerObserver* observer) { 126 void PluginInstaller::AddWeakObserver(WeakPluginInstallerObserver* observer) {
124 weak_observers_.AddObserver(observer); 127 weak_observers_.AddObserver(observer);
125 } 128 }
126 129
127 void PluginInstaller::RemoveWeakObserver( 130 void PluginInstaller::RemoveWeakObserver(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 180 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
178 state_ = INSTALLER_STATE_IDLE; 181 state_ = INSTALLER_STATE_IDLE;
179 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); 182 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg));
180 } 183 }
181 184
182 void PluginInstaller::DownloadCancelled() { 185 void PluginInstaller::DownloadCancelled() {
183 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); 186 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_);
184 state_ = INSTALLER_STATE_IDLE; 187 state_ = INSTALLER_STATE_IDLE;
185 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); 188 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled());
186 } 189 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_installer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698