File: metadata_database_index_interface.h

package info (click to toggle)
chromium-browser 41.0.2272.118-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,189,132 kB
  • sloc: cpp: 9,691,462; ansic: 3,341,451; python: 712,689; asm: 518,779; xml: 208,926; java: 169,820; sh: 119,353; perl: 68,907; makefile: 28,311; yacc: 13,305; objc: 11,385; tcl: 3,186; cs: 2,225; sql: 2,217; lex: 2,215; lisp: 1,349; pascal: 1,256; awk: 407; ruby: 155; sed: 53; php: 14; exp: 11
file content (122 lines) | stat: -rw-r--r-- 4,613 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_INTERFACE_H_
#define CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_INTERFACE_H_

#include <string>
#include <vector>

#include "base/memory/scoped_ptr.h"

namespace sync_file_system {
namespace drive_backend {

class FileMetadata;
class FileTracker;
class TrackerIDSet;

struct ParentIDAndTitle {
  int64 parent_id;
  std::string title;

  ParentIDAndTitle();
  ParentIDAndTitle(int64 parent_id, const std::string& title);
};

bool operator==(const ParentIDAndTitle& left, const ParentIDAndTitle& right);
bool operator<(const ParentIDAndTitle& left, const ParentIDAndTitle& right);

// Interface class to maintain indexes of MetadataDatabase.
class MetadataDatabaseIndexInterface {
 public:
  MetadataDatabaseIndexInterface() {}
  virtual ~MetadataDatabaseIndexInterface() {}

  // Returns true if FileMetadata identified by |file_id| exists.
  // If |metadata| is not NULL, the FileMetadata is copied to it.
  virtual bool GetFileMetadata(
      const std::string& file_id, FileMetadata* metadata) const = 0;

  // Returns true if FileTracker identified by |tracker_id| exists.
  // If |tracker| is not NULL, the FileTracker is copied to it.
  virtual bool GetFileTracker(
      int64 tracker_id, FileTracker* tracker) const = 0;

  // Stores |metadata| and updates indexes.
  // This overwrites existing FileMetadata for the same |file_id|.
  virtual void StoreFileMetadata(scoped_ptr<FileMetadata> metadata) = 0;

  // Stores |tracker| and updates indexes.
  // This overwrites existing FileTracker for the same |tracker_id|.
  virtual void StoreFileTracker(scoped_ptr<FileTracker> tracker) = 0;

  // Removes FileMetadata identified by |file_id| from indexes.
  virtual void RemoveFileMetadata(const std::string& file_id) = 0;

  // Removes FileTracker identified by |tracker_id| from indexes.
  virtual void RemoveFileTracker(int64 tracker_id) = 0;

  // Returns a set of FileTracker that have |file_id| as its own.
  virtual TrackerIDSet GetFileTrackerIDsByFileID(
      const std::string& file_id) const = 0;

  // Returns an app-root tracker identified by |app_id|.  Returns 0 if not
  // found.
  virtual int64 GetAppRootTracker(const std::string& app_id) const = 0;

  // Returns a set of FileTracker that have |parent_tracker_id| and |title|.
  virtual TrackerIDSet GetFileTrackerIDsByParentAndTitle(
      int64 parent_tracker_id,
      const std::string& title) const = 0;

  virtual std::vector<int64> GetFileTrackerIDsByParent(
      int64 parent_tracker_id) const = 0;

  // Returns the |file_id| of a file that has multiple trackers.
  virtual std::string PickMultiTrackerFileID() const = 0;

  // Returns a pair of |parent_tracker_id| and |title| that has multiple file
  // at the path.
  virtual ParentIDAndTitle PickMultiBackingFilePath() const = 0;

  // Returns a FileTracker whose |dirty| is set and which isn't demoted.
  // Returns 0 if not found.
  virtual int64 PickDirtyTracker() const = 0;

  // Demotes a dirty tracker.
  virtual void DemoteDirtyTracker(int64 tracker_id) = 0;

  virtual bool HasDemotedDirtyTracker() const = 0;
  virtual bool IsDemotedDirtyTracker(int64 tracker_id) const = 0;

  // Promotes single demoted dirty tracker to a normal dirty tracker.
  virtual void PromoteDemotedDirtyTracker(int64 tracker_id) = 0;

  // Promotes all demoted dirty trackers to normal dirty trackers.
  // Returns true if any tracker was promoted.
  virtual bool PromoteDemotedDirtyTrackers() = 0;

  virtual size_t CountDirtyTracker() const = 0;
  virtual size_t CountFileMetadata() const = 0;
  virtual size_t CountFileTracker() const = 0;

  virtual void SetSyncRootTrackerID(int64 sync_root_id) const = 0;
  virtual void SetLargestChangeID(int64 largest_change_id) const = 0;
  virtual void SetNextTrackerID(int64 next_tracker_id) const = 0;
  virtual int64 GetSyncRootTrackerID() const = 0;
  virtual int64 GetLargestChangeID() const = 0;
  virtual int64 GetNextTrackerID() const = 0;
  virtual std::vector<std::string> GetRegisteredAppIDs() const = 0;
  virtual std::vector<int64> GetAllTrackerIDs() const = 0;
  virtual std::vector<std::string> GetAllMetadataIDs() const = 0;

 private:
  DISALLOW_COPY_AND_ASSIGN(MetadataDatabaseIndexInterface);
};

}  // namespace drive_backend
}  // namespace sync_file_system

#endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_DRIVE_BACKEND_METADATA_DATABASE_INDEX_INTERFACE_H_