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

Side by Side Diff: chrome/browser/extensions/api/system_info/system_info_api.cc

Issue 216513002: Replace DCHECK(BrowserThread::CurrentlyOn) with DCHECK_CURRENTLY_ON in extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 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/api/system_info/system_info_api.h" 5 #include "chrome/browser/extensions/api/system_info/system_info_api.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 SystemInfoEventRouter::~SystemInfoEventRouter() { 108 SystemInfoEventRouter::~SystemInfoEventRouter() {
109 if (has_storage_monitor_observer_) { 109 if (has_storage_monitor_observer_) {
110 StorageMonitor* storage_monitor = StorageMonitor::GetInstance(); 110 StorageMonitor* storage_monitor = StorageMonitor::GetInstance();
111 if (storage_monitor) 111 if (storage_monitor)
112 storage_monitor->RemoveObserver(this); 112 storage_monitor->RemoveObserver(this);
113 } 113 }
114 } 114 }
115 115
116 void SystemInfoEventRouter::AddEventListener(const std::string& event_name) { 116 void SystemInfoEventRouter::AddEventListener(const std::string& event_name) {
117 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 117 DCHECK_CURRENTLY_ON(BrowserThread::UI);
118 118
119 watching_event_set_.insert(event_name); 119 watching_event_set_.insert(event_name);
120 if (watching_event_set_.count(event_name) > 1) 120 if (watching_event_set_.count(event_name) > 1)
121 return; 121 return;
122 122
123 // For system.display event. 123 // For system.display event.
124 #if defined(OS_CHROMEOS) 124 #if defined(OS_CHROMEOS)
125 if (IsDisplayChangedEvent(event_name)) 125 if (IsDisplayChangedEvent(event_name))
126 ash::Shell::GetScreen()->AddObserver(this); 126 ash::Shell::GetScreen()->AddObserver(this);
127 #endif 127 #endif
128 128
129 if (IsSystemStorageEvent(event_name)) { 129 if (IsSystemStorageEvent(event_name)) {
130 if (!has_storage_monitor_observer_) { 130 if (!has_storage_monitor_observer_) {
131 has_storage_monitor_observer_ = true; 131 has_storage_monitor_observer_ = true;
132 DCHECK(StorageMonitor::GetInstance()->IsInitialized()); 132 DCHECK(StorageMonitor::GetInstance()->IsInitialized());
133 StorageMonitor::GetInstance()->AddObserver(this); 133 StorageMonitor::GetInstance()->AddObserver(this);
134 } 134 }
135 } 135 }
136 } 136 }
137 137
138 void SystemInfoEventRouter::RemoveEventListener(const std::string& event_name) { 138 void SystemInfoEventRouter::RemoveEventListener(const std::string& event_name) {
139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 139 DCHECK_CURRENTLY_ON(BrowserThread::UI);
140 140
141 std::multiset<std::string>::iterator it = 141 std::multiset<std::string>::iterator it =
142 watching_event_set_.find(event_name); 142 watching_event_set_.find(event_name);
143 if (it != watching_event_set_.end()) { 143 if (it != watching_event_set_.end()) {
144 watching_event_set_.erase(it); 144 watching_event_set_.erase(it);
145 if (watching_event_set_.count(event_name) > 0) 145 if (watching_event_set_.count(event_name) > 0)
146 return; 146 return;
147 } 147 }
148 148
149 #if defined(OS_CHROMEOS) 149 #if defined(OS_CHROMEOS)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) { 254 void SystemInfoAPI::OnListenerRemoved(const EventListenerInfo& details) {
255 if (IsSystemStorageEvent(details.event_name)) { 255 if (IsSystemStorageEvent(details.event_name)) {
256 StorageMonitor::GetInstance()->EnsureInitialized( 256 StorageMonitor::GetInstance()->EnsureInitialized(
257 base::Bind(&RemoveEventListener, details.event_name)); 257 base::Bind(&RemoveEventListener, details.event_name));
258 } else { 258 } else {
259 RemoveEventListener(details.event_name); 259 RemoveEventListener(details.event_name);
260 } 260 }
261 } 261 }
262 262
263 } // namespace extensions 263 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698