Home | History | Annotate | Download | only in drive_backend
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TRACKER_SET_H_
      6 #define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TRACKER_SET_H_
      7 
      8 #include <set>
      9 
     10 #include "base/basictypes.h"
     11 
     12 namespace sync_file_system {
     13 namespace drive_backend {
     14 
     15 class FileTracker;
     16 
     17 class TrackerSet {
     18  public:
     19   struct TrackerComparator {
     20     bool operator()(const FileTracker* left,
     21                     const FileTracker* right) const;
     22   };
     23 
     24   typedef std::set<FileTracker*, TrackerComparator> RawTrackerSet;
     25   typedef RawTrackerSet::iterator iterator;
     26   typedef RawTrackerSet::const_iterator const_iterator;
     27 
     28   TrackerSet();
     29   ~TrackerSet();
     30 
     31   bool has_active() const { return !!active_tracker_; }
     32   void Insert(FileTracker* tracker);
     33   void Erase(FileTracker* tracker);
     34   void Activate(FileTracker* tracker);
     35   void Inactivate(FileTracker* tracker);
     36 
     37   const FileTracker* active_tracker() const { return active_tracker_; }
     38   FileTracker* active_tracker() { return active_tracker_; }
     39   const RawTrackerSet& tracker_set() const { return tracker_set_; }
     40 
     41   iterator begin() { return tracker_set_.begin(); }
     42   iterator end() { return tracker_set_.end(); }
     43   const_iterator begin() const { return tracker_set_.begin(); }
     44   const_iterator end() const { return tracker_set_.end(); }
     45   bool empty() const { return tracker_set_.empty(); }
     46   size_t size() const { return tracker_set_.size(); }
     47 
     48  private:
     49   FileTracker* active_tracker_;
     50   RawTrackerSet tracker_set_;
     51 };
     52 
     53 }  // namespace drive_backend
     54 }  // namespace sync_file_system
     55 
     56 #endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_TRACKER_SET_H_
     57