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

Unified Diff: chrome/browser/chromeos/gdata/gdata_util.cc

Issue 10274002: Add gdata content search (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: style nits Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gdata/gdata_util.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_util.cc b/chrome/browser/chromeos/gdata/gdata_util.cc
index 822aba07208b48a68222a45b3005605bcdb96b1b..fc767692b9fcd29e835f402e61bf667bfeccc058 100644
--- a/chrome/browser/chromeos/gdata/gdata_util.cc
+++ b/chrome/browser/chromeos/gdata/gdata_util.cc
@@ -47,6 +47,10 @@ const FilePath::CharType* kGDataMountPointPathComponents[] = {
"/", "special", "gdata"
};
+const FilePath::CharType* kGDataSearchPathComponents[] = {
+ "gdata", ".search"
+};
+
const int kReadOnlyFilePermissions = base::PLATFORM_FILE_OPEN |
base::PLATFORM_FILE_READ |
base::PLATFORM_FILE_EXCLUSIVE_READ |
@@ -175,6 +179,53 @@ bool IsUnderGDataMountPoint(const FilePath& path) {
GetGDataMountPointPath().IsParent(path);
}
+GDataSearchPathType GetSearchPathStatus(const FilePath& path) {
+ std::vector<std::string> components;
+ path.GetComponents(&components);
+ return GetSearchPathStatusForPathComponents(components);
+}
+
+GDataSearchPathType GetSearchPathStatusForPathComponents(
+ const std::vector<std::string>& path_components) {
+ if (path_components.size() < arraysize(kGDataSearchPathComponents))
+ return GDATA_SEARCH_PATH_INVALID;
+
+ for (size_t i = 0; i < arraysize(kGDataSearchPathComponents); i++) {
+ if (path_components[i] != kGDataSearchPathComponents[i])
+ return GDATA_SEARCH_PATH_INVALID;
+ }
+
+ switch (path_components.size()) {
+ case 2:
+ return GDATA_SEARCH_PATH_ROOT;
+ case 3:
+ return GDATA_SEARCH_PATH_QUERY;
+ case 4:
+ return GDATA_SEARCH_PATH_RESULT;
+ default:
+ return GDATA_SEARCH_PATH_RESULT_CHILD;
+ }
+}
+
+bool ParseSearchFileName(const std::string& search_file_name,
+ std::string* resource_id,
+ std::string* original_file_name) {
+ DCHECK(resource_id);
+ DCHECK(original_file_name);
+
+ *resource_id = "";
+ *original_file_name = "";
+
+ size_t dot_index = search_file_name.find('.');
+ if (dot_index == std::string::npos)
+ return false;
+
+ *resource_id = search_file_name.substr(0, dot_index);
+ if (search_file_name.length() - 1 > dot_index)
+ *original_file_name = search_file_name.substr(dot_index + 1);
+ return (!resource_id->empty() && !original_file_name->empty());
+}
+
FilePath ExtractGDataPath(const FilePath& path) {
if (!IsUnderGDataMountPoint(path))
return FilePath();
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_util.h ('k') | chrome/browser/chromeos/gdata/mock_gdata_documents_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698