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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 // Converts DocumentEntry into GDataEntry. | 272 // Converts DocumentEntry into GDataEntry. |
273 static GDataEntry* FromDocumentEntry( | 273 static GDataEntry* FromDocumentEntry( |
274 GDataDirectory* parent, | 274 GDataDirectory* parent, |
275 DocumentEntry* doc, | 275 DocumentEntry* doc, |
276 GDataDirectoryService* directory_service); | 276 GDataDirectoryService* directory_service); |
277 | 277 |
278 // Converts to/from proto. | 278 // Converts to/from proto. |
279 bool FromProto(const GDataDirectoryProto& proto) WARN_UNUSED_RESULT; | 279 bool FromProto(const GDataDirectoryProto& proto) WARN_UNUSED_RESULT; |
280 void ToProto(GDataDirectoryProto* proto) const; | 280 void ToProto(GDataDirectoryProto* proto) const; |
281 | 281 |
282 // Takes the ownership of |entry| from its current parent. If this directory | |
283 // is already the current parent of |file|, this method effectively goes | |
284 // through the name de-duplication for |file| based on the current state of | |
285 // the file system. | |
286 bool TakeEntry(GDataEntry* entry); | |
287 | |
288 // Takes over all entries from |dir|. | |
289 bool TakeOverEntries(GDataDirectory* dir); | |
290 | |
291 // Removes the entry from its children list and destroys the entry instance. | |
292 bool RemoveEntry(GDataEntry* entry); | |
293 | |
294 // Removes child elements. | 282 // Removes child elements. |
295 void RemoveChildren(); | 283 void RemoveChildren(); |
296 void RemoveChildFiles(); | 284 void RemoveChildFiles(); |
297 void RemoveChildDirectories(); | 285 void RemoveChildDirectories(); |
298 | 286 |
299 // Collection of children files/directories. | 287 // Collection of children files/directories. |
300 const GDataFileCollection& child_files() const { return child_files_; } | 288 const GDataFileCollection& child_files() const { return child_files_; } |
301 const GDataDirectoryCollection& child_directories() const { | 289 const GDataDirectoryCollection& child_directories() const { |
302 return child_directories_; | 290 return child_directories_; |
303 } | 291 } |
304 | 292 |
305 private: | 293 private: |
306 // TODO(satorux): Remove the friend statements. crbug.com/139649 | 294 // TODO(satorux): Remove the friend statements. crbug.com/139649 |
307 friend class GDataDirectoryService; | 295 friend class GDataDirectoryService; |
308 friend class GDataFileSystem; | 296 friend class GDataFileSystem; |
309 | 297 |
310 // Adds child file to the directory and takes over the ownership of |file| | 298 // Adds child file to the directory and takes over the ownership of |file| |
311 // object. The method will also do name de-duplication to ensure that the | 299 // object. The method will also do name de-duplication to ensure that the |
312 // exposed presentation path does not have naming conflicts. Two files with | 300 // exposed presentation path does not have naming conflicts. Two files with |
313 // the same name "Foo" will be renames to "Foo (1)" and "Foo (2)". | 301 // the same name "Foo" will be renames to "Foo (1)" and "Foo (2)". |
314 // TODO(satorux): Remove this. crbug.com/139649 | 302 // TODO(satorux): Remove this. crbug.com/139649 |
315 void AddEntry(GDataEntry* entry); | 303 void AddEntry(GDataEntry* entry); |
316 | 304 |
| 305 // Removes the entry from its children list and destroys the entry instance. |
| 306 // TODO(satorux): Remove this. crbug.com/139649 |
| 307 bool RemoveEntry(GDataEntry* entry); |
| 308 |
| 309 // Takes the ownership of |entry| from its current parent. If this directory |
| 310 // is already the current parent of |file|, this method effectively goes |
| 311 // through the name de-duplication for |file| based on the current state of |
| 312 // the file system. |
| 313 // TODO(satorux): Remove this. crbug.com/139649 |
| 314 bool TakeEntry(GDataEntry* entry); |
| 315 |
| 316 // Takes over all entries from |dir|. |
| 317 // TODO(satorux): Remove this. crbug.com/139649 |
| 318 bool TakeOverEntries(GDataDirectory* dir); |
| 319 |
317 // Find a child by its name. | 320 // Find a child by its name. |
318 // TODO(satorux): Remove this. crbug.com/139649 | 321 // TODO(satorux): Remove this. crbug.com/139649 |
319 GDataEntry* FindChild(const FilePath::StringType& file_name) const; | 322 GDataEntry* FindChild(const FilePath::StringType& file_name) const; |
320 | 323 |
321 // Add |entry| to children. | 324 // Add |entry| to children. |
322 void AddChild(GDataEntry* entry); | 325 void AddChild(GDataEntry* entry); |
323 | 326 |
324 // Removes the entry from its children without destroying the | 327 // Removes the entry from its children without destroying the |
325 // entry instance. | 328 // entry instance. |
326 bool RemoveChild(GDataEntry* entry); | 329 bool RemoveChild(GDataEntry* entry); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 size_t serialized_size_; | 410 size_t serialized_size_; |
408 int largest_changestamp_; // Stored in the serialized proto. | 411 int largest_changestamp_; // Stored in the serialized proto. |
409 ContentOrigin origin_; | 412 ContentOrigin origin_; |
410 | 413 |
411 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); | 414 DISALLOW_COPY_AND_ASSIGN(GDataDirectoryService); |
412 }; | 415 }; |
413 | 416 |
414 } // namespace gdata | 417 } // namespace gdata |
415 | 418 |
416 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ | 419 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
OLD | NEW |