| Index: chrome/browser/chromeos/gdata/gdata_files.h
|
| ===================================================================
|
| --- chrome/browser/chromeos/gdata/gdata_files.h (revision 126271)
|
| +++ chrome/browser/chromeos/gdata/gdata_files.h (working copy)
|
| @@ -5,9 +5,11 @@
|
| #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_
|
| #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILES_H_
|
|
|
| -#include <map>
|
| #include <sys/stat.h>
|
|
|
| +#include <map>
|
| +#include <string>
|
| +
|
| #include "base/gtest_prod_util.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/singleton.h"
|
| @@ -39,7 +41,12 @@
|
| // Converts DocumentEntry into GDataFileBase.
|
| static GDataFileBase* FromDocumentEntry(GDataDirectory* parent,
|
| DocumentEntry* doc);
|
| +
|
| + // Escapes forward slashes from file names with magic unicode character
|
| + // \u2215 pretty much looks the same in UI.
|
| static std::string EscapeUtf8FileName(const std::string& input);
|
| +
|
| + // Unescapes what was escaped in EScapeUtf8FileName.
|
| static std::string UnescapeUtf8FileName(const std::string& input);
|
|
|
| GDataDirectory* parent() { return parent_; }
|
| @@ -48,8 +55,14 @@
|
| const FilePath::StringType& original_file_name() const {
|
| return original_file_name_;
|
| }
|
| + void set_original_file_name(const FilePath::StringType& name) {
|
| + original_file_name_ = name;
|
| + }
|
| void set_file_name(const FilePath::StringType& name) { file_name_ = name; }
|
|
|
| + // The unique resource ID associated with this file system entry.
|
| + const std::string& resource_id() const { return resource_id_; }
|
| +
|
| // The content URL is used for downloading regular files as is.
|
| const GURL& content_url() const { return content_url_; }
|
|
|
| @@ -61,10 +74,26 @@
|
| // class.
|
| FilePath GetFilePath();
|
|
|
| + // Restores |file_name_| to the original file name before de-duplication.
|
| + virtual void UseOriginalFileName();
|
| +
|
| protected:
|
| + // GDataDirectory::TakeFile() needs to call GDataFileBase::set_parent().
|
| + friend class GDataDirectory;
|
| +
|
| + // Sets the parent directory of this file system entry.
|
| + // It is intended to be used by GDataDirectory::TakeFile() only.
|
| + void set_parent(GDataDirectory* parent) { parent_ = parent; }
|
| +
|
| base::PlatformFileInfo file_info_;
|
| + // Name of this file in the gdata virtual file system.
|
| FilePath::StringType file_name_;
|
| + // Original name of this file, which is used to refer to the 'title' of
|
| + // a regular file or hosted document. The original name may be different
|
| + // from |file_name_| due to the added .g<something> extension for hosted
|
| + // documents or name de-duplication on the gdata file system.
|
| FilePath::StringType original_file_name_;
|
| + std::string resource_id_;
|
| // Files with the same original name will be uniquely identified with this
|
| // field so we can represent them with unique URLs/paths in File API layer.
|
| // For example, two files in the same directory with the same name "Foo"
|
| @@ -104,13 +133,16 @@
|
| const GURL& edit_url() const { return edit_url_; }
|
| const std::string& content_mime_type() const { return content_mime_type_; }
|
| const std::string& etag() const { return etag_; }
|
| - const std::string& resource() const { return resource_id_; }
|
| const std::string& id() const { return id_; }
|
| const std::string& file_md5() const { return file_md5_; }
|
| // Returns a bitmask of CacheState enum values.
|
| int GetCacheState();
|
| + const std::string& document_extension() const { return document_extension_; }
|
| bool is_hosted_document() const { return is_hosted_document_; }
|
|
|
| + // GDataFileBase override.
|
| + virtual void UseOriginalFileName() OVERRIDE;
|
| +
|
| private:
|
| // Content URL for files.
|
| DocumentEntry::EntryKind kind_;
|
| @@ -118,9 +150,9 @@
|
| GURL edit_url_;
|
| std::string content_mime_type_;
|
| std::string etag_;
|
| - std::string resource_id_;
|
| std::string id_;
|
| std::string file_md5_;
|
| + std::string document_extension_;
|
| bool is_hosted_document_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(GDataFile);
|
| @@ -138,12 +170,18 @@
|
| DocumentEntry* doc);
|
|
|
| // Adds child file to the directory and takes over the ownership of |file|
|
| - // object. The method will also do name deduplication to ensure that the
|
| + // object. The method will also do name de-duplication to ensure that the
|
| // exposed presentation path does not have naming conflicts. Two files with
|
| // the same name "Foo" will be renames to "Foo (1)" and "Foo (2)".
|
| void AddFile(GDataFileBase* file);
|
|
|
| - // Removes the file from its children list.
|
| + // Takes the ownership of |file| from its current parent. If this directory
|
| + // is already the current parent of |file|, this method effectively goes
|
| + // through the name de-duplication for |file| based on the current state of
|
| + // the file system.
|
| + bool TakeFile(GDataFileBase* file);
|
| +
|
| + // Removes the file from its children list and destroys the file instance.
|
| bool RemoveFile(GDataFileBase* file);
|
|
|
| // Removes children elements.
|
| @@ -170,6 +208,10 @@
|
| const GDataFileCollection& children() const { return children_; }
|
|
|
| private:
|
| + // Removes the file from its children list without destroying the
|
| + // file instance.
|
| + bool RemoveFileFromChildrenList(GDataFileBase* file);
|
| +
|
| base::Time refresh_time_;
|
| // Url for this feed.
|
| GURL start_feed_url_;
|
|
|