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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_files.h

Issue 10837148: gdata: Add GetEntryInfoByPath() and ReadDirectoryByPath() to GDataDirectoryService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 4 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_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
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 GDATA_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 GDATA_FILE_OK, |entries| is set to NULL.
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;
90
77 // Base class for representing files and directories in gdata virtual file 91 // Base class for representing files and directories in gdata virtual file
78 // system. 92 // system.
79 class GDataEntry { 93 class GDataEntry {
80 public: 94 public:
81 GDataEntry(GDataDirectory* parent, GDataDirectoryService* directory_service); 95 GDataEntry(GDataDirectory* parent, GDataDirectoryService* directory_service);
82 virtual ~GDataEntry(); 96 virtual ~GDataEntry();
83 97
84 virtual GDataFile* AsGDataFile(); 98 virtual GDataFile* AsGDataFile();
85 virtual GDataDirectory* AsGDataDirectory(); 99 virtual GDataDirectory* AsGDataDirectory();
86 100
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // Converts DocumentEntry into GDataEntry. 288 // Converts DocumentEntry into GDataEntry.
275 static GDataEntry* FromDocumentEntry( 289 static GDataEntry* FromDocumentEntry(
276 GDataDirectory* parent, 290 GDataDirectory* parent,
277 DocumentEntry* doc, 291 DocumentEntry* doc,
278 GDataDirectoryService* directory_service); 292 GDataDirectoryService* directory_service);
279 293
280 // Converts to/from proto. 294 // Converts to/from proto.
281 bool FromProto(const GDataDirectoryProto& proto) WARN_UNUSED_RESULT; 295 bool FromProto(const GDataDirectoryProto& proto) WARN_UNUSED_RESULT;
282 void ToProto(GDataDirectoryProto* proto) const; 296 void ToProto(GDataDirectoryProto* proto) const;
283 297
298 // Converts the children as a vector of GDataEntryProto.
299 scoped_ptr<GDataEntryProtoVector> ToProtoVector() const;
300
284 // Removes child elements. 301 // Removes child elements.
285 void RemoveChildren(); 302 void RemoveChildren();
286 void RemoveChildFiles(); 303 void RemoveChildFiles();
287 void RemoveChildDirectories(); 304 void RemoveChildDirectories();
288 305
289 // Collection of children files/directories. 306 // Collection of children files/directories.
290 const GDataFileCollection& child_files() const { return child_files_; } 307 const GDataFileCollection& child_files() const { return child_files_; }
291 const GDataDirectoryCollection& child_directories() const { 308 const GDataDirectoryCollection& child_directories() const {
292 return child_directories_; 309 return child_directories_;
293 } 310 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 410
394 // Returns the GDataEntry* with the corresponding |resource_id|. 411 // Returns the GDataEntry* with the corresponding |resource_id|.
395 // TODO(achuith): Get rid of this in favor of async version crbug.com/13957. 412 // TODO(achuith): Get rid of this in favor of async version crbug.com/13957.
396 GDataEntry* GetEntryByResourceId(const std::string& resource_id); 413 GDataEntry* GetEntryByResourceId(const std::string& resource_id);
397 414
398 // Returns the GDataEntry* in the callback with the corresponding 415 // Returns the GDataEntry* in the callback with the corresponding
399 // |resource_id|. TODO(achuith): Rename this to GetEntryByResourceId. 416 // |resource_id|. TODO(achuith): Rename this to GetEntryByResourceId.
400 void GetEntryByResourceIdAsync(const std::string& resource_id, 417 void GetEntryByResourceIdAsync(const std::string& resource_id,
401 const GetEntryByResourceIdCallback& callback); 418 const GetEntryByResourceIdCallback& callback);
402 419
420 // Finds an entry (a file or a directory) by |file_path|.
421 //
422 // Must be called from UI thread. |callback| is run on UI thread.
423 void GetEntryInfoByPath(const FilePath& file_path,
424 const GetEntryInfoCallback& callback);
425
426 // Finds and reads a directory by |file_path|.
427 //
428 // Must be called from UI thread. |callback| is run on UI thread.
429 void ReadDirectoryByPath(const FilePath& file_path,
430 const ReadDirectoryCallback& callback);
431
403 // Replaces file entry with the same resource id as |fresh_file| with its 432 // Replaces file entry with the same resource id as |fresh_file| with its
404 // fresh value |fresh_file|. 433 // fresh value |fresh_file|.
405 void RefreshFile(scoped_ptr<GDataFile> fresh_file); 434 void RefreshFile(scoped_ptr<GDataFile> fresh_file);
406 435
407 // Replaces file entry |old_entry| with its fresh value |fresh_file|. 436 // Replaces file entry |old_entry| with its fresh value |fresh_file|.
408 static void RefreshFileInternal(scoped_ptr<GDataFile> fresh_file, 437 static void RefreshFileInternal(scoped_ptr<GDataFile> fresh_file,
409 GDataEntry* old_entry); 438 GDataEntry* old_entry);
410 439
411 // Serializes/Parses to/from string via proto classes. 440 // Serializes/Parses to/from string via proto classes.
412 void SerializeToString(std::string* serialized_proto) const; 441 void SerializeToString(std::string* serialized_proto) const;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // This should remain the last member so it'll be destroyed first and 479 // This should remain the last member so it'll be destroyed first and
451 // invalidate its weak pointers before other members are destroyed. 480 // invalidate its weak pointers before other members are destroyed.
452 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; 481 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_;
453 482
454 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); 483 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService);
455 }; 484 };
456 485
457 } // namespace gdata 486 } // namespace gdata
458 487
459 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ 488 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system_interface.h ('k') | chrome/browser/chromeos/gdata/gdata_files.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698