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

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

Issue 10905142: Rename GData to Drive in drive_file_system_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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_DRIVE_FILE_SYSTEM_UTIL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_UTIL_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_UTIL_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 15 matching lines...) Expand all
26 // "<resource-id>.local". 26 // "<resource-id>.local".
27 const char kLocallyModifiedFileExtension[] = "local"; 27 const char kLocallyModifiedFileExtension[] = "local";
28 // The extension for mounted files. The file names look like 28 // The extension for mounted files. The file names look like
29 // "<resource-id>.<md5>.mounted". 29 // "<resource-id>.<md5>.mounted".
30 const char kMountedArchiveFileExtension[] = "mounted"; 30 const char kMountedArchiveFileExtension[] = "mounted";
31 const char kWildCard[] = "*"; 31 const char kWildCard[] = "*";
32 // The path is used for creating a symlink in "pinned" directory for a file 32 // The path is used for creating a symlink in "pinned" directory for a file
33 // which is not yet fetched. 33 // which is not yet fetched.
34 const char kSymLinkToDevNull[] = "/dev/null"; 34 const char kSymLinkToDevNull[] = "/dev/null";
35 35
36 // Returns the GData mount point path, which looks like "/special/gdata". 36 // Returns the Drive mount point path, which looks like "/special/gdata".
37 const FilePath& GetGDataMountPointPath(); 37 const FilePath& GetDriveMountPointPath();
38 38
39 // Returns the GData mount path as string. 39 // Returns the Drive mount path as string.
40 const std::string& GetGDataMountPointPathAsString(); 40 const std::string& GetDriveMountPointPathAsString();
41 41
42 // Returns the 'local' root of remote file system as "/special". 42 // Returns the 'local' root of remote file system as "/special".
43 const FilePath& GetSpecialRemoteRootPath(); 43 const FilePath& GetSpecialRemoteRootPath();
44 44
45 // Returns the gdata file resource url formatted as 45 // Returns the gdata file resource url formatted as
46 // chrome://drive/<resource_id>/<file_name>. 46 // chrome://drive/<resource_id>/<file_name>.
47 GURL GetFileResourceUrl(const std::string& resource_id, 47 GURL GetFileResourceUrl(const std::string& resource_id,
48 const std::string& file_name); 48 const std::string& file_name);
49 49
50 // Given a profile and a drive_cache_path, return the file resource url. 50 // Given a profile and a drive_cache_path, return the file resource url.
51 void ModifyGDataFileResourceUrl(Profile* profile, 51 void ModifyDriveFileResourceUrl(Profile* profile,
52 const FilePath& drive_cache_path, 52 const FilePath& drive_cache_path,
53 GURL* url); 53 GURL* url);
54 54
55 // Returns true if the given path is under the GData mount point. 55 // Returns true if the given path is under the Drive mount point.
56 bool IsUnderGDataMountPoint(const FilePath& path); 56 bool IsUnderDriveMountPoint(const FilePath& path);
57 57
58 // Extracts the GData path from the given path located under the GData mount 58 // Extracts the Drive path from the given path located under the Drive mount
59 // point. Returns an empty path if |path| is not under the GData mount point. 59 // point. Returns an empty path if |path| is not under the Drive mount point.
60 // Examples: ExtractGDatPath("/special/drive/foo.txt") => "drive/foo.txt" 60 // Examples: ExtractGDatPath("/special/drive/foo.txt") => "drive/foo.txt"
61 FilePath ExtractGDataPath(const FilePath& path); 61 FilePath ExtractDrivePath(const FilePath& path);
62 62
63 // Inserts all possible cache paths for a given vector of paths on gdata mount 63 // Inserts all possible cache paths for a given vector of paths on gdata mount
64 // point into the output vector |cache_paths|, and then invokes callback. 64 // point into the output vector |cache_paths|, and then invokes callback.
65 // Caller must ensure that |cache_paths| lives until the callback is invoked. 65 // Caller must ensure that |cache_paths| lives until the callback is invoked.
66 void InsertDriveCachePathsPermissions( 66 void InsertDriveCachePathsPermissions(
67 Profile* profile_, 67 Profile* profile_,
68 scoped_ptr<std::vector<FilePath> > gdata_paths, 68 scoped_ptr<std::vector<FilePath> > gdata_paths,
69 std::vector<std::pair<FilePath, int> >* cache_paths, 69 std::vector<std::pair<FilePath, int> >* cache_paths,
70 const base::Closure& callback); 70 const base::Closure& callback);
71 71
72 // Escapes a file name in GData cache. 72 // Escapes a file name in Drive cache.
73 // Replaces percent ('%'), period ('.') and slash ('/') with %XX (hex) 73 // Replaces percent ('%'), period ('.') and slash ('/') with %XX (hex)
74 std::string EscapeCacheFileName(const std::string& filename); 74 std::string EscapeCacheFileName(const std::string& filename);
75 75
76 // Unescapes a file path in GData cache. 76 // Unescapes a file path in Drive cache.
77 // This is the inverse of EscapeCacheFileName. 77 // This is the inverse of EscapeCacheFileName.
78 std::string UnescapeCacheFileName(const std::string& filename); 78 std::string UnescapeCacheFileName(const std::string& filename);
79 79
80 // Extracts resource_id, md5, and extra_extension from cache path. 80 // Extracts resource_id, md5, and extra_extension from cache path.
81 // Case 1: Pinned and outgoing symlinks only have resource_id. 81 // Case 1: Pinned and outgoing symlinks only have resource_id.
82 // Example: path="/user/GCache/v1/pinned/pdf:a1b2" => 82 // Example: path="/user/GCache/v1/pinned/pdf:a1b2" =>
83 // resource_id="pdf:a1b2", md5="", extra_extension=""; 83 // resource_id="pdf:a1b2", md5="", extra_extension="";
84 // Case 2: Normal files have both resource_id and md5. 84 // Case 2: Normal files have both resource_id and md5.
85 // Example: path="/user/GCache/v1/tmp/pdf:a1b2.01234567" => 85 // Example: path="/user/GCache/v1/tmp/pdf:a1b2.01234567" =>
86 // resource_id="pdf:a1b2", md5="01234567", extra_extension=""; 86 // resource_id="pdf:a1b2", md5="01234567", extra_extension="";
87 // Case 3: Mounted files have all three parts. 87 // Case 3: Mounted files have all three parts.
88 // Example: path="/user/GCache/v1/persistent/pdf:a1b2.01234567.mounted" => 88 // Example: path="/user/GCache/v1/persistent/pdf:a1b2.01234567.mounted" =>
89 // resource_id="pdf:a1b2", md5="01234567", extra_extension="mounted". 89 // resource_id="pdf:a1b2", md5="01234567", extra_extension="mounted".
90 void ParseCacheFilePath(const FilePath& path, 90 void ParseCacheFilePath(const FilePath& path,
91 std::string* resource_id, 91 std::string* resource_id,
92 std::string* md5, 92 std::string* md5,
93 std::string* extra_extension); 93 std::string* extra_extension);
94 94
95 // Callback type for PrepareWritableFilePathAndRun. 95 // Callback type for PrepareWritableFilePathAndRun.
96 typedef base::Callback<void (DriveFileError, const FilePath& path)> 96 typedef base::Callback<void (DriveFileError, const FilePath& path)>
97 OpenFileCallback; 97 OpenFileCallback;
98 98
99 // Invokes |callback| on blocking thread pool, after converting virtual |path| 99 // Invokes |callback| on blocking thread pool, after converting virtual |path|
100 // string like "/special/drive/foo.txt" to the concrete local cache file path. 100 // string like "/special/drive/foo.txt" to the concrete local cache file path.
101 // After |callback| returns, the written content is synchronized to the server. 101 // After |callback| returns, the written content is synchronized to the server.
102 // 102 //
103 // If |path| is not a GData path, it is regarded as a local path and no path 103 // If |path| is not a Drive path, it is regarded as a local path and no path
104 // conversion takes place. 104 // conversion takes place.
105 // 105 //
106 // Must be called from UI thread. 106 // Must be called from UI thread.
107 void PrepareWritableFileAndRun(Profile* profile, 107 void PrepareWritableFileAndRun(Profile* profile,
108 const FilePath& path, 108 const FilePath& path,
109 const OpenFileCallback& callback); 109 const OpenFileCallback& callback);
110 110
111 // Converts GData error code into file platform error code. 111 // Converts GData error code into file platform error code.
112 DriveFileError GDataToDriveFileError(GDataErrorCode status); 112 DriveFileError GDataToDriveFileError(GDataErrorCode status);
113 113
114 } // namespace util 114 } // namespace util
115 } // namespace gdata 115 } // namespace gdata
116 116
117 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_UTIL_H_ 117 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_FILE_SYSTEM_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_download_observer.cc ('k') | chrome/browser/chromeos/gdata/drive_file_system_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698