| 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/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* | 13 static RemovableStorageNotifications* |
| 14 g_removable_storage_notifications = NULL; | 14 g_removable_storage_notifications = NULL; |
| 15 | 15 |
| 16 RemovableStorageNotifications::StorageInfo::StorageInfo() { | 16 RemovableStorageNotifications::StorageInfo::StorageInfo() |
| 17 : total_size_in_bytes(0) { |
| 17 } | 18 } |
| 18 | 19 |
| 19 RemovableStorageNotifications::StorageInfo::StorageInfo( | 20 RemovableStorageNotifications::StorageInfo::StorageInfo( |
| 20 const std::string& id, | 21 const std::string& id, |
| 21 const string16& device_name, | 22 const string16& device_name, |
| 22 const base::FilePath::StringType& device_location) | 23 const base::FilePath::StringType& device_location) |
| 23 : device_id(id), | 24 : device_id(id), |
| 24 name(device_name), | 25 name(device_name), |
| 25 location(device_location) { | 26 location(device_location), |
| 27 total_size_in_bytes(0) { |
| 26 } | 28 } |
| 27 | 29 |
| 28 RemovableStorageNotifications::Receiver::~Receiver() { | 30 RemovableStorageNotifications::Receiver::~Receiver() { |
| 29 } | 31 } |
| 30 | 32 |
| 31 class RemovableStorageNotifications::ReceiverImpl | 33 class RemovableStorageNotifications::ReceiverImpl |
| 32 : public RemovableStorageNotifications::Receiver { | 34 : public RemovableStorageNotifications::Receiver { |
| 33 public: | 35 public: |
| 34 explicit ReceiverImpl(RemovableStorageNotifications* notifications) | 36 explicit ReceiverImpl(RemovableStorageNotifications* notifications) |
| 35 : notifications_(notifications) {} | 37 : notifications_(notifications) {} |
| 36 | 38 |
| 37 virtual ~ReceiverImpl() {} | 39 virtual ~ReceiverImpl() {} |
| 38 | 40 |
| 39 void ProcessAttach(const std::string& id, | 41 void ProcessAttach( |
| 40 const string16& name, | 42 const RemovableStorageNotifications::StorageInfo& info) OVERRIDE; |
| 41 const base::FilePath::StringType& location) OVERRIDE; | |
| 42 | 43 |
| 43 void ProcessDetach(const std::string& id) OVERRIDE; | 44 void ProcessDetach(const std::string& id) OVERRIDE; |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 RemovableStorageNotifications* notifications_; | 47 RemovableStorageNotifications* notifications_; |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 void RemovableStorageNotifications::ReceiverImpl::ProcessAttach( | 50 void RemovableStorageNotifications::ReceiverImpl::ProcessAttach( |
| 50 const std::string& id, | 51 const RemovableStorageNotifications::StorageInfo& info) { |
| 51 const string16& name, | 52 notifications_->ProcessAttach(info); |
| 52 const base::FilePath::StringType& location) { | |
| 53 notifications_->ProcessAttach( | |
| 54 RemovableStorageNotifications::StorageInfo(id, name, location)); | |
| 55 } | 53 } |
| 56 | 54 |
| 57 void RemovableStorageNotifications::ReceiverImpl::ProcessDetach( | 55 void RemovableStorageNotifications::ReceiverImpl::ProcessDetach( |
| 58 const std::string& id) { | 56 const std::string& id) { |
| 59 notifications_->ProcessDetach(id); | 57 notifications_->ProcessDetach(id); |
| 60 } | 58 } |
| 61 | 59 |
| 62 RemovableStorageNotifications::RemovableStorageNotifications() | 60 RemovableStorageNotifications::RemovableStorageNotifications() |
| 63 : observer_list_( | 61 : observer_list_( |
| 64 new ObserverListThreadSafe<RemovableStorageObserver>()) { | 62 new ObserverListThreadSafe<RemovableStorageObserver>()) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 void RemovableStorageNotifications::RemoveObserver( | 130 void RemovableStorageNotifications::RemoveObserver( |
| 133 RemovableStorageObserver* obs) { | 131 RemovableStorageObserver* obs) { |
| 134 observer_list_->RemoveObserver(obs); | 132 observer_list_->RemoveObserver(obs); |
| 135 } | 133 } |
| 136 | 134 |
| 137 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() { | 135 RemovableStorageNotifications* RemovableStorageNotifications::GetInstance() { |
| 138 return g_removable_storage_notifications; | 136 return g_removable_storage_notifications; |
| 139 } | 137 } |
| 140 | 138 |
| 141 } // namespace chrome | 139 } // namespace chrome |
| OLD | NEW |