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

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

Issue 656393002: [fsp] Pass proper data to Notify(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Created 6 years, 2 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
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/provided_file_system.h" 5 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/files/file.h" 10 #include "base/files/file.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 441 }
442 442
443 void ProvidedFileSystem::RemoveObserver(ProvidedFileSystemObserver* observer) { 443 void ProvidedFileSystem::RemoveObserver(ProvidedFileSystemObserver* observer) {
444 DCHECK(observer); 444 DCHECK(observer);
445 observers_.RemoveObserver(observer); 445 observers_.RemoveObserver(observer);
446 } 446 }
447 447
448 bool ProvidedFileSystem::Notify( 448 bool ProvidedFileSystem::Notify(
449 const base::FilePath& observed_path, 449 const base::FilePath& observed_path,
450 ProvidedFileSystemObserver::ChangeType change_type, 450 ProvidedFileSystemObserver::ChangeType change_type,
451 const ProvidedFileSystemObserver::ChildChanges& child_changes, 451 scoped_ptr<ProvidedFileSystemObserver::ChildChanges> child_changes,
452 const std::string& tag) { 452 const std::string& tag) {
453 const ObservedEntries::iterator it = observed_entries_.find(observed_path); 453 const ObservedEntries::iterator it = observed_entries_.find(observed_path);
454 if (it == observed_entries_.end()) 454 if (it == observed_entries_.end())
455 return false; 455 return false;
456 456
457 // The tag must be provided if and only if it's explicitly supported. 457 // The tag must be provided if and only if it's explicitly supported.
458 if (file_system_info_.supports_notify_tag() == tag.empty()) 458 if (file_system_info_.supports_notify_tag() == tag.empty())
459 return false; 459 return false;
460 460
461 // The object is owned by AutoUpdated, so the reference is valid as long as
462 // callbacks created with AutoUpdater::CreateCallback().
463 const ProvidedFileSystemObserver::ChildChanges& child_changes_ref =
464 *child_changes.get();
465
461 scoped_refptr<AutoUpdater> auto_updater( 466 scoped_refptr<AutoUpdater> auto_updater(
462 new AutoUpdater(base::Bind(&ProvidedFileSystem::OnNotifyCompleted, 467 new AutoUpdater(base::Bind(&ProvidedFileSystem::OnNotifyCompleted,
463 weak_ptr_factory_.GetWeakPtr(), 468 weak_ptr_factory_.GetWeakPtr(),
464 observed_path, 469 observed_path,
465 change_type, 470 change_type,
471 base::Passed(&child_changes),
466 it->second.last_tag, 472 it->second.last_tag,
467 tag))); 473 tag)));
468 474
469 FOR_EACH_OBSERVER(ProvidedFileSystemObserver, 475 FOR_EACH_OBSERVER(ProvidedFileSystemObserver,
470 observers_, 476 observers_,
471 OnObservedEntryChanged(file_system_info_, 477 OnObservedEntryChanged(file_system_info_,
472 observed_path, 478 observed_path,
473 change_type, 479 change_type,
474 child_changes, 480 child_changes_ref,
475 auto_updater->CreateCallback())); 481 auto_updater->CreateCallback()));
476 482
477 return true; 483 return true;
478 } 484 }
479 485
480 base::WeakPtr<ProvidedFileSystemInterface> ProvidedFileSystem::GetWeakPtr() { 486 base::WeakPtr<ProvidedFileSystemInterface> ProvidedFileSystem::GetWeakPtr() {
481 return weak_ptr_factory_.GetWeakPtr(); 487 return weak_ptr_factory_.GetWeakPtr();
482 } 488 }
483 489
484 void ProvidedFileSystem::Abort( 490 void ProvidedFileSystem::Abort(
(...skipping 29 matching lines...) Expand all
514 FOR_EACH_OBSERVER(ProvidedFileSystemObserver, 520 FOR_EACH_OBSERVER(ProvidedFileSystemObserver,
515 observers_, 521 observers_,
516 OnObservedEntryListChanged(file_system_info_)); 522 OnObservedEntryListChanged(file_system_info_));
517 523
518 callback.Run(result); 524 callback.Run(result);
519 } 525 }
520 526
521 void ProvidedFileSystem::OnNotifyCompleted( 527 void ProvidedFileSystem::OnNotifyCompleted(
522 const base::FilePath& observed_path, 528 const base::FilePath& observed_path,
523 ProvidedFileSystemObserver::ChangeType change_type, 529 ProvidedFileSystemObserver::ChangeType change_type,
530 scoped_ptr<ProvidedFileSystemObserver::ChildChanges> /* child_changes */,
524 const std::string& last_tag, 531 const std::string& last_tag,
525 const std::string& tag) { 532 const std::string& tag) {
526 const ObservedEntries::iterator it = observed_entries_.find(observed_path); 533 const ObservedEntries::iterator it = observed_entries_.find(observed_path);
527 // Check if the entry is still observed. 534 // Check if the entry is still observed.
528 if (it == observed_entries_.end()) 535 if (it == observed_entries_.end())
529 return; 536 return;
530 537
531 // Another following notification finished earlier. 538 // Another following notification finished earlier.
532 if (it->second.last_tag != last_tag) 539 if (it->second.last_tag != last_tag)
533 return; 540 return;
(...skipping 11 matching lines...) Expand all
545 observers_, 552 observers_,
546 OnObservedEntryTagUpdated(file_system_info_, observed_path)); 553 OnObservedEntryTagUpdated(file_system_info_, observed_path));
547 554
548 // If the observed entry is deleted, then unobserve it. 555 // If the observed entry is deleted, then unobserve it.
549 if (change_type == ProvidedFileSystemObserver::DELETED) 556 if (change_type == ProvidedFileSystemObserver::DELETED)
550 UnobserveEntry(observed_path, base::Bind(&EmptyStatusCallback)); 557 UnobserveEntry(observed_path, base::Bind(&EmptyStatusCallback));
551 } 558 }
552 559
553 } // namespace file_system_provider 560 } // namespace file_system_provider
554 } // namespace chromeos 561 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698