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

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

Issue 9662041: Implement copy and move operations within the same remote file system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 <sys/stat.h>
9
8 #include <map> 10 #include <map>
9 #include <sys/stat.h> 11 #include <string>
10 12
11 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
14 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
15 #include "base/platform_file.h" 17 #include "base/platform_file.h"
16 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
17 #include "chrome/browser/chromeos/gdata/gdata.h" 19 #include "chrome/browser/chromeos/gdata/gdata.h"
18 #include "chrome/browser/chromeos/gdata/gdata_parser.h" 20 #include "chrome/browser/chromeos/gdata/gdata_parser.h"
19 #include "chrome/browser/chromeos/gdata/gdata_uploader.h" 21 #include "chrome/browser/chromeos/gdata/gdata_uploader.h"
(...skipping 21 matching lines...) Expand all
41 DocumentEntry* doc); 43 DocumentEntry* doc);
42 static std::string EscapeUtf8FileName(const std::string& input); 44 static std::string EscapeUtf8FileName(const std::string& input);
43 static std::string UnescapeUtf8FileName(const std::string& input); 45 static std::string UnescapeUtf8FileName(const std::string& input);
44 46
45 GDataDirectory* parent() { return parent_; } 47 GDataDirectory* parent() { return parent_; }
46 const base::PlatformFileInfo& file_info() const { return file_info_; } 48 const base::PlatformFileInfo& file_info() const { return file_info_; }
47 const FilePath::StringType& file_name() const { return file_name_; } 49 const FilePath::StringType& file_name() const { return file_name_; }
48 const FilePath::StringType& original_file_name() const { 50 const FilePath::StringType& original_file_name() const {
49 return original_file_name_; 51 return original_file_name_;
50 } 52 }
53 void set_original_file_name(const FilePath::StringType& name) {
satorux1 2012/03/12 17:48:24 While you are at it, could you document the differ
Ben Chan 2012/03/13 00:29:21 Done.
54 original_file_name_ = name;
55 }
51 void set_file_name(const FilePath::StringType& name) { file_name_ = name; } 56 void set_file_name(const FilePath::StringType& name) { file_name_ = name; }
57 void set_parent(GDataDirectory* parent) { parent_ = parent; }
satorux1 2012/03/12 17:48:24 Looks scary. Let's move this to protected: section
Ben Chan 2012/03/13 00:29:21 Done.
58
59 const std::string& resource() const { return resource_id_; }
satorux1 2012/03/12 17:48:24 resource() -> resource_id().
Ben Chan 2012/03/13 00:29:21 Done.
52 60
53 // The content URL is used for downloading regular files as is. 61 // The content URL is used for downloading regular files as is.
54 const GURL& content_url() const { return content_url_; } 62 const GURL& content_url() const { return content_url_; }
55 63
56 // The self URL is used for removing files and hosted documents. 64 // The self URL is used for removing files and hosted documents.
57 const GURL& self_url() const { return self_url_; } 65 const GURL& self_url() const { return self_url_; }
58 66
59 // Returns virtual file path representing this file system entry. This path 67 // Returns virtual file path representing this file system entry. This path
60 // corresponds to file path expected by public methods of GDataFileSyste 68 // corresponds to file path expected by public methods of GDataFileSyste
61 // class. 69 // class.
62 FilePath GetFilePath(); 70 FilePath GetFilePath();
63 71
72 // Restores |file_name_| to the original file name before de-duplication.
73 virtual void UseOriginalFileName();
74
64 protected: 75 protected:
65 base::PlatformFileInfo file_info_; 76 base::PlatformFileInfo file_info_;
66 FilePath::StringType file_name_; 77 FilePath::StringType file_name_;
67 FilePath::StringType original_file_name_; 78 FilePath::StringType original_file_name_;
79 std::string resource_id_;
68 // Files with the same original name will be uniquely identified with this 80 // Files with the same original name will be uniquely identified with this
69 // field so we can represent them with unique URLs/paths in File API layer. 81 // field so we can represent them with unique URLs/paths in File API layer.
70 // For example, two files in the same directory with the same name "Foo" 82 // For example, two files in the same directory with the same name "Foo"
71 // will show up in the virtual directory as "Foo" and "Foo (2)". 83 // will show up in the virtual directory as "Foo" and "Foo (2)".
72 GURL self_url_; 84 GURL self_url_;
73 GURL content_url_; 85 GURL content_url_;
74 GDataDirectory* parent_; 86 GDataDirectory* parent_;
75 GDataRootDirectory* root_; // Weak pointer to GDataRootDirectory. 87 GDataRootDirectory* root_; // Weak pointer to GDataRootDirectory.
76 88
77 private: 89 private:
(...skipping 19 matching lines...) Expand all
97 virtual GDataFile* AsGDataFile() OVERRIDE; 109 virtual GDataFile* AsGDataFile() OVERRIDE;
98 110
99 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, 111 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent,
100 DocumentEntry* doc); 112 DocumentEntry* doc);
101 113
102 DocumentEntry::EntryKind kind() const { return kind_; } 114 DocumentEntry::EntryKind kind() const { return kind_; }
103 const GURL& thumbnail_url() const { return thumbnail_url_; } 115 const GURL& thumbnail_url() const { return thumbnail_url_; }
104 const GURL& edit_url() const { return edit_url_; } 116 const GURL& edit_url() const { return edit_url_; }
105 const std::string& content_mime_type() const { return content_mime_type_; } 117 const std::string& content_mime_type() const { return content_mime_type_; }
106 const std::string& etag() const { return etag_; } 118 const std::string& etag() const { return etag_; }
107 const std::string& resource() const { return resource_id_; }
108 const std::string& id() const { return id_; } 119 const std::string& id() const { return id_; }
109 const std::string& file_md5() const { return file_md5_; } 120 const std::string& file_md5() const { return file_md5_; }
110 // Returns a bitmask of CacheState enum values. 121 // Returns a bitmask of CacheState enum values.
111 int GetCacheState(); 122 int GetCacheState();
123 const std::string& document_extension() const { return document_extension_; }
112 bool is_hosted_document() const { return is_hosted_document_; } 124 bool is_hosted_document() const { return is_hosted_document_; }
113 125
126 // GDataFileBase override.
127 virtual void UseOriginalFileName() OVERRIDE;
128
114 private: 129 private:
115 // Content URL for files. 130 // Content URL for files.
116 DocumentEntry::EntryKind kind_; 131 DocumentEntry::EntryKind kind_;
117 GURL thumbnail_url_; 132 GURL thumbnail_url_;
118 GURL edit_url_; 133 GURL edit_url_;
119 std::string content_mime_type_; 134 std::string content_mime_type_;
120 std::string etag_; 135 std::string etag_;
121 std::string resource_id_;
122 std::string id_; 136 std::string id_;
123 std::string file_md5_; 137 std::string file_md5_;
138 std::string document_extension_;
124 bool is_hosted_document_; 139 bool is_hosted_document_;
125 140
126 DISALLOW_COPY_AND_ASSIGN(GDataFile); 141 DISALLOW_COPY_AND_ASSIGN(GDataFile);
127 }; 142 };
128 143
129 // Represents "directory" in a GData virtual file system. Maps to gdata 144 // Represents "directory" in a GData virtual file system. Maps to gdata
130 // collection element. 145 // collection element.
131 class GDataDirectory : public GDataFileBase { 146 class GDataDirectory : public GDataFileBase {
132 public: 147 public:
133 explicit GDataDirectory(GDataDirectory* parent); 148 explicit GDataDirectory(GDataDirectory* parent);
134 virtual ~GDataDirectory(); 149 virtual ~GDataDirectory();
135 virtual GDataDirectory* AsGDataDirectory() OVERRIDE; 150 virtual GDataDirectory* AsGDataDirectory() OVERRIDE;
136 151
137 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, 152 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent,
138 DocumentEntry* doc); 153 DocumentEntry* doc);
139 154
140 // Adds child file to the directory and takes over the ownership of |file| 155 // Adds child file to the directory and takes over the ownership of |file|
141 // object. The method will also do name deduplication to ensure that the 156 // object. The method will also do name deduplication to ensure that the
142 // exposed presentation path does not have naming conflicts. Two files with 157 // exposed presentation path does not have naming conflicts. Two files with
143 // the same name "Foo" will be renames to "Foo (1)" and "Foo (2)". 158 // the same name "Foo" will be renames to "Foo (1)" and "Foo (2)".
144 void AddFile(GDataFileBase* file); 159 void AddFile(GDataFileBase* file);
145 160
161 // Moves the file from its children list to the children list of |dir|.
162 bool MoveFile(GDataFileBase* file, GDataDirectory* dir);
satorux1 2012/03/12 17:48:24 Instead of this, what about adding a function like
Ben Chan 2012/03/13 00:29:21 Done.
163
146 // Removes the file from its children list. 164 // Removes the file from its children list.
147 bool RemoveFile(GDataFileBase* file); 165 bool RemoveFile(GDataFileBase* file);
148 166
149 // Removes children elements. 167 // Removes children elements.
150 void RemoveChildren(); 168 void RemoveChildren();
151 169
152 // Checks if directory content needs to be retrieved again. If it does, 170 // Checks if directory content needs to be retrieved again. If it does,
153 // the function will return URL for next feed in |next_feed_url|. 171 // the function will return URL for next feed in |next_feed_url|.
154 bool NeedsRefresh(GURL* next_feed_url); 172 bool NeedsRefresh(GURL* next_feed_url);
155 173
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 ResourceMap resource_map_; 282 ResourceMap resource_map_;
265 283
266 CacheMap cache_map_; 284 CacheMap cache_map_;
267 285
268 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory); 286 DISALLOW_COPY_AND_ASSIGN(GDataRootDirectory);
269 }; 287 };
270 288
271 } // namespace gdata 289 } // namespace gdata
272 290
273 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_ 291 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698