Lines Matching refs:tracker
38 const char kFileTrackerKeyPrefix[] = "TRACKER: ";
141 void PutTrackerToBatch(const FileTracker& tracker, leveldb::WriteBatch* batch) {
143 bool success = tracker.SerializeToString(&value);
145 batch->Put(kFileTrackerKeyPrefix + base::Int64ToString(tracker.tracker_id()),
177 std::string GetTrackerTitle(const FileTracker& tracker) {
178 if (tracker.has_synced_details())
179 return tracker.synced_details().title();
312 scoped_ptr<FileTracker> tracker(new FileTracker);
313 if (!tracker->ParseFromString(itr->value().ToString())) {
315 "Failed to parse a Tracker");
318 contents->file_trackers.push_back(tracker.release());
350 FileTracker* tracker = *itr;
351 DCHECK(!ContainsKey(unvisited_trackers, tracker->tracker_id()));
352 unvisited_trackers[tracker->tracker_id()] = tracker;
353 if (tracker->parent_tracker_id())
354 trackers_by_parent[tracker->parent_tracker_id()].insert(tracker);
357 // Traverse synced tracker tree. Take only active items, app-root and their
373 FileTracker* tracker = found->second;
375 reachable_trackers.push_back(tracker);
377 if (!tracker->active() && !tracker->is_app_root())
395 FileTracker* tracker = itr->second;
396 PutTrackerDeletionToBatch(tracker->tracker_id(), batch);
397 delete tracker;
403 // Update the tracker set in database contents with the reachable tracker set.
520 FileTracker* tracker = *trackers.tracker_set().begin();
523 RegisterTrackerAsAppRoot(app_id, tracker->tracker_id(), batch.get());
529 FileTracker tracker;
530 if (!FindAppRootTracker(app_id, &tracker)) {
535 if (!tracker.active()) {
541 MakeTrackerInactive(tracker.tracker_id(), batch.get());
547 FileTracker tracker;
548 if (!FindAppRootTracker(app_id, &tracker)) {
553 if (tracker.active()) {
559 MakeTrackerActive(tracker.tracker_id(), batch.get());
565 FileTracker tracker;
566 if (!FindAppRootTracker(app_id, &tracker)) {
577 FileTracker* tracker) const {
578 return FindItem(app_root_by_app_id_, app_id, tracker);
597 FileTracker* tracker) const {
598 return FindItem(tracker_by_id_, tracker_id, tracker);
752 FileTracker* tracker = *itr;
753 tracker_by_id_[tracker->tracker_id()] = tracker;
754 trackers_by_file_id_[tracker->file_id()].Insert(tracker);
756 if (tracker->is_app_root())
757 app_root_by_app_id_[tracker->app_id()] = tracker;
759 if (tracker->parent_tracker_id()) {
760 std::string title = GetTrackerTitle(*tracker);
762 &trackers_by_parent_and_title_[tracker->parent_tracker_id()][title];
763 trackers->Insert(tracker);
766 if (tracker->dirty())
767 dirty_trackers_.insert(tracker);
776 FileTracker* tracker = tracker_by_id_[tracker_id];
777 DCHECK(tracker);
778 tracker->set_app_id(app_id);
779 tracker->set_is_app_root(true);
780 app_root_by_app_id_[app_id] = tracker;
782 MakeTrackerActive(tracker->tracker_id(), batch);
788 FileTracker* tracker = FindAndEraseItem(&app_root_by_app_id_, app_id);
789 tracker->set_app_id(std::string());
790 tracker->set_is_app_root(false);
792 // Inactivate the tracker to drop all descendant.
794 MakeTrackerInactive(tracker->tracker_id(), batch);
799 FileTracker* tracker = tracker_by_id_[tracker_id];
800 int64 parent_tracker_id = tracker->parent_tracker_id();
801 DCHECK(tracker->has_synced_details());
802 trackers_by_file_id_[tracker->file_id()].Activate(tracker);
805 tracker->synced_details().title()].Activate(tracker);
807 tracker->set_active(true);
808 tracker->set_needs_folder_listing(
809 tracker->synced_details().file_kind() == FILE_KIND_FOLDER);
810 tracker->set_dirty(true);
811 dirty_trackers_.insert(tracker);
813 PutTrackerToBatch(*tracker, batch);
818 FileTracker* tracker = tracker_by_id_[tracker_id];
819 trackers_by_file_id_[tracker->file_id()].Inactivate(tracker);
821 std::string title = GetTrackerTitle(*tracker);
822 int64 parent_tracker_id = tracker->parent_tracker_id();
824 trackers_by_parent_and_title_[parent_tracker_id][title].Inactivate(tracker);
825 tracker->set_active(false);
829 if (!tracker->is_app_root())
831 MarkTrackersDirtyByFileID(tracker->file_id(), batch);
834 PutTrackerToBatch(*tracker, batch);
842 scoped_ptr<FileTracker> tracker(new FileTracker);
843 tracker->set_tracker_id(tracker_id);
844 tracker->set_parent_tracker_id(parent_tracker.tracker_id());
845 tracker->set_file_id(file_id);
846 tracker->set_app_id(parent_tracker.app_id());
847 tracker->set_is_app_root(false);
848 tracker->set_dirty(true);
849 tracker->set_active(false);
850 tracker->set_needs_folder_listing(false);
851 PutTrackerToBatch(*tracker, batch);
853 trackers_by_file_id_[file_id].Insert(tracker.get());
856 // on tracker updated phase. Use empty string as the title since
859 .Insert(tracker.get());
860 dirty_trackers_.insert(tracker.get());
861 tracker_by_id_[tracker_id] = tracker.release();
867 FileTracker* tracker = FindAndEraseItem(&tracker_by_id_, tracker_id);
868 if (!tracker)
871 EraseTrackerFromFileIDIndex(tracker, batch);
872 if (tracker->is_app_root())
873 app_root_by_app_id_.erase(tracker->app_id());
874 EraseTrackerFromPathIndex(tracker);
876 MarkTrackersDirtyByFileID(tracker->file_id(), batch);
879 delete tracker;
934 void MetadataDatabase::EraseTrackerFromFileIDIndex(FileTracker* tracker,
937 trackers_by_file_id_.find(tracker->file_id());
942 trackers->Erase(tracker);
946 EraseFileFromDatabase(tracker->file_id(), batch);
958 void MetadataDatabase::EraseTrackerFromPathIndex(FileTracker* tracker) {
960 trackers_by_parent_and_title_.find(tracker->parent_tracker_id());
964 std::string title = GetTrackerTitle(*tracker);
968 conflicting_trackers->Erase(tracker);
982 FileTracker* tracker = *itr;
983 if (tracker->dirty())
985 tracker->set_dirty(true);
986 PutTrackerToBatch(*tracker, batch);
987 dirty_trackers_.insert(tracker);