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

Side by Side Diff: chrome/browser/system_monitor/removable_storage_notifications.cc

Issue 11573048: [Media Galleries] Move RemovableStorageInfo notifications to chrome namespace (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typedef, init observer Created 7 years, 11 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) 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/system_monitor/removable_storage_notifications.h" 5 #include "chrome/browser/system_monitor/removable_storage_notifications.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/system_monitor/removable_storage_observer.h" 9 #include "chrome/browser/system_monitor/removable_storage_observer.h"
10 10
11 namespace chrome { 11 namespace chrome {
12 12
13 static RemovableStorageNotifications*
14 g_removable_storage_notifications = NULL;
15
13 RemovableStorageNotifications::StorageInfo::StorageInfo() { 16 RemovableStorageNotifications::StorageInfo::StorageInfo() {
14 } 17 }
15 18
16 RemovableStorageNotifications::StorageInfo::StorageInfo( 19 RemovableStorageNotifications::StorageInfo::StorageInfo(
17 const std::string& id, 20 const std::string& id,
18 const string16& device_name, 21 const string16& device_name,
19 const FilePath::StringType& device_location) 22 const FilePath::StringType& device_location)
20 : device_id(id), 23 : device_id(id),
21 name(device_name), 24 name(device_name),
22 location(device_location) { 25 location(device_location) {
23 } 26 }
24 27
25 RemovableStorageNotifications::RemovableStorageNotifications() 28 RemovableStorageNotifications::RemovableStorageNotifications()
26 : observer_list_( 29 : observer_list_(
27 new ObserverListThreadSafe<RemovableStorageObserver>()) { 30 new ObserverListThreadSafe<RemovableStorageObserver>()) {
31 DCHECK(!g_removable_storage_notifications);
32 g_removable_storage_notifications = this;
28 } 33 }
29 34
30 RemovableStorageNotifications::~RemovableStorageNotifications() { 35 RemovableStorageNotifications::~RemovableStorageNotifications() {
36 DCHECK_EQ(this, g_removable_storage_notifications);
37 g_removable_storage_notifications = NULL;
31 } 38 }
32 39
33 void RemovableStorageNotifications::ProcessAttach( 40 void RemovableStorageNotifications::ProcessAttach(
34 const std::string& id, 41 const std::string& id,
35 const string16& name, 42 const string16& name,
36 const FilePath::StringType& location) { 43 const FilePath::StringType& location) {
37 StorageInfo info(id, name, location); 44 StorageInfo info(id, name, location);
38 { 45 {
39 base::AutoLock lock(storage_lock_); 46 base::AutoLock lock(storage_lock_);
40 if (ContainsKey(storage_map_, id)) { 47 if (ContainsKey(storage_map_, id)) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 90
84 void RemovableStorageNotifications::AddObserver(RemovableStorageObserver* obs) { 91 void RemovableStorageNotifications::AddObserver(RemovableStorageObserver* obs) {
85 observer_list_->AddObserver(obs); 92 observer_list_->AddObserver(obs);
86 } 93 }
87 94
88 void RemovableStorageNotifications::RemoveObserver( 95 void RemovableStorageNotifications::RemoveObserver(
89 RemovableStorageObserver* obs) { 96 RemovableStorageObserver* obs) {
90 observer_list_->RemoveObserver(obs); 97 observer_list_->RemoveObserver(obs);
91 } 98 }
92 99
100 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() {
101 return g_removable_storage_notifications;
102 }
103
93 } // namespace chrome 104 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698