OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/file_system_provider/service.h" | 5 #include "chrome/browser/chromeos/file_system_provider/service.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" | 9 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" |
10 #include "chrome/browser/chromeos/file_system_provider/observer.h" | 10 #include "chrome/browser/chromeos/file_system_provider/observer.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 extensions::ExtensionRegistry* extension_registry) | 40 extensions::ExtensionRegistry* extension_registry) |
41 : profile_(profile), | 41 : profile_(profile), |
42 extension_registry_(extension_registry), | 42 extension_registry_(extension_registry), |
43 file_system_factory_(base::Bind(CreateProvidedFileSystem)), | 43 file_system_factory_(base::Bind(CreateProvidedFileSystem)), |
44 next_id_(1), | 44 next_id_(1), |
45 weak_ptr_factory_(this) { | 45 weak_ptr_factory_(this) { |
46 extension_registry_->AddObserver(this); | 46 extension_registry_->AddObserver(this); |
47 } | 47 } |
48 | 48 |
49 Service::~Service() { | 49 Service::~Service() { |
| 50 extension_registry_->RemoveObserver(this); |
| 51 |
50 ProvidedFileSystemMap::iterator it = file_system_map_.begin(); | 52 ProvidedFileSystemMap::iterator it = file_system_map_.begin(); |
51 while (it != file_system_map_.end()) { | 53 while (it != file_system_map_.end()) { |
52 const int file_system_id = it->first; | 54 const int file_system_id = it->first; |
53 const std::string extension_id = | 55 const std::string extension_id = |
54 it->second->GetFileSystemInfo().extension_id(); | 56 it->second->GetFileSystemInfo().extension_id(); |
55 ++it; | 57 ++it; |
56 UnmountFileSystem(extension_id, file_system_id); | 58 UnmountFileSystem(extension_id, file_system_id); |
57 } | 59 } |
58 | 60 |
59 DCHECK_EQ(0u, file_system_map_.size()); | 61 DCHECK_EQ(0u, file_system_map_.size()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 199 } |
198 | 200 |
199 bool Service::RequestUnmount(int file_system_id) { | 201 bool Service::RequestUnmount(int file_system_id) { |
200 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 202 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
201 | 203 |
202 ProvidedFileSystemMap::iterator file_system_it = | 204 ProvidedFileSystemMap::iterator file_system_it = |
203 file_system_map_.find(file_system_id); | 205 file_system_map_.find(file_system_id); |
204 if (file_system_it == file_system_map_.end()) | 206 if (file_system_it == file_system_map_.end()) |
205 return false; | 207 return false; |
206 | 208 |
207 return file_system_it->second->RequestUnmount( | 209 file_system_it->second->RequestUnmount( |
208 base::Bind(&Service::OnRequestUnmountStatus, | 210 base::Bind(&Service::OnRequestUnmountStatus, |
209 weak_ptr_factory_.GetWeakPtr(), | 211 weak_ptr_factory_.GetWeakPtr(), |
210 file_system_it->second->GetFileSystemInfo())); | 212 file_system_it->second->GetFileSystemInfo())); |
| 213 return true; |
211 } | 214 } |
212 | 215 |
213 std::vector<ProvidedFileSystemInfo> Service::GetProvidedFileSystemInfoList() { | 216 std::vector<ProvidedFileSystemInfo> Service::GetProvidedFileSystemInfoList() { |
214 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 217 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
215 | 218 |
216 std::vector<ProvidedFileSystemInfo> result; | 219 std::vector<ProvidedFileSystemInfo> result; |
217 for (ProvidedFileSystemMap::const_iterator it = file_system_map_.begin(); | 220 for (ProvidedFileSystemMap::const_iterator it = file_system_map_.begin(); |
218 it != file_system_map_.end(); | 221 it != file_system_map_.end(); |
219 ++it) { | 222 ++it) { |
220 result.push_back(it->second->GetFileSystemInfo()); | 223 result.push_back(it->second->GetFileSystemInfo()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // invoked, and observers notified, so there is no need to call them now. | 286 // invoked, and observers notified, so there is no need to call them now. |
284 if (error != base::File::FILE_OK) { | 287 if (error != base::File::FILE_OK) { |
285 FOR_EACH_OBSERVER(Observer, | 288 FOR_EACH_OBSERVER(Observer, |
286 observers_, | 289 observers_, |
287 OnProvidedFileSystemUnmount(file_system_info, error)); | 290 OnProvidedFileSystemUnmount(file_system_info, error)); |
288 } | 291 } |
289 } | 292 } |
290 | 293 |
291 } // namespace file_system_provider | 294 } // namespace file_system_provider |
292 } // namespace chromeos | 295 } // namespace chromeos |
OLD | NEW |