OLD | NEW |
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_GDATA_GDATA_FILES_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // The root directory name used for the Google Drive file system tree. The | 61 // The root directory name used for the Google Drive file system tree. The |
62 // name is used in URLs for the file manager, hence user-visible. | 62 // name is used in URLs for the file manager, hence user-visible. |
63 const FilePath::CharType kGDataRootDirectory[] = FILE_PATH_LITERAL("drive"); | 63 const FilePath::CharType kGDataRootDirectory[] = FILE_PATH_LITERAL("drive"); |
64 | 64 |
65 // The resource ID for the root directory is defined in the spec: | 65 // The resource ID for the root directory is defined in the spec: |
66 // https://developers.google.com/google-apps/documents-list/ | 66 // https://developers.google.com/google-apps/documents-list/ |
67 const char kGDataRootDirectoryResourceId[] = "folder:root"; | 67 const char kGDataRootDirectoryResourceId[] = "folder:root"; |
68 | 68 |
69 // This should be incremented when incompatibility change is made in | 69 // This should be incremented when incompatibility change is made in |
70 // gdata.proto. | 70 // gdata.proto. |
71 const int32 kProtoVersion = 1; | 71 const int32 kProtoVersion = 2; |
72 | 72 |
73 // Used for file operations like removing files. | 73 // Used for file operations like removing files. |
74 typedef base::Callback<void(GDataFileError error)> | 74 typedef base::Callback<void(GDataFileError error)> |
75 FileOperationCallback; | 75 FileOperationCallback; |
76 | 76 |
77 // Callback similar to FileOperationCallback but with a given |file_path|. | 77 // Callback similar to FileOperationCallback but with a given |file_path|. |
78 // Used for operations that change a file path like moving files. | 78 // Used for operations that change a file path like moving files. |
79 typedef base::Callback<void(GDataFileError error, | 79 typedef base::Callback<void(GDataFileError error, |
80 const FilePath& file_path)> | 80 const FilePath& file_path)> |
81 FileMoveCallback; | 81 FileMoveCallback; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 399 |
400 // Last time when we dumped serialized file system to disk. | 400 // Last time when we dumped serialized file system to disk. |
401 const base::Time& last_serialized() const { return last_serialized_; } | 401 const base::Time& last_serialized() const { return last_serialized_; } |
402 void set_last_serialized(const base::Time& time) { last_serialized_ = time; } | 402 void set_last_serialized(const base::Time& time) { last_serialized_ = time; } |
403 // Size of serialized file system on disk in bytes. | 403 // Size of serialized file system on disk in bytes. |
404 const size_t serialized_size() const { return serialized_size_; } | 404 const size_t serialized_size() const { return serialized_size_; } |
405 void set_serialized_size(size_t size) { serialized_size_ = size; } | 405 void set_serialized_size(size_t size) { serialized_size_ = size; } |
406 | 406 |
407 // Largest change timestamp that was the source of content for the current | 407 // Largest change timestamp that was the source of content for the current |
408 // state of the root directory. | 408 // state of the root directory. |
409 const int largest_changestamp() const { return largest_changestamp_; } | 409 const int64 largest_changestamp() const { return largest_changestamp_; } |
410 void set_largest_changestamp(int value) { largest_changestamp_ = value; } | 410 void set_largest_changestamp(int64 value) { largest_changestamp_ = value; } |
411 | 411 |
412 // The root directory content origin. | 412 // The root directory content origin. |
413 const ContentOrigin origin() const { return origin_; } | 413 const ContentOrigin origin() const { return origin_; } |
414 void set_origin(ContentOrigin value) { origin_ = value; } | 414 void set_origin(ContentOrigin value) { origin_ = value; } |
415 | 415 |
| 416 // Sets root directory resource id and initialize the root entry. |
| 417 void InitializeRootEntry(const std::string& root_id); |
| 418 |
416 // Move |entry| to |directory_path| asynchronously. Removes entry from | 419 // Move |entry| to |directory_path| asynchronously. Removes entry from |
417 // previous parent. Must be called on UI thread. |callback| is called on the | 420 // previous parent. Must be called on UI thread. |callback| is called on the |
418 // UI thread. | 421 // UI thread. |
419 void MoveEntryToDirectory(const FilePath& directory_path, | 422 void MoveEntryToDirectory(const FilePath& directory_path, |
420 GDataEntry* entry, | 423 GDataEntry* entry, |
421 const FileMoveCallback& callback); | 424 const FileMoveCallback& callback); |
422 | 425 |
423 // Adds the entry to resource map. | 426 // Adds the entry to resource map. |
424 void AddEntryToResourceMap(GDataEntry* entry); | 427 void AddEntryToResourceMap(GDataEntry* entry); |
425 | 428 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 // Private data members. | 523 // Private data members. |
521 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 524 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
522 scoped_ptr<ResourceMetadataDB> directory_service_db_; | 525 scoped_ptr<ResourceMetadataDB> directory_service_db_; |
523 | 526 |
524 ResourceMap resource_map_; | 527 ResourceMap resource_map_; |
525 | 528 |
526 scoped_ptr<GDataDirectory> root_; // Stored in the serialized proto. | 529 scoped_ptr<GDataDirectory> root_; // Stored in the serialized proto. |
527 | 530 |
528 base::Time last_serialized_; | 531 base::Time last_serialized_; |
529 size_t serialized_size_; | 532 size_t serialized_size_; |
530 int largest_changestamp_; // Stored in the serialized proto. | 533 int64 largest_changestamp_; // Stored in the serialized proto. |
531 ContentOrigin origin_; | 534 ContentOrigin origin_; |
532 | 535 |
533 // This should remain the last member so it'll be destroyed first and | 536 // This should remain the last member so it'll be destroyed first and |
534 // invalidate its weak pointers before other members are destroyed. | 537 // invalidate its weak pointers before other members are destroyed. |
535 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; | 538 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; |
536 | 539 |
537 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); | 540 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); |
538 }; | 541 }; |
539 | 542 |
540 } // namespace gdata | 543 } // namespace gdata |
541 | 544 |
542 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ | 545 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
OLD | NEW |