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

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

Issue 10168025: GDataDB support with leveldb. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fixes Created 8 years, 8 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 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 REGULAR_FILE, 52 REGULAR_FILE,
53 HOSTED_DOCUMENT, 53 HOSTED_DOCUMENT,
54 }; 54 };
55 55
56 // Base class for representing files and directories in gdata virtual file 56 // Base class for representing files and directories in gdata virtual file
57 // system. 57 // system.
58 class GDataEntry { 58 class GDataEntry {
59 public: 59 public:
60 explicit GDataEntry(GDataDirectory* parent, GDataRootDirectory* root); 60 explicit GDataEntry(GDataDirectory* parent, GDataRootDirectory* root);
61 virtual ~GDataEntry(); 61 virtual ~GDataEntry();
62
62 virtual GDataFile* AsGDataFile(); 63 virtual GDataFile* AsGDataFile();
63 virtual GDataDirectory* AsGDataDirectory(); 64 virtual GDataDirectory* AsGDataDirectory();
64 virtual GDataRootDirectory* AsGDataRootDirectory(); 65 virtual GDataRootDirectory* AsGDataRootDirectory();
65 66
67 // const versions of AsGDataFile and AsGDataDirectory.
68 const GDataFile* AsGDataFile() const;
satorux1 2012/04/23 17:40:41 function overloading should be avoided. can you re
achuithb 2012/04/24 08:09:36 Done.
69 const GDataDirectory* AsGDataDirectory() const;
70
66 // Converts DocumentEntry into GDataEntry. 71 // Converts DocumentEntry into GDataEntry.
67 static GDataEntry* FromDocumentEntry(GDataDirectory* parent, 72 static GDataEntry* FromDocumentEntry(GDataDirectory* parent,
68 DocumentEntry* doc, 73 DocumentEntry* doc,
69 GDataRootDirectory* root); 74 GDataRootDirectory* root);
70 75
76 // Serialize/Parse to/from string via proto classes.
77 void SerializeToString(std::string* serialized_proto) const;
78 static scoped_ptr<GDataEntry> FromProtoString(
79 const std::string& serialized_proto);
80
71 // Convert to/from proto. 81 // Convert to/from proto.
72 void FromProto(const GDataEntryProto& proto); 82 void FromProto(const GDataEntryProto& proto);
73 void ToProto(GDataEntryProto* proto) const; 83 void ToProto(GDataEntryProto* proto) const;
74 84
75 // Escapes forward slashes from file names with magic unicode character 85 // Escapes forward slashes from file names with magic unicode character
76 // \u2215 pretty much looks the same in UI. 86 // \u2215 pretty much looks the same in UI.
77 static std::string EscapeUtf8FileName(const std::string& input); 87 static std::string EscapeUtf8FileName(const std::string& input);
78 88
79 // Unescapes what was escaped in EScapeUtf8FileName. 89 // Unescapes what was escaped in EScapeUtf8FileName.
80 static std::string UnescapeUtf8FileName(const std::string& input); 90 static std::string UnescapeUtf8FileName(const std::string& input);
81 91
82 GDataDirectory* parent() { return parent_; } 92 GDataDirectory* parent() { return parent_; }
83 const base::PlatformFileInfo& file_info() const { return file_info_; } 93 const base::PlatformFileInfo& file_info() const { return file_info_; }
94
84 const FilePath::StringType& file_name() const { return file_name_; } 95 const FilePath::StringType& file_name() const { return file_name_; }
85 const FilePath::StringType& title() const {
86 return title_;
87 }
88 void set_title(const FilePath::StringType& title) {
89 title_ = title;
90 }
91 void set_file_name(const FilePath::StringType& name) { file_name_ = name; } 96 void set_file_name(const FilePath::StringType& name) { file_name_ = name; }
92 97
98 const FilePath::StringType& title() const { return title_; }
99 void set_title(const FilePath::StringType& title) { title_ = title; }
100
93 // The unique resource ID associated with this file system entry. 101 // The unique resource ID associated with this file system entry.
94 const std::string& resource_id() const { return resource_id_; } 102 const std::string& resource_id() const { return resource_id_; }
103 void set_resource_id(const std::string& res_id) { resource_id_ = res_id; }
95 104
96 // The content URL is used for downloading regular files as is. 105 // The content URL is used for downloading regular files as is.
97 const GURL& content_url() const { return content_url_; } 106 const GURL& content_url() const { return content_url_; }
107 void set_content_url(const GURL& url) { content_url_ = url; }
98 108
99 // The edit URL is used for removing files and hosted documents. 109 // The edit URL is used for removing files and hosted documents.
100 const GURL& edit_url() const { return edit_url_; } 110 const GURL& edit_url() const { return edit_url_; }
101 111
102 // The resource id of the parent folder. This piece of information is needed 112 // The resource id of the parent folder. This piece of information is needed
103 // to pair files from change feeds with their directory parents withing the 113 // to pair files from change feeds with their directory parents withing the
104 // existing file system snapshot (GDataRootDirectory::resource_map_). 114 // existing file system snapshot (GDataRootDirectory::resource_map_).
105 const std::string& parent_resource_id() const { return parent_resource_id_; } 115 const std::string& parent_resource_id() const { return parent_resource_id_; }
106 116
107 // True if file was deleted. Used only for instances that are generated from 117 // True if file was deleted. Used only for instances that are generated from
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return cache_state &= ~CACHE_STATE_DIRTY; 214 return cache_state &= ~CACHE_STATE_DIRTY;
205 } 215 }
206 216
207 DocumentEntry::EntryKind kind() const { return kind_; } 217 DocumentEntry::EntryKind kind() const { return kind_; }
208 const GURL& thumbnail_url() const { return thumbnail_url_; } 218 const GURL& thumbnail_url() const { return thumbnail_url_; }
209 const GURL& alternate_url() const { return alternate_url_; } 219 const GURL& alternate_url() const { return alternate_url_; }
210 const std::string& content_mime_type() const { return content_mime_type_; } 220 const std::string& content_mime_type() const { return content_mime_type_; }
211 const std::string& etag() const { return etag_; } 221 const std::string& etag() const { return etag_; }
212 const std::string& id() const { return id_; } 222 const std::string& id() const { return id_; }
213 const std::string& file_md5() const { return file_md5_; } 223 const std::string& file_md5() const { return file_md5_; }
224 void set_file_md5(const std::string& file_md5) { file_md5_ = file_md5; }
214 const std::string& document_extension() const { return document_extension_; } 225 const std::string& document_extension() const { return document_extension_; }
215 bool is_hosted_document() const { return is_hosted_document_; } 226 bool is_hosted_document() const { return is_hosted_document_; }
216 227
217 // Overrides GDataEntry::SetFileNameFromTitle() to set |file_name_| based 228 // Overrides GDataEntry::SetFileNameFromTitle() to set |file_name_| based
218 // on the value of |title_| as well as |is_hosted_document_| and 229 // on the value of |title_| as well as |is_hosted_document_| and
219 // |document_extension_| for hosted documents. 230 // |document_extension_| for hosted documents.
220 virtual void SetFileNameFromTitle() OVERRIDE; 231 virtual void SetFileNameFromTitle() OVERRIDE;
221 232
222 private: 233 private:
223 // Content URL for files. 234 // Content URL for files.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 base::Time last_serialized_; 449 base::Time last_serialized_;
439 int largest_changestamp_; 450 int largest_changestamp_;
440 size_t serialized_size_; 451 size_t serialized_size_;
441 452
442 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); 453 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory);
443 }; 454 };
444 455
445 } // namespace gdata 456 } // namespace gdata
446 457
447 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ 458 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698