Chromium Code Reviews| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 = 1; |
| 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 // Used to get entry info from the file system. | |
| 78 // If |error| is not PLATFORM_FILE_OK, |entry_info| is set to NULL. | |
| 79 typedef base::Callback<void(GDataFileError error, | |
| 80 scoped_ptr<GDataEntryProto> entry_proto)> | |
| 81 GetEntryInfoCallback; | |
| 82 | |
| 83 // Used to read a directory from the file system. | |
| 84 // If |error| is not PLATFORM_FILE_OK, |entries| is set to NULL. | |
|
achuithb
2012/08/07 20:46:07
Isn't the error GDATA_FILE_OK?
satorux1
2012/08/07 21:13:20
Done.
| |
| 85 // |entries| are contents, both files and directories, of the directory. | |
| 86 typedef std::vector<GDataEntryProto> GDataEntryProtoVector; | |
| 87 typedef base::Callback<void(GDataFileError error, | |
| 88 scoped_ptr<GDataEntryProtoVector> entries)> | |
| 89 ReadDirectoryCallback; | |
| 77 // Base class for representing files and directories in gdata virtual file | 90 // Base class for representing files and directories in gdata virtual file |
| 78 // system. | 91 // system. |
| 79 class GDataEntry { | 92 class GDataEntry { |
| 80 public: | 93 public: |
| 81 GDataEntry(GDataDirectory* parent, GDataDirectoryService* directory_service); | 94 GDataEntry(GDataDirectory* parent, GDataDirectoryService* directory_service); |
| 82 virtual ~GDataEntry(); | 95 virtual ~GDataEntry(); |
| 83 | 96 |
| 84 virtual GDataFile* AsGDataFile(); | 97 virtual GDataFile* AsGDataFile(); |
| 85 virtual GDataDirectory* AsGDataDirectory(); | 98 virtual GDataDirectory* AsGDataDirectory(); |
| 86 | 99 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 | 406 |
| 394 // Returns the GDataEntry* with the corresponding |resource_id|. | 407 // Returns the GDataEntry* with the corresponding |resource_id|. |
| 395 // TODO(achuith): Get rid of this in favor of async version crbug.com/13957. | 408 // TODO(achuith): Get rid of this in favor of async version crbug.com/13957. |
| 396 GDataEntry* GetEntryByResourceId(const std::string& resource_id); | 409 GDataEntry* GetEntryByResourceId(const std::string& resource_id); |
| 397 | 410 |
| 398 // Returns the GDataEntry* in the callback with the corresponding | 411 // Returns the GDataEntry* in the callback with the corresponding |
| 399 // |resource_id|. TODO(achuith): Rename this to GetEntryByResourceId. | 412 // |resource_id|. TODO(achuith): Rename this to GetEntryByResourceId. |
| 400 void GetEntryByResourceIdAsync(const std::string& resource_id, | 413 void GetEntryByResourceIdAsync(const std::string& resource_id, |
| 401 const GetEntryByResourceIdCallback& callback); | 414 const GetEntryByResourceIdCallback& callback); |
| 402 | 415 |
| 416 // Finds an entry (a file or a directory) by |file_path|. | |
| 417 // | |
| 418 // Must be called from UI thread. |callback| is run on UI thread. | |
| 419 void GetEntryInfoByPath(const FilePath& file_path, | |
| 420 const GetEntryInfoCallback& callback); | |
|
achuithb
2012/08/07 20:46:07
indentation.
satorux1
2012/08/07 21:13:20
Done.
| |
| 421 | |
| 422 // Finds and reads a directory by |file_path|. | |
| 423 // | |
| 424 // Must be called from UI thread. |callback| is run on UI thread. | |
| 425 void ReadDirectoryByPath(const FilePath& file_path, | |
| 426 const ReadDirectoryCallback& callback); | |
| 427 | |
| 403 // Replaces file entry with the same resource id as |fresh_file| with its | 428 // Replaces file entry with the same resource id as |fresh_file| with its |
| 404 // fresh value |fresh_file|. | 429 // fresh value |fresh_file|. |
| 405 void RefreshFile(scoped_ptr<GDataFile> fresh_file); | 430 void RefreshFile(scoped_ptr<GDataFile> fresh_file); |
| 406 | 431 |
| 407 // Replaces file entry |old_entry| with its fresh value |fresh_file|. | 432 // Replaces file entry |old_entry| with its fresh value |fresh_file|. |
| 408 static void RefreshFileInternal(scoped_ptr<GDataFile> fresh_file, | 433 static void RefreshFileInternal(scoped_ptr<GDataFile> fresh_file, |
| 409 GDataEntry* old_entry); | 434 GDataEntry* old_entry); |
| 410 | 435 |
| 411 // Serializes/Parses to/from string via proto classes. | 436 // Serializes/Parses to/from string via proto classes. |
| 412 void SerializeToString(std::string* serialized_proto) const; | 437 void SerializeToString(std::string* serialized_proto) const; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 // This should remain the last member so it'll be destroyed first and | 475 // This should remain the last member so it'll be destroyed first and |
| 451 // invalidate its weak pointers before other members are destroyed. | 476 // invalidate its weak pointers before other members are destroyed. |
| 452 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; | 477 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; |
| 453 | 478 |
| 454 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); | 479 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); |
| 455 }; | 480 }; |
| 456 | 481 |
| 457 } // namespace gdata | 482 } // namespace gdata |
| 458 | 483 |
| 459 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ | 484 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
| OLD | NEW |