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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
| 11 #include <vector> |
11 | 12 |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/platform_file.h" | 18 #include "base/platform_file.h" |
18 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
19 #include "chrome/browser/chromeos/gdata/gdata_params.h" | 20 #include "chrome/browser/chromeos/gdata/gdata_params.h" |
20 #include "chrome/browser/chromeos/gdata/gdata_parser.h" | 21 #include "chrome/browser/chromeos/gdata/gdata_parser.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 132 |
132 // The resource id of the parent folder. This piece of information is needed | 133 // The resource id of the parent folder. This piece of information is needed |
133 // to pair files from change feeds with their directory parents withing the | 134 // to pair files from change feeds with their directory parents withing the |
134 // existing file system snapshot (GDataRootDirectory::resource_map_). | 135 // existing file system snapshot (GDataRootDirectory::resource_map_). |
135 const std::string& parent_resource_id() const { return parent_resource_id_; } | 136 const std::string& parent_resource_id() const { return parent_resource_id_; } |
136 | 137 |
137 // True if file was deleted. Used only for instances that are generated from | 138 // True if file was deleted. Used only for instances that are generated from |
138 // delta feeds. | 139 // delta feeds. |
139 bool is_deleted() const { return deleted_; } | 140 bool is_deleted() const { return deleted_; } |
140 | 141 |
| 142 // True if the entry is not bound to any file system (i.e. doesn't have a root |
| 143 // directory set). E.g. |fake_search_directory| below. |
| 144 // NOTE: GDataRootDirectories will return true here, since they have |
| 145 // themselves as root directories. |
| 146 bool is_detached() const { return root_ == NULL; } |
| 147 |
141 // Returns virtual file path representing this file system entry. This path | 148 // Returns virtual file path representing this file system entry. This path |
142 // corresponds to file path expected by public methods of GDataFileSyste | 149 // corresponds to file path expected by public methods of GDataFileSyste |
143 // class. | 150 // class. |
144 FilePath GetFilePath() const; | 151 FilePath GetFilePath() const; |
145 | 152 |
146 // Sets |file_name_| based on the value of |title_| without name | 153 // Sets |file_name_| based on the value of |title_| without name |
147 // de-duplication (see AddEntry() for details on de-duplication). | 154 // de-duplication (see AddEntry() for details on de-duplication). |
148 virtual void SetFileNameFromTitle(); | 155 virtual void SetFileNameFromTitle(); |
149 | 156 |
150 protected: | 157 protected: |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 493 |
487 // Serializes/Parses to/from string via proto classes. | 494 // Serializes/Parses to/from string via proto classes. |
488 void SerializeToString(std::string* serialized_proto) const; | 495 void SerializeToString(std::string* serialized_proto) const; |
489 bool ParseFromString(const std::string& serialized_proto); | 496 bool ParseFromString(const std::string& serialized_proto); |
490 | 497 |
491 // Converts to/from proto. | 498 // Converts to/from proto. |
492 void FromProto(const GDataRootDirectoryProto& proto); | 499 void FromProto(const GDataRootDirectoryProto& proto); |
493 void ToProto(GDataRootDirectoryProto* proto) const; | 500 void ToProto(GDataRootDirectoryProto* proto) const; |
494 | 501 |
495 private: | 502 private: |
| 503 // Used in |FindEntryByPath| if the path that is being searched for is |
| 504 // pointing to a search result path. The find entry parameters should be |
| 505 // modified to point to the actual file system entry that is referenced by |
| 506 // virtual search path. |
| 507 // Search path is formatted: <search_result_path><search_result_child_path>. |
| 508 // <search_result_child_path> is used when search result is directory, and is |
| 509 // relative to search result path (id references some content inside search |
| 510 // result). |
| 511 // Search result file name will be formatted <resource_id>.<file_name>. |
| 512 // We can define "search result path references gdata entry" for gdata search |
| 513 // results by: |
| 514 // Entry that whose file name is <file_name>, and has the same parent as |
| 515 // the entry with resource id <resource_id>. This definition enables us to |
| 516 // test uniqueness of the proposed name when renaming gdata search result. |
| 517 // |
| 518 // For example, if gdata/.search/foo/res_id.foo_name references |
| 519 // gdata/result_parent/result, and the search path is |
| 520 // gdata/.search/foo/res_ud.foo_name/foo_child, we'll set current dir to the |
| 521 // entry with path reulst_parent, and components to [result_parent, result, |
| 522 // foo_child]. |
| 523 bool ModifyFindEntryParamsForSearchPath( |
| 524 const FilePath& file_path, |
| 525 std::vector<FilePath::StringType>* components, |
| 526 GDataDirectory** current_dir, |
| 527 FilePath* directory_path); |
| 528 |
496 ResourceMap resource_map_; | 529 ResourceMap resource_map_; |
497 CacheMap cache_map_; | 530 CacheMap cache_map_; |
498 | 531 |
| 532 // Fake directory that will be returned when searching for content search |
| 533 // paths to make file manager happy when resolving paths. This directory |
| 534 // should never be used for file operations or storing file entries. |
| 535 scoped_ptr<GDataDirectory> fake_search_directory_; |
| 536 |
499 base::Time last_serialized_; | 537 base::Time last_serialized_; |
500 int largest_changestamp_; | 538 int largest_changestamp_; |
501 size_t serialized_size_; | 539 size_t serialized_size_; |
502 | 540 |
503 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); | 541 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); |
504 }; | 542 }; |
505 | 543 |
506 } // namespace gdata | 544 } // namespace gdata |
507 | 545 |
508 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ | 546 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ |
OLD | NEW |