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

Side by Side Diff: chrome/browser/status_icons/status_tray.cc

Issue 10156004: status_icons: Fold RemoveAllIcons() into StatusTray dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unittest Created 8 years, 8 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
1 // Copyright (c) 2011 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/status_icons/status_tray.h" 5 #include "chrome/browser/status_icons/status_tray.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/status_icons/status_icon.h" 10 #include "chrome/browser/status_icons/status_icon.h"
11 11
12 StatusTray::StatusTray() { 12 StatusTray::StatusTray() {
13 } 13 }
14 14
15 StatusTray::~StatusTray() { 15 StatusTray::~StatusTray() {
16 RemoveAllIcons();
17 }
18
19 void StatusTray::RemoveAllIcons() {
20 STLDeleteElements(&status_icons_); 16 STLDeleteElements(&status_icons_);
21 } 17 }
22 18
23 StatusIcon* StatusTray::CreateStatusIcon() { 19 StatusIcon* StatusTray::CreateStatusIcon() {
24 StatusIcon* icon = CreatePlatformStatusIcon(); 20 StatusIcon* icon = CreatePlatformStatusIcon();
25 if (icon) 21 if (icon)
26 status_icons_.push_back(icon); 22 status_icons_.push_back(icon);
27 return icon; 23 return icon;
28 } 24 }
29 25
30 void StatusTray::RemoveStatusIcon(StatusIcon* icon) { 26 void StatusTray::RemoveStatusIcon(StatusIcon* icon) {
31 StatusIconList::iterator iter = std::find( 27 StatusIconList::iterator i(std::find(status_icons_.begin(),
32 status_icons_.begin(), status_icons_.end(), icon); 28 status_icons_.end(), icon));
33 if (iter != status_icons_.end()) { 29 DCHECK(i != status_icons_.end());
Andrew T Wilson (Slow) 2012/04/20 19:13:09 I think I'd prefer this to read: if (i == status_i
tfarina 2012/04/20 19:24:13 Done.
34 // Free the StatusIcon from the list. 30 delete *i;
35 delete *iter; 31 status_icons_.erase(i);
36 status_icons_.erase(iter);
37 }
38 } 32 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698