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

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: 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;
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 void set_file_info(const base::PlatformFileInfo& file_info) {
95 file_info_ = file_info;
96 }
97
84 const FilePath::StringType& file_name() const { return file_name_; } 98 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; } 99 void set_file_name(const FilePath::StringType& name) { file_name_ = name; }
92 100
101 const FilePath::StringType& title() const { return title_; }
102 void set_title(const FilePath::StringType& title) { title_ = title; }
103
93 // The unique resource ID associated with this file system entry. 104 // The unique resource ID associated with this file system entry.
94 const std::string& resource_id() const { return resource_id_; } 105 const std::string& resource_id() const { return resource_id_; }
106 void set_resource_id(const std::string& res_id) { resource_id_ = res_id; }
95 107
96 // The content URL is used for downloading regular files as is. 108 // The content URL is used for downloading regular files as is.
97 const GURL& content_url() const { return content_url_; } 109 const GURL& content_url() const { return content_url_; }
110 void set_content_url(const GURL& url) { content_url_ = url; }
98 111
99 // The edit URL is used for removing files and hosted documents. 112 // The edit URL is used for removing files and hosted documents.
100 const GURL& edit_url() const { return edit_url_; } 113 const GURL& edit_url() const { return edit_url_; }
101 114
102 // The resource id of the parent folder. This piece of information is needed 115 // 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 116 // to pair files from change feeds with their directory parents withing the
104 // existing file system snapshot (GDataRootDirectory::resource_map_). 117 // existing file system snapshot (GDataRootDirectory::resource_map_).
105 const std::string& parent_resource_id() const { return parent_resource_id_; } 118 const std::string& parent_resource_id() const { return parent_resource_id_; }
106 119
107 // True if file was deleted. Used only for instances that are generated from 120 // 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; 217 return cache_state &= ~CACHE_STATE_DIRTY;
205 } 218 }
206 219
207 DocumentEntry::EntryKind kind() const { return kind_; } 220 DocumentEntry::EntryKind kind() const { return kind_; }
208 const GURL& thumbnail_url() const { return thumbnail_url_; } 221 const GURL& thumbnail_url() const { return thumbnail_url_; }
209 const GURL& alternate_url() const { return alternate_url_; } 222 const GURL& alternate_url() const { return alternate_url_; }
210 const std::string& content_mime_type() const { return content_mime_type_; } 223 const std::string& content_mime_type() const { return content_mime_type_; }
211 const std::string& etag() const { return etag_; } 224 const std::string& etag() const { return etag_; }
212 const std::string& id() const { return id_; } 225 const std::string& id() const { return id_; }
213 const std::string& file_md5() const { return file_md5_; } 226 const std::string& file_md5() const { return file_md5_; }
227 void set_file_md5(const std::string& file_md5) { file_md5_ = file_md5; }
214 const std::string& document_extension() const { return document_extension_; } 228 const std::string& document_extension() const { return document_extension_; }
215 bool is_hosted_document() const { return is_hosted_document_; } 229 bool is_hosted_document() const { return is_hosted_document_; }
216 230
217 // Overrides GDataEntry::SetFileNameFromTitle() to set |file_name_| based 231 // Overrides GDataEntry::SetFileNameFromTitle() to set |file_name_| based
218 // on the value of |title_| as well as |is_hosted_document_| and 232 // on the value of |title_| as well as |is_hosted_document_| and
219 // |document_extension_| for hosted documents. 233 // |document_extension_| for hosted documents.
220 virtual void SetFileNameFromTitle() OVERRIDE; 234 virtual void SetFileNameFromTitle() OVERRIDE;
221 235
222 private: 236 private:
223 // Content URL for files. 237 // Content URL for files.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 base::Time last_serialized_; 452 base::Time last_serialized_;
439 int largest_changestamp_; 453 int largest_changestamp_;
440 size_t serialized_size_; 454 size_t serialized_size_;
441 455
442 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); 456 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory);
443 }; 457 };
444 458
445 } // namespace gdata 459 } // namespace gdata
446 460
447 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ 461 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698