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

Side by Side Diff: base/system_monitor/system_monitor.h

Issue 10905237: Fix a potential multi-thread issue when manipulating removable storage map (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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
« no previous file with comments | « no previous file | base/system_monitor/system_monitor.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 (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 #ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ 5 #ifndef BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ 6 #define BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
vandebo (ex-Chrome) 2012/09/12 17:12:57 Should include the lock header.
12 #include "base/base_export.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/file_path.h" 14 #include "base/file_path.h"
15 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 17
18 // Windows HiRes timers drain the battery faster so we need to know the battery 18 // Windows HiRes timers drain the battery faster so we need to know the battery
19 // status. This isn't true for other platforms. 19 // status. This isn't true for other platforms.
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #define ENABLE_BATTERY_MONITORING 1 21 #define ENABLE_BATTERY_MONITORING 1
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // This function must be called before instantiating an instance of the class 88 // This function must be called before instantiating an instance of the class
89 // and before the Sandbox is initialized. 89 // and before the Sandbox is initialized.
90 #if !defined(OS_IOS) 90 #if !defined(OS_IOS)
91 static void AllocateSystemIOPorts(); 91 static void AllocateSystemIOPorts();
92 #else 92 #else
93 static void AllocateSystemIOPorts() {} 93 static void AllocateSystemIOPorts() {}
94 #endif // OS_IOS 94 #endif // OS_IOS
95 #endif // OS_MACOSX 95 #endif // OS_MACOSX
96 96
97 // Returns information for attached removable storage. 97 // Returns information for attached removable storage.
98 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage() const; 98 std::vector<RemovableStorageInfo> GetAttachedRemovableStorage();
willchan no longer on Chromium 2012/09/12 17:00:45 This should probably stay const. If you only need
vandebo (ex-Chrome) 2012/09/12 17:12:57 Hmm, I haven't seen a lot of mutable annotations i
99 99
100 // 100 //
101 // Power-related APIs 101 // Power-related APIs
102 // 102 //
103 103
104 // Is the computer currently on battery power. 104 // Is the computer currently on battery power.
105 // Can be called on any thread. 105 // Can be called on any thread.
106 bool BatteryPower() const { 106 bool BatteryPower() const {
107 // Using a lock here is not necessary for just a bool. 107 // Using a lock here is not necessary for just a bool.
108 return battery_in_use_; 108 return battery_in_use_;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 #if defined(ENABLE_BATTERY_MONITORING) 213 #if defined(ENABLE_BATTERY_MONITORING)
214 base::OneShotTimer<SystemMonitor> delayed_battery_check_; 214 base::OneShotTimer<SystemMonitor> delayed_battery_check_;
215 #endif 215 #endif
216 216
217 #if defined(OS_IOS) 217 #if defined(OS_IOS)
218 // Holds pointers to system event notification observers. 218 // Holds pointers to system event notification observers.
219 std::vector<id> notification_observers_; 219 std::vector<id> notification_observers_;
220 #endif 220 #endif
221 221
222 // The lock for manipluating removable_storage_map_ structure.
vandebo (ex-Chrome) 2012/09/12 17:12:57 nit: Remove the: "Lock for..."
223 base::Lock removable_storage_lock_;
222 // Map of all the attached removable storage devices. 224 // Map of all the attached removable storage devices.
223 RemovableStorageMap removable_storage_map_; 225 RemovableStorageMap removable_storage_map_;
224 226
225 DISALLOW_COPY_AND_ASSIGN(SystemMonitor); 227 DISALLOW_COPY_AND_ASSIGN(SystemMonitor);
226 }; 228 };
227 229
228 } // namespace base 230 } // namespace base
229 231
230 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_ 232 #endif // BASE_SYSTEM_MONITOR_SYSTEM_MONITOR_H_
OLDNEW
« no previous file with comments | « no previous file | base/system_monitor/system_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698