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

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

Issue 12673003: chromeos: Remove unused DB related code from DriveResourceMetadata (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/time.h" 17 #include "base/time.h"
18 #include "chrome/browser/chromeos/drive/drive_file_error.h" 18 #include "chrome/browser/chromeos/drive/drive_file_error.h"
19 19
20 namespace base { 20 namespace base {
21 class SequencedTaskRunner; 21 class SequencedTaskRunner;
22 } 22 }
23 23
24 namespace google_apis { 24 namespace google_apis {
25 class ResourceEntry; 25 class ResourceEntry;
26 } 26 }
27 27
28 namespace drive { 28 namespace drive {
29 29
30 struct CreateDBParams;
31 class DriveDirectory; 30 class DriveDirectory;
32 class DriveEntry; 31 class DriveEntry;
33 class DriveEntryProto; 32 class DriveEntryProto;
34 class ResourceMetadataDB;
35 33
36 typedef std::vector<DriveEntryProto> DriveEntryProtoVector; 34 typedef std::vector<DriveEntryProto> DriveEntryProtoVector;
37 typedef std::map<std::string /* resource_id */, DriveEntryProto> 35 typedef std::map<std::string /* resource_id */, DriveEntryProto>
38 DriveEntryProtoMap; 36 DriveEntryProtoMap;
39 37
40 // File type on the drive file system can be either a regular file or 38 // File type on the drive file system can be either a regular file or
41 // a hosted document. 39 // a hosted document.
42 enum DriveFileType { 40 enum DriveFileType {
43 REGULAR_FILE, 41 REGULAR_FILE,
44 HOSTED_DOCUMENT, 42 HOSTED_DOCUMENT,
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 const FileMoveCallback& callback) OVERRIDE; 254 const FileMoveCallback& callback) OVERRIDE;
257 virtual void GetChildDirectories( 255 virtual void GetChildDirectories(
258 const std::string& resource_id, 256 const std::string& resource_id,
259 const GetChildDirectoriesCallback& changed_dirs_callback) OVERRIDE; 257 const GetChildDirectoriesCallback& changed_dirs_callback) OVERRIDE;
260 virtual void RemoveAll(const base::Closure& callback) OVERRIDE; 258 virtual void RemoveAll(const base::Closure& callback) OVERRIDE;
261 259
262 // Serializes/Parses to/from string via proto classes. 260 // Serializes/Parses to/from string via proto classes.
263 void SerializeToString(std::string* serialized_proto) const; 261 void SerializeToString(std::string* serialized_proto) const;
264 bool ParseFromString(const std::string& serialized_proto); 262 bool ParseFromString(const std::string& serialized_proto);
265 263
266 // Restores from and saves to database, calling |callback| asynchronously.
267 // |callback| must not be null.
268 void InitFromDB(const base::FilePath& db_path,
269 base::SequencedTaskRunner* blocking_task_runner,
270 const FileOperationCallback& callback);
271 void SaveToDB();
272
273 // TODO(achuith): Remove all DriveEntry based methods. crbug.com/127856. 264 // TODO(achuith): Remove all DriveEntry based methods. crbug.com/127856.
274 // Creates DriveEntry from proto. 265 // Creates DriveEntry from proto.
275 scoped_ptr<DriveEntry> CreateDriveEntryFromProto( 266 scoped_ptr<DriveEntry> CreateDriveEntryFromProto(
276 const DriveEntryProto& entry_proto); 267 const DriveEntryProto& entry_proto);
277 268
278 // Creates a DriveEntry instance. 269 // Creates a DriveEntry instance.
279 scoped_ptr<DriveEntry> CreateDriveEntry(); 270 scoped_ptr<DriveEntry> CreateDriveEntry();
280 271
281 // Creates a DriveDirectory instance. 272 // Creates a DriveDirectory instance.
282 scoped_ptr<DriveDirectory> CreateDriveDirectory(); 273 scoped_ptr<DriveDirectory> CreateDriveDirectory();
283 274
284 // Adds the entry to resource map. Returns false if an entry with the same 275 // Adds the entry to resource map. Returns false if an entry with the same
285 // resource_id exists. 276 // resource_id exists.
286 bool AddEntryToResourceMap(DriveEntry* entry); 277 bool AddEntryToResourceMap(DriveEntry* entry);
287 278
288 // Removes the entry from resource map. 279 // Removes the entry from resource map.
289 void RemoveEntryFromResourceMap(const std::string& resource_id); 280 void RemoveEntryFromResourceMap(const std::string& resource_id);
290 281
291 // Returns the DriveEntry* with the corresponding |resource_id|. 282 // Returns the DriveEntry* with the corresponding |resource_id|.
292 // TODO(satorux): Remove this in favor of GetEntryInfoByResourceId() 283 // TODO(satorux): Remove this in favor of GetEntryInfoByResourceId()
293 // but can be difficult. See crbug.com/137374 284 // but can be difficult. See crbug.com/137374
294 DriveEntry* GetEntryByResourceId(const std::string& resource_id); 285 DriveEntry* GetEntryByResourceId(const std::string& resource_id);
295 286
296 private: 287 private:
297 // Initializes the resource map using serialized_resources fetched from the
298 // database.
299 // |callback| must not be null.
300 void InitResourceMap(CreateDBParams* create_params,
301 const FileOperationCallback& callback);
302
303 // Clears root_ and the resource map. 288 // Clears root_ and the resource map.
304 void ClearRoot(); 289 void ClearRoot();
305 290
306 // Creates DriveEntry from serialized string. 291 // Creates DriveEntry from serialized string.
307 scoped_ptr<DriveEntry> CreateDriveEntryFromProtoString( 292 scoped_ptr<DriveEntry> CreateDriveEntryFromProtoString(
308 const std::string& serialized_proto); 293 const std::string& serialized_proto);
309 294
310 // Continues with GetEntryInfoPairByPaths after the first DriveEntry has been 295 // Continues with GetEntryInfoPairByPaths after the first DriveEntry has been
311 // asynchronously fetched. This fetches the second DriveEntry only if the 296 // asynchronously fetched. This fetches the second DriveEntry only if the
312 // first was found. 297 // first was found.
(...skipping 17 matching lines...) Expand all
330 DriveEntry* FindEntryByPathSync(const base::FilePath& file_path); 315 DriveEntry* FindEntryByPathSync(const base::FilePath& file_path);
331 316
332 // Helper function to get a parent directory given |parent_resource_id|. 317 // Helper function to get a parent directory given |parent_resource_id|.
333 // Returns root if |parent_resource_id| is empty. Returns NULL if 318 // Returns root if |parent_resource_id| is empty. Returns NULL if
334 // |parent_resource_id| is not empty and the corresponding entry is not a 319 // |parent_resource_id| is not empty and the corresponding entry is not a
335 // directory. 320 // directory.
336 DriveDirectory* GetParent(const std::string& parent_resource_id); 321 DriveDirectory* GetParent(const std::string& parent_resource_id);
337 322
338 // Private data members. 323 // Private data members.
339 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 324 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
340 scoped_ptr<ResourceMetadataDB> resource_metadata_db_;
341 325
342 ResourceMap resource_map_; 326 ResourceMap resource_map_;
343 327
344 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto. 328 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto.
345 329
346 base::Time last_serialized_; 330 base::Time last_serialized_;
347 size_t serialized_size_; 331 size_t serialized_size_;
348 int64 largest_changestamp_; // Stored in the serialized proto. 332 int64 largest_changestamp_; // Stored in the serialized proto.
349 bool loaded_; 333 bool loaded_;
350 334
351 // This should remain the last member so it'll be destroyed first and 335 // This should remain the last member so it'll be destroyed first and
352 // invalidate its weak pointers before other members are destroyed. 336 // invalidate its weak pointers before other members are destroyed.
353 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; 337 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_;
354 338
355 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); 339 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata);
356 }; 340 };
357 341
358 } // namespace drive 342 } // namespace drive
359 343
360 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ 344 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/change_list_loader.cc ('k') | chrome/browser/chromeos/drive/drive_resource_metadata.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698