| OLD | NEW |
| 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/storage_monitor/storage_monitor.h" | 5 #include "chrome/browser/storage_monitor/storage_monitor.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/storage_monitor/removable_storage_observer.h" | 9 #include "chrome/browser/storage_monitor/removable_storage_observer.h" |
| 10 #include "chrome/browser/storage_monitor/transient_device_ids.h" | 10 #include "chrome/browser/storage_monitor/transient_device_ids.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 if (initialized_) { | 65 if (initialized_) { |
| 66 if (!callback.is_null()) | 66 if (!callback.is_null()) |
| 67 callback.Run(); | 67 callback.Run(); |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 | 70 |
| 71 if (!callback.is_null()) { | 71 if (!callback.is_null()) { |
| 72 on_initialize_callbacks_.push_back(callback); | 72 on_initialize_callbacks_.push_back(callback); |
| 73 } | 73 } |
| 74 | 74 |
| 75 if (initializing_) |
| 76 return; |
| 77 |
| 78 initializing_ = true; |
| 75 Init(); | 79 Init(); |
| 76 } | 80 } |
| 77 | 81 |
| 78 bool StorageMonitor::IsInitialized() { | 82 bool StorageMonitor::IsInitialized() { |
| 79 return initialized_; | 83 return initialized_; |
| 80 } | 84 } |
| 81 | 85 |
| 82 void StorageMonitor::AddObserver(RemovableStorageObserver* obs) { | 86 void StorageMonitor::AddObserver(RemovableStorageObserver* obs) { |
| 83 observer_list_->AddObserver(obs); | 87 observer_list_->AddObserver(obs); |
| 84 } | 88 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 101 void StorageMonitor::EjectDevice( | 105 void StorageMonitor::EjectDevice( |
| 102 const std::string& device_id, | 106 const std::string& device_id, |
| 103 base::Callback<void(EjectStatus)> callback) { | 107 base::Callback<void(EjectStatus)> callback) { |
| 104 // Platform-specific implementations will override this method to | 108 // Platform-specific implementations will override this method to |
| 105 // perform actual device ejection. | 109 // perform actual device ejection. |
| 106 callback.Run(EJECT_FAILURE); | 110 callback.Run(EJECT_FAILURE); |
| 107 } | 111 } |
| 108 | 112 |
| 109 StorageMonitor::StorageMonitor() | 113 StorageMonitor::StorageMonitor() |
| 110 : observer_list_(new ObserverListThreadSafe<RemovableStorageObserver>()), | 114 : observer_list_(new ObserverListThreadSafe<RemovableStorageObserver>()), |
| 115 initializing_(false), |
| 111 initialized_(false), | 116 initialized_(false), |
| 112 transient_device_ids_(new TransientDeviceIds) { | 117 transient_device_ids_(new TransientDeviceIds) { |
| 113 receiver_.reset(new ReceiverImpl(this)); | 118 receiver_.reset(new ReceiverImpl(this)); |
| 114 | 119 |
| 115 DCHECK(!g_storage_monitor); | 120 DCHECK(!g_storage_monitor); |
| 116 g_storage_monitor = this; | 121 g_storage_monitor = this; |
| 117 } | 122 } |
| 118 | 123 |
| 119 StorageMonitor::~StorageMonitor() { | 124 StorageMonitor::~StorageMonitor() { |
| 120 g_storage_monitor = NULL; | 125 g_storage_monitor = NULL; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 info = it->second; | 171 info = it->second; |
| 167 storage_map_.erase(it); | 172 storage_map_.erase(it); |
| 168 } | 173 } |
| 169 | 174 |
| 170 DVLOG(1) << "RemovableStorageDetached for id " << id; | 175 DVLOG(1) << "RemovableStorageDetached for id " << id; |
| 171 observer_list_->Notify( | 176 observer_list_->Notify( |
| 172 &RemovableStorageObserver::OnRemovableStorageDetached, info); | 177 &RemovableStorageObserver::OnRemovableStorageDetached, info); |
| 173 } | 178 } |
| 174 | 179 |
| 175 } // namespace chrome | 180 } // namespace chrome |
| OLD | NEW |