Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // URL utility functions for Google Documents List API (aka WAPI). | 5 // URL utility functions for Google Documents List API (aka WAPI). |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ | 7 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_ |
| 8 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ | 8 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 | 13 |
| 14 namespace google_apis { | 14 namespace google_apis { |
| 15 namespace gdata_wapi_url_util { | |
| 16 | 15 |
| 17 // The base URL for communicating with the WAPI server for production. | |
| 18 extern const char kBaseUrlForProduction[]; | |
| 19 | |
| 20 // The base URL for communicating with the local test server for testing. | |
| 21 extern const char kBaseUrlForTesting[]; | |
| 22 | |
| 23 // Adds additional parameters for API version, output content type and to show | |
| 24 // folders in the feed are added to document feed URLs. | |
| 25 GURL AddStandardUrlParams(const GURL& url); | |
| 26 | |
| 27 // Adds additional parameters to metadata feed to include installed 3rd party | |
| 28 // applications. | |
| 29 GURL AddMetadataUrlParams(const GURL& url); | |
| 30 | |
| 31 // Adds additional parameters for API version, output content type and to show | |
| 32 // folders in the feed are added to document feed URLs. | |
| 33 // Optionally, adds start-index=... parameter if |changestamp| is non-zero, | |
| 34 // and adds q=... parameter if |search_string| is non-empty. | |
| 35 GURL AddFeedUrlParams(const GURL& url, | |
| 36 int num_items_to_fetch, | |
| 37 int changestamp, | |
| 38 const std::string& search_string); | |
| 39 | |
| 40 } // namespace gdata_wapi_url_util | |
| 41 | |
| 42 // TODO(satorux): Move the class to a separate file gdata_wapi_url_generator.h. | |
| 43 // | |
| 44 // The class is used to generate URLs for communicating with the WAPI server. | 16 // The class is used to generate URLs for communicating with the WAPI server. |
| 45 // for production, and the local server for testing. | 17 // for production, and the local server for testing. |
| 46 class GDataWapiUrlGenerator { | 18 class GDataWapiUrlGenerator { |
| 47 public: | 19 public: |
| 48 explicit GDataWapiUrlGenerator(const GURL& base_url); | 20 explicit GDataWapiUrlGenerator(const GURL& base_url); |
| 49 ~GDataWapiUrlGenerator(); | 21 ~GDataWapiUrlGenerator(); |
| 50 | 22 |
| 23 // The base URL for communicating with the WAPI server for production. | |
| 24 static const char kBaseUrlForProduction[]; | |
|
hashimoto
2012/11/21 03:37:44
How about having static methods which return GURL
satorux1
2012/11/21 04:05:38
I thought about it but went with constants. Functi
| |
| 25 | |
| 26 // The base URL for communicating with the local test server for testing. | |
| 27 static const char kBaseUrlForTesting[]; | |
| 28 | |
| 29 // Adds additional parameters for API version, output content type and to | |
| 30 // show folders in the feed are added to document feed URLs. | |
| 31 static GURL AddStandardUrlParams(const GURL& url); | |
| 32 | |
| 33 // Adds additional parameters to metadata feed to include installed 3rd | |
| 34 // party applications. | |
| 35 static GURL AddMetadataUrlParams(const GURL& url); | |
| 36 | |
| 37 // Adds additional parameters for API version, output content type and to | |
| 38 // show folders in the feed are added to document feed URLs. | |
| 39 // Optionally, adds start-index=... parameter if |changestamp| is non-zero, | |
| 40 // and adds q=... parameter if |search_string| is non-empty. | |
| 41 static GURL AddFeedUrlParams(const GURL& url, | |
| 42 int num_items_to_fetch, | |
| 43 int changestamp, | |
| 44 const std::string& search_string); | |
| 45 | |
| 51 // Generates a URL for getting the documents list feed. | 46 // Generates a URL for getting the documents list feed. |
| 52 // | 47 // |
| 53 // override_url: | 48 // override_url: |
| 54 // By default, a hard-coded base URL of the WAPI server is used. | 49 // By default, a hard-coded base URL of the WAPI server is used. |
| 55 // The base URL can be overridden by |override_url|. | 50 // The base URL can be overridden by |override_url|. |
| 56 // This is used for handling continuation of feeds (2nd page and onward). | 51 // This is used for handling continuation of feeds (2nd page and onward). |
| 57 // | 52 // |
| 58 // start_changestamp | 53 // start_changestamp |
| 59 // If |start_changestamp| is 0, URL for a full feed is generated. | 54 // If |start_changestamp| is 0, URL for a full feed is generated. |
| 60 // If |start_changestamp| is non-zero, URL for a delta feed is generated. | 55 // If |start_changestamp| is non-zero, URL for a delta feed is generated. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 88 | 83 |
| 89 // Generates a URL for getting the account metadata feed. | 84 // Generates a URL for getting the account metadata feed. |
| 90 GURL GenerateAccountMetadataUrl() const; | 85 GURL GenerateAccountMetadataUrl() const; |
| 91 | 86 |
| 92 private: | 87 private: |
| 93 const GURL base_url_; | 88 const GURL base_url_; |
| 94 }; | 89 }; |
| 95 | 90 |
| 96 } // namespace google_apis | 91 } // namespace google_apis |
| 97 | 92 |
| 98 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ | 93 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_ |
| OLD | NEW |