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

Unified Diff: chrome/browser/google_apis/gdata_wapi_url_util.cc

Issue 11316097: google_apis: Rename and simplify GenerateGetDocumentsURL() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years, 1 month 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/google_apis/gdata_wapi_url_util.cc
diff --git a/chrome/browser/google_apis/gdata_wapi_url_util.cc b/chrome/browser/google_apis/gdata_wapi_url_util.cc
index 21e8970ba9dbc60af437822d98e96ca5636fa7ea..a9a945b90f104a55141fbf45d8ee6876a2ee58e0 100644
--- a/chrome/browser/google_apis/gdata_wapi_url_util.cc
+++ b/chrome/browser/google_apis/gdata_wapi_url_util.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/google_apis/gdata_wapi_url_util.h"
+#include "base/logging.h"
#include "base/stringprintf.h"
#include "chrome/common/net/url_util.h"
#include "googleurl/src/gurl.h"
@@ -43,19 +44,6 @@ const char kGetDocumentListURLForSharedWithMe[] =
const char kGetChangesListURL[] =
"https://docs.google.com/feeds/default/private/changes";
-// Generates a URL for getting document list. If |directory_resource_id| is
-// empty, returns a URL for fetching all documents. If it's given, returns a
-// URL for fetching documents in a particular directory.
-// This function is used to implement GenerateGetDocumentsURL().
-GURL GenerateDocumentListURL(const std::string& directory_resource_id) {
- if (directory_resource_id.empty())
- return GURL(kGetDocumentListURLForAllDocuments);
-
- return GURL(base::StringPrintf(kGetDocumentListURLForDirectoryFormat,
- net::EscapePath(
- directory_resource_id).c_str()));
-}
-
} // namespace
GURL AddStandardUrlParams(const GURL& url) {
@@ -103,7 +91,7 @@ GURL AddFeedUrlParams(const GURL& url,
return result;
}
-GURL GenerateGetDocumentsURL(
+GURL GenerateDocumentListUrl(
const GURL& override_url,
int start_changestamp,
const std::string& search_string,
@@ -111,34 +99,25 @@ GURL GenerateGetDocumentsURL(
const std::string& directory_resource_id) {
int max_docs = search_string.empty() ? kMaxDocumentsPerFeed :
kMaxDocumentsPerSearchFeed;
-
- if (!override_url.is_empty())
- return gdata_wapi_url_util::AddFeedUrlParams(override_url,
- max_docs,
- 0,
- search_string);
-
- if (shared_with_me) {
- return gdata_wapi_url_util::AddFeedUrlParams(
- GURL(kGetDocumentListURLForSharedWithMe),
- max_docs,
- 0,
- search_string);
+ GURL url;
+ if (!override_url.is_empty()) {
+ url = override_url;
+ } else if (shared_with_me) {
+ url = GURL(kGetDocumentListURLForSharedWithMe);
+ } else if (start_changestamp > 0) {
hashimoto 2012/11/20 06:16:06 Ah, sorry, '!= 0' and DCHECK_LE(0, start_changesta
satorux1 2012/11/20 06:27:33 Added a DCHECK at the beginning of the function.
+ // The start changestamp shouldn't be used for a search.
+ DCHECK(search_string.empty());
+ url = GURL(kGetChangesListURL);
+ } else if (!directory_resource_id.empty()) {
+ DCHECK_EQ(0, start_changestamp);
+ url = GURL(base::StringPrintf(kGetDocumentListURLForDirectoryFormat,
+ net::EscapePath(
+ directory_resource_id).c_str()));
+ } else {
+ DCHECK_EQ(0, start_changestamp);
+ url = GURL(kGetDocumentListURLForAllDocuments);
}
-
- if (start_changestamp == 0) {
- return gdata_wapi_url_util::AddFeedUrlParams(
- gdata_wapi_url_util::GenerateDocumentListURL(directory_resource_id),
- max_docs,
- 0,
- search_string);
- }
-
- return gdata_wapi_url_util::AddFeedUrlParams(
- GURL(kGetChangesListURL),
- kMaxDocumentsPerFeed,
- start_changestamp,
- std::string());
+ return AddFeedUrlParams(url, max_docs, start_changestamp, search_string);
}
} // namespace gdata_wapi_url_util
« no previous file with comments | « chrome/browser/google_apis/gdata_wapi_url_util.h ('k') | chrome/browser/google_apis/gdata_wapi_url_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698