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

Side by Side Diff: chrome/browser/chromeos/drive/drive_resource_metadata_storage.h

Issue 14108009: chromeos: Use WriteBatch to update DriveResourceMetadata DB (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_STORAGE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_STORAGE_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_STORAGE_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_STORAGE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 27 matching lines...) Expand all
38 // Initializes this object. 38 // Initializes this object.
39 bool Initialize(); 39 bool Initialize();
40 40
41 // Sets the largest changestamp. 41 // Sets the largest changestamp.
42 void SetLargestChangestamp(int64 largest_changestamp); 42 void SetLargestChangestamp(int64 largest_changestamp);
43 43
44 // Gets the largest changestamp. 44 // Gets the largest changestamp.
45 int64 GetLargestChangestamp(); 45 int64 GetLargestChangestamp();
46 46
47 // Puts the entry to this storage. 47 // Puts the entry to this storage.
48 void PutEntry(const DriveEntryProto& entry); 48 bool PutEntry(const DriveEntryProto& entry);
49 49
50 // Returns an entry stored in this storage. 50 // Returns an entry stored in this storage.
51 scoped_ptr<DriveEntryProto> GetEntry(const std::string& resource_id); 51 scoped_ptr<DriveEntryProto> GetEntry(const std::string& resource_id);
52 52
53 // Removes an entry from this storage. 53 // Removes an entry from this storage.
54 void RemoveEntry(const std::string& resource_id); 54 bool RemoveEntry(const std::string& resource_id);
55 55
56 // Iterates over entries stored in this storage. 56 // Iterates over entries stored in this storage.
57 void Iterate(const IterateCallback& callback); 57 void Iterate(const IterateCallback& callback);
58 58
59 // Puts child under the parent.
60 void PutChild(const std::string& parent_resource_id,
61 const std::string& child_name,
62 const std::string& child_resource_id);
63
64 // Returns resource ID of the parent's child. 59 // Returns resource ID of the parent's child.
65 std::string GetChild(const std::string& parent_resource_id, 60 std::string GetChild(const std::string& parent_resource_id,
66 const std::string& child_name); 61 const std::string& child_name);
67 62
68 // Returns resource IDs of the parent's children. 63 // Returns resource IDs of the parent's children.
69 void GetChildren(const std::string& parent_resource_id, 64 void GetChildren(const std::string& parent_resource_id,
70 std::vector<std::string>* children); 65 std::vector<std::string>* children);
71 66
72 // Removes child from the parent.
73 void RemoveChild(const std::string& parent_resource_id,
74 const std::string& child_name);
75
76 private: 67 private:
77 friend class DriveResourceMetadataStorageTest; 68 friend class DriveResourceMetadataStorageTest;
78 69
70 // Returns a string to be used as a key for child entry.
71 static std::string GetChildEntryKey(const std::string& parent_resource_id,
72 const std::string& child_name);
73
79 // Puts header. 74 // Puts header.
80 void PutHeader(const DriveResourceMetadataHeader& header); 75 void PutHeader(const DriveResourceMetadataHeader& header);
81 76
82 // Gets header. 77 // Gets header.
83 scoped_ptr<DriveResourceMetadataHeader> GetHeader(); 78 scoped_ptr<DriveResourceMetadataHeader> GetHeader();
84 79
85 // Checks validity of the data. 80 // Checks validity of the data.
86 bool CheckValidity(); 81 bool CheckValidity();
87 82
88 // Path to the directory where the data is stored. 83 // Path to the directory where the data is stored.
89 base::FilePath directory_path_; 84 base::FilePath directory_path_;
90 85
91 // Entries stored in this storage. 86 // Entries stored in this storage.
92 scoped_ptr<leveldb::DB> resource_map_; 87 scoped_ptr<leveldb::DB> resource_map_;
93 88
94 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadataStorage); 89 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadataStorage);
95 }; 90 };
96 91
97 } // namespace drive 92 } // namespace drive
98 93
99 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_STORAGE_H_ 94 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698