Commit 48b6601c authored by hidehiko@chromium.org's avatar hidehiko@chromium.org

Small clean up of GDataWapiUrlGenerator.

Removed unnecessary query parameter "include-installed-apps=true" from
AddFeedUrlParams. Use base::IntToString instead of StringPrintf for trivial
case.
This is a preparation to add new method into GDataWapiUrlGenerator to support
"search by title exact match".

BUG=232352
TEST=Ran unit_tests

Review URL: https://chromiumcodereview.appspot.com/14240004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195191 0039d316-1c4b-4281-b951-d872f2087c98
parent 4d82ea81
...@@ -163,7 +163,7 @@ GetResourceListOperation::GetResourceListOperation( ...@@ -163,7 +163,7 @@ GetResourceListOperation::GetResourceListOperation(
net::URLRequestContextGetter* url_request_context_getter, net::URLRequestContextGetter* url_request_context_getter,
const GDataWapiUrlGenerator& url_generator, const GDataWapiUrlGenerator& url_generator,
const GURL& override_url, const GURL& override_url,
int start_changestamp, int64 start_changestamp,
const std::string& search_string, const std::string& search_string,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const GetResourceListCallback& callback) const GetResourceListCallback& callback)
......
...@@ -51,7 +51,7 @@ class GetResourceListOperation : public GetDataOperation { ...@@ -51,7 +51,7 @@ class GetResourceListOperation : public GetDataOperation {
net::URLRequestContextGetter* url_request_context_getter, net::URLRequestContextGetter* url_request_context_getter,
const GDataWapiUrlGenerator& url_generator, const GDataWapiUrlGenerator& url_generator,
const GURL& override_url, const GURL& override_url,
int start_changestamp, int64 start_changestamp,
const std::string& search_string, const std::string& search_string,
const std::string& directory_resource_id, const std::string& directory_resource_id,
const GetResourceListCallback& callback); const GetResourceListCallback& callback);
...@@ -64,7 +64,7 @@ class GetResourceListOperation : public GetDataOperation { ...@@ -64,7 +64,7 @@ class GetResourceListOperation : public GetDataOperation {
private: private:
const GDataWapiUrlGenerator url_generator_; const GDataWapiUrlGenerator url_generator_;
const GURL override_url_; const GURL override_url_;
const int start_changestamp_; const int64 start_changestamp_;
const std::string search_string_; const std::string search_string_;
const std::string directory_resource_id_; const std::string directory_resource_id_;
......
...@@ -339,8 +339,7 @@ TEST_F(GDataWapiOperationsTest, GetResourceListOperation_DefaultFeed) { ...@@ -339,8 +339,7 @@ TEST_F(GDataWapiOperationsTest, GetResourceListOperation_DefaultFeed) {
EXPECT_EQ(HTTP_SUCCESS, result_code); EXPECT_EQ(HTTP_SUCCESS, result_code);
EXPECT_EQ(test_server::METHOD_GET, http_request_.method); EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&" EXPECT_EQ("/feeds/default/private/full?v=3&alt=json&showroot=true&"
"showfolders=true&include-shared=true&max-results=500&" "showfolders=true&include-shared=true&max-results=500",
"include-installed-apps=true",
http_request_.relative_url); http_request_.relative_url);
// Sanity check of the result. // Sanity check of the result.
...@@ -373,8 +372,7 @@ TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) { ...@@ -373,8 +372,7 @@ TEST_F(GDataWapiOperationsTest, GetResourceListOperation_ValidFeed) {
EXPECT_EQ(HTTP_SUCCESS, result_code); EXPECT_EQ(HTTP_SUCCESS, result_code);
EXPECT_EQ(test_server::METHOD_GET, http_request_.method); EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&" EXPECT_EQ("/files/chromeos/gdata/root_feed.json?v=3&alt=json&showroot=true&"
"showfolders=true&include-shared=true&max-results=500" "showfolders=true&include-shared=true&max-results=500",
"&include-installed-apps=true",
http_request_.relative_url); http_request_.relative_url);
scoped_ptr<ResourceList> expected( scoped_ptr<ResourceList> expected(
...@@ -408,8 +406,7 @@ TEST_F(GDataWapiOperationsTest, GetResourceListOperation_InvalidFeed) { ...@@ -408,8 +406,7 @@ TEST_F(GDataWapiOperationsTest, GetResourceListOperation_InvalidFeed) {
EXPECT_EQ(GDATA_PARSE_ERROR, result_code); EXPECT_EQ(GDATA_PARSE_ERROR, result_code);
EXPECT_EQ(test_server::METHOD_GET, http_request_.method); EXPECT_EQ(test_server::METHOD_GET, http_request_.method);
EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&" EXPECT_EQ("/files/chromeos/gdata/testfile.txt?v=3&alt=json&showroot=true&"
"showfolders=true&include-shared=true&max-results=500&" "showfolders=true&include-shared=true&max-results=500",
"include-installed-apps=true",
http_request_.relative_url); http_request_.relative_url);
EXPECT_FALSE(result_data); EXPECT_FALSE(result_data);
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "base/strings/string_number_conversions.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "net/base/escape.h" #include "net/base/escape.h"
#include "net/base/url_util.h" #include "net/base/url_util.h"
...@@ -74,22 +75,17 @@ GURL GDataWapiUrlGenerator::AddInitiateUploadUrlParams(const GURL& url) { ...@@ -74,22 +75,17 @@ GURL GDataWapiUrlGenerator::AddInitiateUploadUrlParams(const GURL& url) {
GURL GDataWapiUrlGenerator::AddFeedUrlParams( GURL GDataWapiUrlGenerator::AddFeedUrlParams(
const GURL& url, const GURL& url,
int num_items_to_fetch, int num_items_to_fetch,
int changestamp, int64 changestamp,
const std::string& search_string) { const std::string& search_string) {
GURL result = AddStandardUrlParams(url); GURL result = AddStandardUrlParams(url);
result = net::AppendOrReplaceQueryParameter(result, "showfolders", "true"); result = net::AppendOrReplaceQueryParameter(result, "showfolders", "true");
result = net::AppendOrReplaceQueryParameter(result, "include-shared", "true"); result = net::AppendOrReplaceQueryParameter(result, "include-shared", "true");
result = net::AppendOrReplaceQueryParameter( result = net::AppendOrReplaceQueryParameter(
result, result, "max-results", base::IntToString(num_items_to_fetch));
"max-results",
base::StringPrintf("%d", num_items_to_fetch));
result = net::AppendOrReplaceQueryParameter(
result, "include-installed-apps", "true");
if (changestamp) { if (changestamp) {
result = net::AppendQueryParameter(result, result = net::AppendQueryParameter(
"start-index", result, "start-index", base::Int64ToString(changestamp));
base::StringPrintf("%d", changestamp));
} }
if (!search_string.empty()) { if (!search_string.empty()) {
...@@ -107,7 +103,7 @@ GDataWapiUrlGenerator::~GDataWapiUrlGenerator() { ...@@ -107,7 +103,7 @@ GDataWapiUrlGenerator::~GDataWapiUrlGenerator() {
GURL GDataWapiUrlGenerator::GenerateResourceListUrl( GURL GDataWapiUrlGenerator::GenerateResourceListUrl(
const GURL& override_url, const GURL& override_url,
int start_changestamp, int64 start_changestamp,
const std::string& search_string, const std::string& search_string,
const std::string& directory_resource_id) const { const std::string& directory_resource_id) const {
DCHECK_LE(0, start_changestamp); DCHECK_LE(0, start_changestamp);
......
...@@ -37,7 +37,7 @@ class GDataWapiUrlGenerator { ...@@ -37,7 +37,7 @@ class GDataWapiUrlGenerator {
// and adds q=... parameter if |search_string| is non-empty. // and adds q=... parameter if |search_string| is non-empty.
static GURL AddFeedUrlParams(const GURL& url, static GURL AddFeedUrlParams(const GURL& url,
int num_items_to_fetch, int num_items_to_fetch,
int changestamp, int64 changestamp,
const std::string& search_string); const std::string& search_string);
// Generates a URL for getting the resource list feed. // Generates a URL for getting the resource list feed.
...@@ -69,7 +69,7 @@ class GDataWapiUrlGenerator { ...@@ -69,7 +69,7 @@ class GDataWapiUrlGenerator {
// //
GURL GenerateResourceListUrl( GURL GenerateResourceListUrl(
const GURL& override_url, const GURL& override_url,
int start_changestamp, int64 start_changestamp,
const std::string& search_string, const std::string& search_string,
const std::string& directory_resource_id) const; const std::string& directory_resource_id) const;
......
...@@ -36,8 +36,7 @@ TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) { ...@@ -36,8 +36,7 @@ TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) {
"http://www.example.com/?v=3&alt=json&showroot=true&" "http://www.example.com/?v=3&alt=json&showroot=true&"
"showfolders=true" "showfolders=true"
"&include-shared=true" "&include-shared=true"
"&max-results=100" "&max-results=100",
"&include-installed-apps=true",
GDataWapiUrlGenerator::AddFeedUrlParams(GURL("http://www.example.com"), GDataWapiUrlGenerator::AddFeedUrlParams(GURL("http://www.example.com"),
100, // num_items_to_fetch 100, // num_items_to_fetch
0, // changestamp 0, // changestamp
...@@ -48,7 +47,6 @@ TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) { ...@@ -48,7 +47,6 @@ TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) {
"showfolders=true" "showfolders=true"
"&include-shared=true" "&include-shared=true"
"&max-results=100" "&max-results=100"
"&include-installed-apps=true"
"&start-index=123", "&start-index=123",
GDataWapiUrlGenerator::AddFeedUrlParams(GURL("http://www.example.com"), GDataWapiUrlGenerator::AddFeedUrlParams(GURL("http://www.example.com"),
100, // num_items_to_fetch 100, // num_items_to_fetch
...@@ -59,7 +57,6 @@ TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) { ...@@ -59,7 +57,6 @@ TEST_F(GDataWapiUrlGeneratorTest, AddFeedUrlParams) {
"showfolders=true" "showfolders=true"
"&include-shared=true" "&include-shared=true"
"&max-results=100" "&max-results=100"
"&include-installed-apps=true"
"&start-index=123" "&start-index=123"
"&q=%22foo+bar%22", "&q=%22foo+bar%22",
GDataWapiUrlGenerator::AddFeedUrlParams( GDataWapiUrlGenerator::AddFeedUrlParams(
...@@ -74,7 +71,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { ...@@ -74,7 +71,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) {
// This is the very basic URL for the GetResourceList operation. // This is the very basic URL for the GetResourceList operation.
EXPECT_EQ("https://docs.google.com/feeds/default/private/full" EXPECT_EQ("https://docs.google.com/feeds/default/private/full"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true" "?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500&include-installed-apps=true", "&max-results=500",
url_generator_.GenerateResourceListUrl( url_generator_.GenerateResourceListUrl(
GURL(), // override_url, GURL(), // override_url,
0, // start_changestamp, 0, // start_changestamp,
...@@ -86,7 +83,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { ...@@ -86,7 +83,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) {
// parameters remain as-is. // parameters remain as-is.
EXPECT_EQ("http://localhost/" EXPECT_EQ("http://localhost/"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true" "?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500&include-installed-apps=true", "&max-results=500",
url_generator_.GenerateResourceListUrl( url_generator_.GenerateResourceListUrl(
GURL("http://localhost/"), // override_url, GURL("http://localhost/"), // override_url,
0, // start_changestamp, 0, // start_changestamp,
...@@ -98,8 +95,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { ...@@ -98,8 +95,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) {
// "full" to "changes", and "start-index" parameter is added. // "full" to "changes", and "start-index" parameter is added.
EXPECT_EQ("https://docs.google.com/feeds/default/private/changes" EXPECT_EQ("https://docs.google.com/feeds/default/private/changes"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true" "?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500&include-installed-apps=true" "&max-results=500&start-index=100",
"&start-index=100",
url_generator_.GenerateResourceListUrl( url_generator_.GenerateResourceListUrl(
GURL(), // override_url, GURL(), // override_url,
100, // start_changestamp, 100, // start_changestamp,
...@@ -111,7 +107,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { ...@@ -111,7 +107,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) {
// and "q" parameter is added. // and "q" parameter is added.
EXPECT_EQ("https://docs.google.com/feeds/default/private/full" EXPECT_EQ("https://docs.google.com/feeds/default/private/full"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true" "?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=50&include-installed-apps=true&q=foo", "&max-results=50&q=foo",
url_generator_.GenerateResourceListUrl( url_generator_.GenerateResourceListUrl(
GURL(), // override_url, GURL(), // override_url,
0, // start_changestamp, 0, // start_changestamp,
...@@ -124,7 +120,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { ...@@ -124,7 +120,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) {
EXPECT_EQ( EXPECT_EQ(
"https://docs.google.com/feeds/default/private/full/XXX/contents" "https://docs.google.com/feeds/default/private/full/XXX/contents"
"?v=3&alt=json&showroot=true&showfolders=true&include-shared=true" "?v=3&alt=json&showroot=true&showfolders=true&include-shared=true"
"&max-results=500&include-installed-apps=true", "&max-results=500",
url_generator_.GenerateResourceListUrl(GURL(), // override_url, url_generator_.GenerateResourceListUrl(GURL(), // override_url,
0, // start_changestamp, 0, // start_changestamp,
std::string(), // search_string, std::string(), // search_string,
...@@ -136,7 +132,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) { ...@@ -136,7 +132,7 @@ TEST_F(GDataWapiUrlGeneratorTest, GenerateResourceListUrl) {
// overridden. // overridden.
EXPECT_EQ("http://example.com/" EXPECT_EQ("http://example.com/"
"?start-index=123&v=3&alt=json&showroot=true&showfolders=true" "?start-index=123&v=3&alt=json&showroot=true&showfolders=true"
"&include-shared=true&max-results=500&include-installed-apps=true", "&include-shared=true&max-results=500",
url_generator_.GenerateResourceListUrl( url_generator_.GenerateResourceListUrl(
GURL("http://example.com/?start-index=123"), // override_url, GURL("http://example.com/?start-index=123"), // override_url,
100, // start_changestamp, 100, // start_changestamp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment