| 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_DRIVE_RESOURCE_METADATA_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_RESOURCE_METADATA_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_RESOURCE_METADATA_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_RESOURCE_METADATA_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 17 #include "chrome/browser/chromeos/gdata/drive_errorcode.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace gdata { | 23 namespace gdata { |
| 24 | 24 |
| 25 struct CreateDBParams; | 25 struct CreateDBParams; |
| 26 class DocumentEntry; | 26 class DocumentEntry; |
| 27 class DriveDirectory; | 27 class DriveDirectory; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 // The resource ID for the root directory is defined in the spec: | 59 // The resource ID for the root directory is defined in the spec: |
| 60 // https://developers.google.com/google-apps/documents-list/ | 60 // https://developers.google.com/google-apps/documents-list/ |
| 61 const char kDriveRootDirectoryResourceId[] = "folder:root"; | 61 const char kDriveRootDirectoryResourceId[] = "folder:root"; |
| 62 | 62 |
| 63 // This should be incremented when incompatibility change is made in | 63 // This should be incremented when incompatibility change is made in |
| 64 // drive.proto. | 64 // drive.proto. |
| 65 const int32 kProtoVersion = 2; | 65 const int32 kProtoVersion = 2; |
| 66 | 66 |
| 67 // Callback type used to get result of file search. | 67 // Callback type used to get result of file search. |
| 68 // If |error| is not PLATFORM_FILE_OK, |entry| is set to NULL. | 68 // If |error| is not PLATFORM_FILE_OK, |entry| is set to NULL. |
| 69 typedef base::Callback<void(GDataFileError error, DriveEntry* entry)> | 69 typedef base::Callback<void(DriveFileError error, DriveEntry* entry)> |
| 70 FindEntryCallback; | 70 FindEntryCallback; |
| 71 | 71 |
| 72 // Used for file operations like removing files. | 72 // Used for file operations like removing files. |
| 73 typedef base::Callback<void(GDataFileError error)> | 73 typedef base::Callback<void(DriveFileError error)> |
| 74 FileOperationCallback; | 74 FileOperationCallback; |
| 75 | 75 |
| 76 // Callback similar to FileOperationCallback but with a given |file_path|. | 76 // Callback similar to FileOperationCallback but with a given |file_path|. |
| 77 // Used for operations that change a file path like moving files. | 77 // Used for operations that change a file path like moving files. |
| 78 typedef base::Callback<void(GDataFileError error, | 78 typedef base::Callback<void(DriveFileError error, |
| 79 const FilePath& file_path)> | 79 const FilePath& file_path)> |
| 80 FileMoveCallback; | 80 FileMoveCallback; |
| 81 | 81 |
| 82 // Used to get entry info from the file system. | 82 // Used to get entry info from the file system. |
| 83 // If |error| is not GDATA_FILE_OK, |entry_info| is set to NULL. | 83 // If |error| is not DRIVE_FILE_OK, |entry_info| is set to NULL. |
| 84 typedef base::Callback<void(GDataFileError error, | 84 typedef base::Callback<void(DriveFileError error, |
| 85 scoped_ptr<DriveEntryProto> entry_proto)> | 85 scoped_ptr<DriveEntryProto> entry_proto)> |
| 86 GetEntryInfoCallback; | 86 GetEntryInfoCallback; |
| 87 | 87 |
| 88 typedef base::Callback<void(GDataFileError error, | 88 typedef base::Callback<void(DriveFileError error, |
| 89 scoped_ptr<DriveEntryProtoVector> entries)> | 89 scoped_ptr<DriveEntryProtoVector> entries)> |
| 90 ReadDirectoryCallback; | 90 ReadDirectoryCallback; |
| 91 | 91 |
| 92 // Used to get entry info from the file system, with the Drive file path. | 92 // Used to get entry info from the file system, with the Drive file path. |
| 93 // If |error| is not GDATA_FILE_OK, |entry_proto| is set to NULL. | 93 // If |error| is not DRIVE_FILE_OK, |entry_proto| is set to NULL. |
| 94 // | 94 // |
| 95 // |drive_file_path| parameter is provided as DriveEntryProto does not contain | 95 // |drive_file_path| parameter is provided as DriveEntryProto does not contain |
| 96 // the Drive file path (i.e. only contains the base name without parent | 96 // the Drive file path (i.e. only contains the base name without parent |
| 97 // directory names). | 97 // directory names). |
| 98 typedef base::Callback<void(GDataFileError error, | 98 typedef base::Callback<void(DriveFileError error, |
| 99 const FilePath& drive_file_path, | 99 const FilePath& drive_file_path, |
| 100 scoped_ptr<DriveEntryProto> entry_proto)> | 100 scoped_ptr<DriveEntryProto> entry_proto)> |
| 101 GetEntryInfoWithFilePathCallback; | 101 GetEntryInfoWithFilePathCallback; |
| 102 | 102 |
| 103 // This is a part of EntryInfoPairResult. | 103 // This is a part of EntryInfoPairResult. |
| 104 struct EntryInfoResult { | 104 struct EntryInfoResult { |
| 105 EntryInfoResult(); | 105 EntryInfoResult(); |
| 106 ~EntryInfoResult(); | 106 ~EntryInfoResult(); |
| 107 | 107 |
| 108 FilePath path; | 108 FilePath path; |
| 109 GDataFileError error; | 109 DriveFileError error; |
| 110 scoped_ptr<DriveEntryProto> proto; | 110 scoped_ptr<DriveEntryProto> proto; |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 // The result of GetEntryInfoPairCallback(). Used to get a pair of entries | 113 // The result of GetEntryInfoPairCallback(). Used to get a pair of entries |
| 114 // in one function call. | 114 // in one function call. |
| 115 struct EntryInfoPairResult { | 115 struct EntryInfoPairResult { |
| 116 EntryInfoPairResult(); | 116 EntryInfoPairResult(); |
| 117 ~EntryInfoPairResult(); | 117 ~EntryInfoPairResult(); |
| 118 | 118 |
| 119 EntryInfoResult first; | 119 EntryInfoResult first; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 scoped_ptr<DriveEntry> FromProtoString( | 276 scoped_ptr<DriveEntry> FromProtoString( |
| 277 const std::string& serialized_proto); | 277 const std::string& serialized_proto); |
| 278 | 278 |
| 279 // Continues with GetEntryInfoPairByPaths after the first DriveEntry has been | 279 // Continues with GetEntryInfoPairByPaths after the first DriveEntry has been |
| 280 // asynchronously fetched. This fetches the second DriveEntry only if the | 280 // asynchronously fetched. This fetches the second DriveEntry only if the |
| 281 // first was found. | 281 // first was found. |
| 282 void GetEntryInfoPairByPathsAfterGetFirst( | 282 void GetEntryInfoPairByPathsAfterGetFirst( |
| 283 const FilePath& first_path, | 283 const FilePath& first_path, |
| 284 const FilePath& second_path, | 284 const FilePath& second_path, |
| 285 const GetEntryInfoPairCallback& callback, | 285 const GetEntryInfoPairCallback& callback, |
| 286 GDataFileError error, | 286 DriveFileError error, |
| 287 scoped_ptr<DriveEntryProto> entry_proto); | 287 scoped_ptr<DriveEntryProto> entry_proto); |
| 288 | 288 |
| 289 // Continues with GetIntroInfoPairByPaths after the second DriveEntry has been | 289 // Continues with GetIntroInfoPairByPaths after the second DriveEntry has been |
| 290 // asynchronously fetched. | 290 // asynchronously fetched. |
| 291 void GetEntryInfoPairByPathsAfterGetSecond( | 291 void GetEntryInfoPairByPathsAfterGetSecond( |
| 292 const FilePath& second_path, | 292 const FilePath& second_path, |
| 293 const GetEntryInfoPairCallback& callback, | 293 const GetEntryInfoPairCallback& callback, |
| 294 scoped_ptr<EntryInfoPairResult> result, | 294 scoped_ptr<EntryInfoPairResult> result, |
| 295 GDataFileError error, | 295 DriveFileError error, |
| 296 scoped_ptr<DriveEntryProto> entry_proto); | 296 scoped_ptr<DriveEntryProto> entry_proto); |
| 297 | 297 |
| 298 // These internal functions need friend access to private DriveDirectory | 298 // These internal functions need friend access to private DriveDirectory |
| 299 // methods. | 299 // methods. |
| 300 // Replaces file entry |old_entry| with its fresh value |fresh_file|. | 300 // Replaces file entry |old_entry| with its fresh value |fresh_file|. |
| 301 static void RefreshFileInternal(scoped_ptr<DriveFile> fresh_file, | 301 static void RefreshFileInternal(scoped_ptr<DriveFile> fresh_file, |
| 302 DriveEntry* old_entry); | 302 DriveEntry* old_entry); |
| 303 | 303 |
| 304 // Removes all child files of |directory| and replace with file_map. | 304 // Removes all child files of |directory| and replace with file_map. |
| 305 // |callback| may not be null. | 305 // |callback| may not be null. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 323 // This should remain the last member so it'll be destroyed first and | 323 // This should remain the last member so it'll be destroyed first and |
| 324 // invalidate its weak pointers before other members are destroyed. | 324 // invalidate its weak pointers before other members are destroyed. |
| 325 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; | 325 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; |
| 326 | 326 |
| 327 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); | 327 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 } // namespace gdata | 330 } // namespace gdata |
| 331 | 331 |
| 332 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_RESOURCE_METADATA_H_ | 332 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_RESOURCE_METADATA_H_ |
| OLD | NEW |