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

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

Issue 10836354: Rename GData* to Drive* in gdata.proto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for comments. 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 <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.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/platform_file.h" 16 #include "base/platform_file.h"
17 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" 17 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h"
18 18
19 namespace gdata { 19 namespace gdata {
20 20
21 class GDataFile; 21 class DriveDirectoryProto;
22 class DriveEntryProto;
22 class GDataDirectory; 23 class GDataDirectory;
23 class GDataDirectoryService; 24 class GDataDirectoryService;
24 25 class GDataFile;
25 class GDataEntryProto;
26 class GDataDirectoryProto;
27 class GDataRootDirectoryProto;
28 class PlatformFileInfoProto; 26 class PlatformFileInfoProto;
29 27
30 // Used to read a directory from the file system. 28 // Used to read a directory from the file system.
31 // If |error| is not GDATA_FILE_OK, |entries| is set to NULL. 29 // If |error| is not GDATA_FILE_OK, |entries| is set to NULL.
32 // |entries| are contents, both files and directories, of the directory. 30 // |entries| are contents, both files and directories, of the directory.
33 typedef std::vector<GDataEntryProto> GDataEntryProtoVector; 31 typedef std::vector<DriveEntryProto> DriveEntryProtoVector;
34 32
35 // Base class for representing files and directories in gdata virtual file 33 // Base class for representing files and directories in gdata virtual file
36 // system. 34 // system.
37 class GDataEntry { 35 class GDataEntry {
38 public: 36 public:
39 virtual ~GDataEntry(); 37 virtual ~GDataEntry();
40 38
41 virtual GDataFile* AsGDataFile(); 39 virtual GDataFile* AsGDataFile();
42 virtual GDataDirectory* AsGDataDirectory(); 40 virtual GDataDirectory* AsGDataDirectory();
43 41
(...skipping 12 matching lines...) Expand all
56 const PlatformFileInfoProto& proto, 54 const PlatformFileInfoProto& proto,
57 base::PlatformFileInfo* file_info); 55 base::PlatformFileInfo* file_info);
58 56
59 // Converts the platform file info to the proto representation. 57 // Converts the platform file info to the proto representation.
60 static void ConvertPlatformFileInfoToProto( 58 static void ConvertPlatformFileInfoToProto(
61 const base::PlatformFileInfo& file_info, 59 const base::PlatformFileInfo& file_info,
62 PlatformFileInfoProto* proto); 60 PlatformFileInfoProto* proto);
63 61
64 // Converts to/from proto. Only handles the common part (i.e. does not 62 // Converts to/from proto. Only handles the common part (i.e. does not
65 // touch |file_specific_info|). 63 // touch |file_specific_info|).
66 void FromProto(const GDataEntryProto& proto); 64 void FromProto(const DriveEntryProto& proto);
67 // TODO(achuith,satorux): Should this be virtual? 65 // TODO(achuith,satorux): Should this be virtual?
68 void ToProto(GDataEntryProto* proto) const; 66 void ToProto(DriveEntryProto* proto) const;
69 67
70 // Similar to ToProto() but this fills in |file_specific_info| and 68 // Similar to ToProto() but this fills in |file_specific_info| and
71 // |directory_specific_info| based on the actual type of the entry. 69 // |directory_specific_info| based on the actual type of the entry.
72 // Used to obtain full metadata of a file or a directory as 70 // Used to obtain full metadata of a file or a directory as
73 // GDataEntryProto. 71 // DriveEntryProto.
74 void ToProtoFull(GDataEntryProto* proto) const; 72 void ToProtoFull(DriveEntryProto* proto) const;
75 73
76 // Escapes forward slashes from file names with magic unicode character 74 // Escapes forward slashes from file names with magic unicode character
77 // \u2215 pretty much looks the same in UI. 75 // \u2215 pretty much looks the same in UI.
78 static std::string EscapeUtf8FileName(const std::string& input); 76 static std::string EscapeUtf8FileName(const std::string& input);
79 77
80 // Unescapes what was escaped in EScapeUtf8FileName. 78 // Unescapes what was escaped in EScapeUtf8FileName.
81 static std::string UnescapeUtf8FileName(const std::string& input); 79 static std::string UnescapeUtf8FileName(const std::string& input);
82 80
83 // Return the parent of this entry. NULL for root. 81 // Return the parent of this entry. NULL for root.
84 GDataDirectory* parent() const { return parent_; } 82 GDataDirectory* parent() const { return parent_; }
(...skipping 10 matching lines...) Expand all
95 void set_title(const FilePath::StringType& title) { title_ = title; } 93 void set_title(const FilePath::StringType& title) { title_ = title; }
96 94
97 // The unique resource ID associated with this file system entry. 95 // The unique resource ID associated with this file system entry.
98 const std::string& resource_id() const { return resource_id_; } 96 const std::string& resource_id() const { return resource_id_; }
99 void set_resource_id(const std::string& res_id) { resource_id_ = res_id; } 97 void set_resource_id(const std::string& res_id) { resource_id_ = res_id; }
100 98
101 // The content URL is used for downloading regular files as is. 99 // The content URL is used for downloading regular files as is.
102 const GURL& content_url() const { return content_url_; } 100 const GURL& content_url() const { return content_url_; }
103 void set_content_url(const GURL& url) { content_url_ = url; } 101 void set_content_url(const GURL& url) { content_url_ = url; }
104 102
105 // Upload URL is used for uploading files. See gdata.proto for details. 103 // Upload URL is used for uploading files. See drive.proto for details.
106 const GURL& upload_url() const { return upload_url_; } 104 const GURL& upload_url() const { return upload_url_; }
107 void set_upload_url(const GURL& url) { upload_url_ = url; } 105 void set_upload_url(const GURL& url) { upload_url_ = url; }
108 106
109 // The edit URL is used for removing files and hosted documents. 107 // The edit URL is used for removing files and hosted documents.
110 const GURL& edit_url() const { return edit_url_; } 108 const GURL& edit_url() const { return edit_url_; }
111 109
112 // The resource id of the parent folder. This piece of information is needed 110 // The resource id of the parent folder. This piece of information is needed
113 // to pair files from change feeds with their directory parents withing the 111 // to pair files from change feeds with their directory parents withing the
114 // existing file system snapshot (GDataDirectoryService::resource_map_). 112 // existing file system snapshot (GDataDirectoryService::resource_map_).
115 const std::string& parent_resource_id() const { return parent_resource_id_; } 113 const std::string& parent_resource_id() const { return parent_resource_id_; }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 DISALLOW_COPY_AND_ASSIGN(GDataEntry); 167 DISALLOW_COPY_AND_ASSIGN(GDataEntry);
170 }; 168 };
171 169
172 // Represents "file" in in a GData virtual file system. On gdata feed side, 170 // Represents "file" in in a GData virtual file system. On gdata feed side,
173 // this could be either a regular file or a server side document. 171 // this could be either a regular file or a server side document.
174 class GDataFile : public GDataEntry { 172 class GDataFile : public GDataEntry {
175 public: 173 public:
176 virtual ~GDataFile(); 174 virtual ~GDataFile();
177 175
178 // Converts to/from proto. 176 // Converts to/from proto.
179 void FromProto(const GDataEntryProto& proto); 177 void FromProto(const DriveEntryProto& proto);
180 void ToProto(GDataEntryProto* proto) const; 178 void ToProto(DriveEntryProto* proto) const;
181 179
182 DocumentEntry::EntryKind kind() const { return kind_; } 180 DocumentEntry::EntryKind kind() const { return kind_; }
183 const GURL& thumbnail_url() const { return thumbnail_url_; } 181 const GURL& thumbnail_url() const { return thumbnail_url_; }
184 const GURL& alternate_url() const { return alternate_url_; } 182 const GURL& alternate_url() const { return alternate_url_; }
185 const std::string& content_mime_type() const { return content_mime_type_; } 183 const std::string& content_mime_type() const { return content_mime_type_; }
186 const std::string& file_md5() const { return file_md5_; } 184 const std::string& file_md5() const { return file_md5_; }
187 void set_file_md5(const std::string& file_md5) { file_md5_ = file_md5; } 185 void set_file_md5(const std::string& file_md5) { file_md5_ = file_md5; }
188 const std::string& document_extension() const { return document_extension_; } 186 const std::string& document_extension() const { return document_extension_; }
189 bool is_hosted_document() const { return is_hosted_document_; } 187 bool is_hosted_document() const { return is_hosted_document_; }
190 void set_file_info(const base::PlatformFileInfo& info) { file_info_ = info; } 188 void set_file_info(const base::PlatformFileInfo& info) { file_info_ = info; }
(...skipping 23 matching lines...) Expand all
214 DISALLOW_COPY_AND_ASSIGN(GDataFile); 212 DISALLOW_COPY_AND_ASSIGN(GDataFile);
215 }; 213 };
216 214
217 // Represents "directory" in a GData virtual file system. Maps to gdata 215 // Represents "directory" in a GData virtual file system. Maps to gdata
218 // collection element. 216 // collection element.
219 class GDataDirectory : public GDataEntry { 217 class GDataDirectory : public GDataEntry {
220 public: 218 public:
221 virtual ~GDataDirectory(); 219 virtual ~GDataDirectory();
222 220
223 // Converts to/from proto. 221 // Converts to/from proto.
224 void FromProto(const GDataDirectoryProto& proto); 222 void FromProto(const DriveDirectoryProto& proto);
225 void ToProto(GDataDirectoryProto* proto) const; 223 void ToProto(DriveDirectoryProto* proto) const;
226 224
227 // Converts the children as a vector of GDataEntryProto. 225 // Converts the children as a vector of DriveEntryProto.
228 scoped_ptr<GDataEntryProtoVector> ToProtoVector() const; 226 scoped_ptr<DriveEntryProtoVector> ToProtoVector() const;
229 227
230 private: 228 private:
231 // TODO(satorux): Remove the friend statements. crbug.com/139649 229 // TODO(satorux): Remove the friend statements. crbug.com/139649
232 friend class GDataDirectoryService; 230 friend class GDataDirectoryService;
233 friend class GDataWapiFeedProcessor; 231 friend class GDataWapiFeedProcessor;
234 232
235 explicit GDataDirectory(GDataDirectoryService* directory_service); 233 explicit GDataDirectory(GDataDirectoryService* directory_service);
236 234
237 // Initializes from DocumentEntry. 235 // Initializes from DocumentEntry.
238 virtual void InitFromDocumentEntry(const DocumentEntry& doc) OVERRIDE; 236 virtual void InitFromDocumentEntry(const DocumentEntry& doc) OVERRIDE;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // Collection of children. 277 // Collection of children.
280 GDataChildMap child_files_; 278 GDataChildMap child_files_;
281 GDataChildMap child_directories_; 279 GDataChildMap child_directories_;
282 280
283 DISALLOW_COPY_AND_ASSIGN(GDataDirectory); 281 DISALLOW_COPY_AND_ASSIGN(GDataDirectory);
284 }; 282 };
285 283
286 } // namespace gdata 284 } // namespace gdata
287 285
288 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ 286 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc ('k') | chrome/browser/chromeos/gdata/gdata_files.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698