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

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

Issue 10825218: Simplify implementation of FindEntryByPathSync (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 // Converts to/from proto. 280 // Converts to/from proto.
281 bool FromProto(const GDataDirectoryProto& proto) WARN_UNUSED_RESULT; 281 bool FromProto(const GDataDirectoryProto& proto) WARN_UNUSED_RESULT;
282 void ToProto(GDataDirectoryProto* proto) const; 282 void ToProto(GDataDirectoryProto* proto) const;
283 283
284 // Removes child elements. 284 // Removes child elements.
285 void RemoveChildren(); 285 void RemoveChildren();
286 void RemoveChildFiles(); 286 void RemoveChildFiles();
287 void RemoveChildDirectories(); 287 void RemoveChildDirectories();
288 288
289 // Find child by its name.
290 void FindChildAsync(const FilePath::StringType& file_name,
satorux1 2012/08/07 10:43:46 base_name ?
291 const FindEntryCallback& callback) const;
292
289 // Collection of children files/directories. 293 // Collection of children files/directories.
290 const GDataFileCollection& child_files() const { return child_files_; } 294 const GDataFileCollection& child_files() const { return child_files_; }
291 const GDataDirectoryCollection& child_directories() const { 295 const GDataDirectoryCollection& child_directories() const {
292 return child_directories_; 296 return child_directories_;
293 } 297 }
294 298
295 private: 299 private:
296 // TODO(satorux): Remove the friend statements. crbug.com/139649 300 // TODO(satorux): Remove the friend statements. crbug.com/139649
297 friend class GDataDirectoryService; 301 friend class GDataDirectoryService;
298 friend class GDataFileSystem; 302 friend class GDataFileSystem;
299 friend class GDataWapiFeedProcessor; 303 friend class GDataWapiFeedProcessor;
300 304
301 // Adds child file to the directory and takes over the ownership of |file| 305 // Adds child file to the directory and takes over the ownership of |file|
302 // object. The method will also do name de-duplication to ensure that the 306 // object. The method will also do name de-duplication to ensure that the
303 // exposed presentation path does not have naming conflicts. Two files with 307 // exposed presentation path does not have naming conflicts. Two files with
304 // the same name "Foo" will be renames to "Foo (1)" and "Foo (2)". 308 // the same name "Foo" will be renames to "Foo (1)" and "Foo (2)".
305 // TODO(satorux): Remove this. crbug.com/139649 309 // TODO(satorux): Remove this. crbug.com/139649
306 void AddEntry(GDataEntry* entry); 310 void AddEntry(GDataEntry* entry);
307 311
308 // Removes the entry from its children list and destroys the entry instance. 312 // Removes the entry from its children list and destroys the entry instance.
309 // TODO(satorux): Remove this. crbug.com/139649 313 // TODO(satorux): Remove this. crbug.com/139649
310 bool RemoveEntry(GDataEntry* entry); 314 void RemoveEntry(GDataEntry* entry);
311 315
312 // Takes the ownership of |entry| from its current parent. If this directory 316 // Takes the ownership of |entry| from its current parent. If this directory
313 // is already the current parent of |file|, this method effectively goes 317 // is already the current parent of |file|, this method effectively goes
314 // through the name de-duplication for |file| based on the current state of 318 // through the name de-duplication for |file| based on the current state of
315 // the file system. 319 // the file system.
316 // TODO(satorux): Remove this. crbug.com/139649 320 // TODO(satorux): Remove this. crbug.com/139649
317 bool TakeEntry(GDataEntry* entry); 321 bool TakeEntry(GDataEntry* entry);
318 322
319 // Takes over all entries from |dir|. 323 // Takes over all entries from |dir|.
320 // TODO(satorux): Remove this. crbug.com/139649 324 // TODO(satorux): Remove this. crbug.com/139649
321 bool TakeOverEntries(GDataDirectory* dir); 325 bool TakeOverEntries(GDataDirectory* dir);
322 326
323 // Find a child by its name. 327 // Find a child by its name.
324 // TODO(satorux): Remove this. crbug.com/139649 328 // TODO(satorux): Remove this. crbug.com/139649
325 GDataEntry* FindChild(const FilePath::StringType& file_name) const; 329 GDataEntry* FindChild(const FilePath::StringType& file_name) const;
326 330
327 // Add |entry| to children. 331 // Add |entry| to children.
328 void AddChild(GDataEntry* entry); 332 void AddChild(GDataEntry* entry);
329 333
330 // Removes the entry from its children without destroying the 334 // Removes the entry from its children without destroying the
331 // entry instance. 335 // entry instance.
332 bool RemoveChild(GDataEntry* entry); 336 void RemoveChild(GDataEntry* entry);
333 337
334 // Collection of children GDataEntry items. 338 // Collection of children GDataEntry items.
335 GDataFileCollection child_files_; 339 GDataFileCollection child_files_;
336 GDataDirectoryCollection child_directories_; 340 GDataDirectoryCollection child_directories_;
337 341
338 DISALLOW_COPY_AND_ASSIGN(GDataDirectory); 342 DISALLOW_COPY_AND_ASSIGN(GDataDirectory);
339 }; 343 };
340 344
341 // TODO(achuith,hashimoto,satorux): Move this to a separate file. 345 // TODO(achuith,hashimoto,satorux): Move this to a separate file.
342 // crbug.com/140317. 346 // crbug.com/140317.
343 // Class to handle GDataEntry* lookups, add/remove GDataEntry*. 347 // Class to handle GDataEntry* lookups, add/remove GDataEntry*.
344 class GDataDirectoryService { 348 class GDataDirectoryService {
345 public: 349 public:
346 // Callback for GetEntryByResourceIdAsync. 350 // Callback for GetEntryByResourceIdAsync.
347 typedef base::Callback<void(GDataEntry* entry)> GetEntryByResourceIdCallback; 351 typedef base::Callback<void(GDataEntry* entry)> GetEntryByResourceIdCallback;
348
349 // Map of resource id and serialized GDataEntry. 352 // Map of resource id and serialized GDataEntry.
350 typedef std::map<std::string, std::string> SerializedMap; 353 typedef std::map<std::string, std::string> SerializedMap;
351 354
352 GDataDirectoryService(); 355 GDataDirectoryService();
353 ~GDataDirectoryService(); 356 ~GDataDirectoryService();
354 357
355 GDataDirectory* root() { return root_.get(); } 358 GDataDirectory* root() { return root_.get(); }
356 359
357 // Last time when we dumped serialized file system to disk. 360 // Last time when we dumped serialized file system to disk.
358 const base::Time& last_serialized() const { return last_serialized_; } 361 const base::Time& last_serialized() const { return last_serialized_; }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // This should remain the last member so it'll be destroyed first and 453 // This should remain the last member so it'll be destroyed first and
451 // invalidate its weak pointers before other members are destroyed. 454 // invalidate its weak pointers before other members are destroyed.
452 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_; 455 base::WeakPtrFactory<GDataDirectoryService> weak_ptr_factory_;
453 456
454 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); 457 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService);
455 }; 458 };
456 459
457 } // namespace gdata 460 } // namespace gdata
458 461
459 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ 462 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698