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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/service.cc

Issue 674413002: [fsp] Rename ObserveEntry with AddWatcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 1 month 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
OLDNEW
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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/scoped_user_pref_update.h" 9 #include "base/prefs/scoped_user_pref_update.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // mount_path = /provided/b33f1337-hello_world-5aa5 151 // mount_path = /provided/b33f1337-hello_world-5aa5
152 ProvidedFileSystemInfo file_system_info(extension_id, options, mount_path); 152 ProvidedFileSystemInfo file_system_info(extension_id, options, mount_path);
153 153
154 ProvidedFileSystemInterface* file_system = 154 ProvidedFileSystemInterface* file_system =
155 file_system_factory_.Run(profile_, file_system_info); 155 file_system_factory_.Run(profile_, file_system_info);
156 DCHECK(file_system); 156 DCHECK(file_system);
157 file_system_map_[FileSystemKey(extension_id, options.file_system_id)] = 157 file_system_map_[FileSystemKey(extension_id, options.file_system_id)] =
158 file_system; 158 file_system;
159 mount_point_name_to_key_map_[mount_point_name] = 159 mount_point_name_to_key_map_[mount_point_name] =
160 FileSystemKey(extension_id, options.file_system_id); 160 FileSystemKey(extension_id, options.file_system_id);
161 registry_->RememberFileSystem(file_system_info, 161 registry_->RememberFileSystem(file_system_info, *file_system->GetWatchers());
162 *file_system->GetObservedEntries());
163 162
164 FOR_EACH_OBSERVER( 163 FOR_EACH_OBSERVER(
165 Observer, 164 Observer,
166 observers_, 165 observers_,
167 OnProvidedFileSystemMount(file_system_info, base::File::FILE_OK)); 166 OnProvidedFileSystemMount(file_system_info, base::File::FILE_OK));
168 167
169 return true; 168 return true;
170 } 169 }
171 170
172 bool Service::UnmountFileSystem(const std::string& extension_id, 171 bool Service::UnmountFileSystem(const std::string& extension_id,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // preferences to avoid remounting it over and over again with a failure. 303 // preferences to avoid remounting it over and over again with a failure.
305 registry_->ForgetFileSystem(restored_file_system.extension_id, 304 registry_->ForgetFileSystem(restored_file_system.extension_id,
306 restored_file_system.options.file_system_id); 305 restored_file_system.options.file_system_id);
307 continue; 306 continue;
308 } 307 }
309 308
310 ProvidedFileSystemInterface* const file_system = 309 ProvidedFileSystemInterface* const file_system =
311 GetProvidedFileSystem(restored_file_system.extension_id, 310 GetProvidedFileSystem(restored_file_system.extension_id,
312 restored_file_system.options.file_system_id); 311 restored_file_system.options.file_system_id);
313 DCHECK(file_system); 312 DCHECK(file_system);
314 file_system->GetObservedEntries()->insert( 313 file_system->GetWatchers()->insert(restored_file_system.watchers.begin(),
315 restored_file_system.observed_entries.begin(), 314 restored_file_system.watchers.end());
316 restored_file_system.observed_entries.end());
317 } 315 }
318 } 316 }
319 317
320 ProvidedFileSystemInterface* Service::GetProvidedFileSystem( 318 ProvidedFileSystemInterface* Service::GetProvidedFileSystem(
321 const std::string& mount_point_name) { 319 const std::string& mount_point_name) {
322 DCHECK(thread_checker_.CalledOnValidThread()); 320 DCHECK(thread_checker_.CalledOnValidThread());
323 321
324 const MountPointNameToKeyMap::const_iterator mapping_it = 322 const MountPointNameToKeyMap::const_iterator mapping_it =
325 mount_point_name_to_key_map_.find(mount_point_name); 323 mount_point_name_to_key_map_.find(mount_point_name);
326 if (mapping_it == mount_point_name_to_key_map_.end()) 324 if (mapping_it == mount_point_name_to_key_map_.end())
(...skipping 13 matching lines...) Expand all
340 // Notify observers about failure in unmounting, since mount() will not be 338 // Notify observers about failure in unmounting, since mount() will not be
341 // called by the provided file system. In case of success mount() will be 339 // called by the provided file system. In case of success mount() will be
342 // invoked, and observers notified, so there is no need to call them now. 340 // invoked, and observers notified, so there is no need to call them now.
343 if (error != base::File::FILE_OK) { 341 if (error != base::File::FILE_OK) {
344 FOR_EACH_OBSERVER(Observer, 342 FOR_EACH_OBSERVER(Observer,
345 observers_, 343 observers_,
346 OnProvidedFileSystemUnmount(file_system_info, error)); 344 OnProvidedFileSystemUnmount(file_system_info, error));
347 } 345 }
348 } 346 }
349 347
350 void Service::OnObservedEntryChanged( 348 void Service::OnWatcherChanged(const ProvidedFileSystemInfo& file_system_info,
351 const ProvidedFileSystemInfo& file_system_info, 349 const Watcher& watcher,
352 const ObservedEntry& observed_entry, 350 ChangeType change_type,
353 ChangeType change_type, 351 const Changes& changes,
354 const Changes& changes, 352 const base::Closure& callback) {
355 const base::Closure& callback) {
356 callback.Run(); 353 callback.Run();
357 } 354 }
358 355
359 void Service::OnObservedEntryTagUpdated( 356 void Service::OnWatcherTagUpdated(
360 const ProvidedFileSystemInfo& file_system_info, 357 const ProvidedFileSystemInfo& file_system_info,
361 const ObservedEntry& observed_entry) { 358 const Watcher& watcher) {
362 PrefService* const pref_service = profile_->GetPrefs(); 359 PrefService* const pref_service = profile_->GetPrefs();
363 DCHECK(pref_service); 360 DCHECK(pref_service);
364 361
365 registry_->UpdateObservedEntryTag(file_system_info, observed_entry); 362 registry_->UpdateWatcherTag(file_system_info, watcher);
366 } 363 }
367 364
368 void Service::OnObservedEntryListChanged( 365 void Service::OnWatcherListChanged(
369 const ProvidedFileSystemInfo& file_system_info, 366 const ProvidedFileSystemInfo& file_system_info,
370 const ObservedEntries& observed_entries) { 367 const Watchers& watchers) {
371 registry_->RememberFileSystem(file_system_info, observed_entries); 368 registry_->RememberFileSystem(file_system_info, watchers);
372 } 369 }
373 370
374 } // namespace file_system_provider 371 } // namespace file_system_provider
375 } // namespace chromeos 372 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698