| 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 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_REQUESTS_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_REQUESTS_H_ |
| 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_REQUESTS_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_REQUESTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "chrome/browser/google_apis/base_requests.h" | 11 #include "chrome/browser/google_apis/base_requests.h" |
| 12 #include "chrome/browser/google_apis/drive_common_callbacks.h" | 12 #include "chrome/browser/google_apis/drive_common_callbacks.h" |
| 13 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" | 13 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" |
| 14 | 14 |
| 15 namespace net { | |
| 16 class URLRequestContextGetter; | |
| 17 } // namespace net | |
| 18 | |
| 19 namespace google_apis { | 15 namespace google_apis { |
| 20 | 16 |
| 21 class AccountMetadata; | 17 class AccountMetadata; |
| 22 class GDataWapiUrlGenerator; | 18 class GDataWapiUrlGenerator; |
| 23 class ResourceEntry; | 19 class ResourceEntry; |
| 24 | 20 |
| 25 //============================ GetResourceListRequest ======================== | 21 //============================ GetResourceListRequest ======================== |
| 26 | 22 |
| 27 // This class performs the request for fetching a resource list. | 23 // This class performs the request for fetching a resource list. |
| 28 class GetResourceListRequest : public GetDataRequest { | 24 class GetResourceListRequest : public GetDataRequest { |
| 29 public: | 25 public: |
| 30 // override_url: | 26 // override_url: |
| 31 // If empty, a hard-coded base URL of the WAPI server is used to fetch | 27 // If empty, a hard-coded base URL of the WAPI server is used to fetch |
| 32 // the first page of the feed. This parameter is used for fetching 2nd | 28 // the first page of the feed. This parameter is used for fetching 2nd |
| 33 // page and onward. | 29 // page and onward. |
| 34 // | 30 // |
| 35 // start_changestamp: | 31 // start_changestamp: |
| 36 // This parameter specifies the starting point of a delta feed or 0 if a | 32 // This parameter specifies the starting point of a delta feed or 0 if a |
| 37 // full feed is necessary. | 33 // full feed is necessary. |
| 38 // | 34 // |
| 39 // search_string: | 35 // search_string: |
| 40 // If non-empty, fetches a list of resources that match the search | 36 // If non-empty, fetches a list of resources that match the search |
| 41 // string. | 37 // string. |
| 42 // | 38 // |
| 43 // directory_resource_id: | 39 // directory_resource_id: |
| 44 // If non-empty, fetches a list of resources in a particular directory. | 40 // If non-empty, fetches a list of resources in a particular directory. |
| 45 // | 41 // |
| 46 // callback: | 42 // callback: |
| 47 // Called once the feed is fetched. Must not be null. | 43 // Called once the feed is fetched. Must not be null. |
| 48 GetResourceListRequest( | 44 GetResourceListRequest(RequestSender* sender, |
| 49 RequestSender* runner, | 45 const GDataWapiUrlGenerator& url_generator, |
| 50 net::URLRequestContextGetter* url_request_context_getter, | 46 const GURL& override_url, |
| 51 const GDataWapiUrlGenerator& url_generator, | 47 int64 start_changestamp, |
| 52 const GURL& override_url, | 48 const std::string& search_string, |
| 53 int64 start_changestamp, | 49 const std::string& directory_resource_id, |
| 54 const std::string& search_string, | 50 const GetResourceListCallback& callback); |
| 55 const std::string& directory_resource_id, | |
| 56 const GetResourceListCallback& callback); | |
| 57 virtual ~GetResourceListRequest(); | 51 virtual ~GetResourceListRequest(); |
| 58 | 52 |
| 59 protected: | 53 protected: |
| 60 // UrlFetchRequestBase overrides. | 54 // UrlFetchRequestBase overrides. |
| 61 virtual GURL GetURL() const OVERRIDE; | 55 virtual GURL GetURL() const OVERRIDE; |
| 62 | 56 |
| 63 private: | 57 private: |
| 64 const GDataWapiUrlGenerator url_generator_; | 58 const GDataWapiUrlGenerator url_generator_; |
| 65 const GURL override_url_; | 59 const GURL override_url_; |
| 66 const int64 start_changestamp_; | 60 const int64 start_changestamp_; |
| 67 const std::string search_string_; | 61 const std::string search_string_; |
| 68 const std::string directory_resource_id_; | 62 const std::string directory_resource_id_; |
| 69 | 63 |
| 70 DISALLOW_COPY_AND_ASSIGN(GetResourceListRequest); | 64 DISALLOW_COPY_AND_ASSIGN(GetResourceListRequest); |
| 71 }; | 65 }; |
| 72 | 66 |
| 73 //============================ SearchByTitleRequest ========================== | 67 //============================ SearchByTitleRequest ========================== |
| 74 | 68 |
| 75 // This class performs the request for searching resources by title. | 69 // This class performs the request for searching resources by title. |
| 76 class SearchByTitleRequest : public GetDataRequest { | 70 class SearchByTitleRequest : public GetDataRequest { |
| 77 public: | 71 public: |
| 78 // title: the search query. | 72 // title: the search query. |
| 79 // | 73 // |
| 80 // directory_resource_id: If given (non-empty), the search target is | 74 // directory_resource_id: If given (non-empty), the search target is |
| 81 // directly under the directory with the |directory_resource_id|. | 75 // directly under the directory with the |directory_resource_id|. |
| 82 // If empty, the search target is all the existing resources. | 76 // If empty, the search target is all the existing resources. |
| 83 // | 77 // |
| 84 // callback: | 78 // callback: |
| 85 // Called once the feed is fetched. Must not be null. | 79 // Called once the feed is fetched. Must not be null. |
| 86 SearchByTitleRequest( | 80 SearchByTitleRequest(RequestSender* sender, |
| 87 RequestSender* runner, | 81 const GDataWapiUrlGenerator& url_generator, |
| 88 net::URLRequestContextGetter* url_request_context_getter, | 82 const std::string& title, |
| 89 const GDataWapiUrlGenerator& url_generator, | 83 const std::string& directory_resource_id, |
| 90 const std::string& title, | 84 const GetResourceListCallback& callback); |
| 91 const std::string& directory_resource_id, | |
| 92 const GetResourceListCallback& callback); | |
| 93 virtual ~SearchByTitleRequest(); | 85 virtual ~SearchByTitleRequest(); |
| 94 | 86 |
| 95 protected: | 87 protected: |
| 96 // UrlFetchRequestBase overrides. | 88 // UrlFetchRequestBase overrides. |
| 97 virtual GURL GetURL() const OVERRIDE; | 89 virtual GURL GetURL() const OVERRIDE; |
| 98 | 90 |
| 99 private: | 91 private: |
| 100 const GDataWapiUrlGenerator url_generator_; | 92 const GDataWapiUrlGenerator url_generator_; |
| 101 const std::string title_; | 93 const std::string title_; |
| 102 const std::string directory_resource_id_; | 94 const std::string directory_resource_id_; |
| 103 | 95 |
| 104 DISALLOW_COPY_AND_ASSIGN(SearchByTitleRequest); | 96 DISALLOW_COPY_AND_ASSIGN(SearchByTitleRequest); |
| 105 }; | 97 }; |
| 106 | 98 |
| 107 //========================= GetResourceEntryRequest ========================== | 99 //========================= GetResourceEntryRequest ========================== |
| 108 | 100 |
| 109 // This class performs the request for fetching a single resource entry. | 101 // This class performs the request for fetching a single resource entry. |
| 110 class GetResourceEntryRequest : public GetDataRequest { | 102 class GetResourceEntryRequest : public GetDataRequest { |
| 111 public: | 103 public: |
| 112 // |callback| must not be null. | 104 // |callback| must not be null. |
| 113 GetResourceEntryRequest( | 105 GetResourceEntryRequest(RequestSender* sender, |
| 114 RequestSender* runner, | 106 const GDataWapiUrlGenerator& url_generator, |
| 115 net::URLRequestContextGetter* url_request_context_getter, | 107 const std::string& resource_id, |
| 116 const GDataWapiUrlGenerator& url_generator, | 108 const GetDataCallback& callback); |
| 117 const std::string& resource_id, | |
| 118 const GetDataCallback& callback); | |
| 119 virtual ~GetResourceEntryRequest(); | 109 virtual ~GetResourceEntryRequest(); |
| 120 | 110 |
| 121 protected: | 111 protected: |
| 122 // UrlFetchRequestBase overrides. | 112 // UrlFetchRequestBase overrides. |
| 123 virtual GURL GetURL() const OVERRIDE; | 113 virtual GURL GetURL() const OVERRIDE; |
| 124 | 114 |
| 125 private: | 115 private: |
| 126 const GDataWapiUrlGenerator url_generator_; | 116 const GDataWapiUrlGenerator url_generator_; |
| 127 // Resource id of the requested entry. | 117 // Resource id of the requested entry. |
| 128 const std::string resource_id_; | 118 const std::string resource_id_; |
| 129 | 119 |
| 130 DISALLOW_COPY_AND_ASSIGN(GetResourceEntryRequest); | 120 DISALLOW_COPY_AND_ASSIGN(GetResourceEntryRequest); |
| 131 }; | 121 }; |
| 132 | 122 |
| 133 //========================= GetAccountMetadataRequest ======================== | 123 //========================= GetAccountMetadataRequest ======================== |
| 134 | 124 |
| 135 // Callback used for GetAccountMetadata(). | 125 // Callback used for GetAccountMetadata(). |
| 136 typedef base::Callback<void(GDataErrorCode error, | 126 typedef base::Callback<void(GDataErrorCode error, |
| 137 scoped_ptr<AccountMetadata> account_metadata)> | 127 scoped_ptr<AccountMetadata> account_metadata)> |
| 138 GetAccountMetadataCallback; | 128 GetAccountMetadataCallback; |
| 139 | 129 |
| 140 // This class performs the request for fetching account metadata. | 130 // This class performs the request for fetching account metadata. |
| 141 class GetAccountMetadataRequest : public GetDataRequest { | 131 class GetAccountMetadataRequest : public GetDataRequest { |
| 142 public: | 132 public: |
| 143 // If |include_installed_apps| is set to true, the result should include | 133 // If |include_installed_apps| is set to true, the result should include |
| 144 // the list of installed third party applications. | 134 // the list of installed third party applications. |
| 145 // |callback| must not be null. | 135 // |callback| must not be null. |
| 146 GetAccountMetadataRequest( | 136 GetAccountMetadataRequest(RequestSender* sender, |
| 147 RequestSender* runner, | 137 const GDataWapiUrlGenerator& url_generator, |
| 148 net::URLRequestContextGetter* url_request_context_getter, | 138 const GetAccountMetadataCallback& callback, |
| 149 const GDataWapiUrlGenerator& url_generator, | 139 bool include_installed_apps); |
| 150 const GetAccountMetadataCallback& callback, | |
| 151 bool include_installed_apps); | |
| 152 virtual ~GetAccountMetadataRequest(); | 140 virtual ~GetAccountMetadataRequest(); |
| 153 | 141 |
| 154 protected: | 142 protected: |
| 155 // UrlFetchRequestBase overrides. | 143 // UrlFetchRequestBase overrides. |
| 156 virtual GURL GetURL() const OVERRIDE; | 144 virtual GURL GetURL() const OVERRIDE; |
| 157 | 145 |
| 158 private: | 146 private: |
| 159 const GDataWapiUrlGenerator url_generator_; | 147 const GDataWapiUrlGenerator url_generator_; |
| 160 const bool include_installed_apps_; | 148 const bool include_installed_apps_; |
| 161 | 149 |
| 162 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataRequest); | 150 DISALLOW_COPY_AND_ASSIGN(GetAccountMetadataRequest); |
| 163 }; | 151 }; |
| 164 | 152 |
| 165 //=========================== DeleteResourceRequest ========================== | 153 //=========================== DeleteResourceRequest ========================== |
| 166 | 154 |
| 167 // This class performs the request for deleting a resource. | 155 // This class performs the request for deleting a resource. |
| 168 // | 156 // |
| 169 // In WAPI, "gd:deleted" means that the resource was put in the trash, and | 157 // In WAPI, "gd:deleted" means that the resource was put in the trash, and |
| 170 // "docs:removed" means its permanently gone. Since what the class does is to | 158 // "docs:removed" means its permanently gone. Since what the class does is to |
| 171 // put the resource into trash, we have chosen "Delete" in the name, even though | 159 // put the resource into trash, we have chosen "Delete" in the name, even though |
| 172 // we are preferring the term "Remove" in drive/google_api code. | 160 // we are preferring the term "Remove" in drive/google_api code. |
| 173 class DeleteResourceRequest : public EntryActionRequest { | 161 class DeleteResourceRequest : public EntryActionRequest { |
| 174 public: | 162 public: |
| 175 // |callback| must not be null. | 163 // |callback| must not be null. |
| 176 DeleteResourceRequest( | 164 DeleteResourceRequest(RequestSender* sender, |
| 177 RequestSender* runner, | 165 const GDataWapiUrlGenerator& url_generator, |
| 178 net::URLRequestContextGetter* url_request_context_getter, | 166 const EntryActionCallback& callback, |
| 179 const GDataWapiUrlGenerator& url_generator, | 167 const std::string& resource_id, |
| 180 const EntryActionCallback& callback, | 168 const std::string& etag); |
| 181 const std::string& resource_id, | |
| 182 const std::string& etag); | |
| 183 virtual ~DeleteResourceRequest(); | 169 virtual ~DeleteResourceRequest(); |
| 184 | 170 |
| 185 protected: | 171 protected: |
| 186 // UrlFetchRequestBase overrides. | 172 // UrlFetchRequestBase overrides. |
| 187 virtual GURL GetURL() const OVERRIDE; | 173 virtual GURL GetURL() const OVERRIDE; |
| 188 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 174 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 189 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 175 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 190 | 176 |
| 191 private: | 177 private: |
| 192 const GDataWapiUrlGenerator url_generator_; | 178 const GDataWapiUrlGenerator url_generator_; |
| 193 const std::string resource_id_; | 179 const std::string resource_id_; |
| 194 const std::string etag_; | 180 const std::string etag_; |
| 195 | 181 |
| 196 DISALLOW_COPY_AND_ASSIGN(DeleteResourceRequest); | 182 DISALLOW_COPY_AND_ASSIGN(DeleteResourceRequest); |
| 197 }; | 183 }; |
| 198 | 184 |
| 199 //========================== CreateDirectoryRequest ========================== | 185 //========================== CreateDirectoryRequest ========================== |
| 200 | 186 |
| 201 // This class performs the request for creating a directory. | 187 // This class performs the request for creating a directory. |
| 202 class CreateDirectoryRequest : public GetDataRequest { | 188 class CreateDirectoryRequest : public GetDataRequest { |
| 203 public: | 189 public: |
| 204 // A new directory will be created under a directory specified by | 190 // A new directory will be created under a directory specified by |
| 205 // |parent_resource_id|. If this parameter is empty, a new directory will | 191 // |parent_resource_id|. If this parameter is empty, a new directory will |
| 206 // be created in the root directory. | 192 // be created in the root directory. |
| 207 // |callback| must not be null. | 193 // |callback| must not be null. |
| 208 CreateDirectoryRequest( | 194 CreateDirectoryRequest(RequestSender* sender, |
| 209 RequestSender* runner, | 195 const GDataWapiUrlGenerator& url_generator, |
| 210 net::URLRequestContextGetter* url_request_context_getter, | 196 const GetDataCallback& callback, |
| 211 const GDataWapiUrlGenerator& url_generator, | 197 const std::string& parent_resource_id, |
| 212 const GetDataCallback& callback, | 198 const std::string& directory_name); |
| 213 const std::string& parent_resource_id, | |
| 214 const std::string& directory_name); | |
| 215 virtual ~CreateDirectoryRequest(); | 199 virtual ~CreateDirectoryRequest(); |
| 216 | 200 |
| 217 protected: | 201 protected: |
| 218 // UrlFetchRequestBase overrides. | 202 // UrlFetchRequestBase overrides. |
| 219 virtual GURL GetURL() const OVERRIDE; | 203 virtual GURL GetURL() const OVERRIDE; |
| 220 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 204 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 221 virtual bool GetContentData(std::string* upload_content_type, | 205 virtual bool GetContentData(std::string* upload_content_type, |
| 222 std::string* upload_content) OVERRIDE; | 206 std::string* upload_content) OVERRIDE; |
| 223 | 207 |
| 224 private: | 208 private: |
| 225 const GDataWapiUrlGenerator url_generator_; | 209 const GDataWapiUrlGenerator url_generator_; |
| 226 const std::string parent_resource_id_; | 210 const std::string parent_resource_id_; |
| 227 const std::string directory_name_; | 211 const std::string directory_name_; |
| 228 | 212 |
| 229 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryRequest); | 213 DISALLOW_COPY_AND_ASSIGN(CreateDirectoryRequest); |
| 230 }; | 214 }; |
| 231 | 215 |
| 232 //============================ CopyHostedDocumentRequest ===================== | 216 //============================ CopyHostedDocumentRequest ===================== |
| 233 | 217 |
| 234 // This class performs the request for making a copy of a hosted document. | 218 // This class performs the request for making a copy of a hosted document. |
| 235 // Note that this function cannot be used to copy regular files, as it's not | 219 // Note that this function cannot be used to copy regular files, as it's not |
| 236 // supported by WAPI. | 220 // supported by WAPI. |
| 237 class CopyHostedDocumentRequest : public GetDataRequest { | 221 class CopyHostedDocumentRequest : public GetDataRequest { |
| 238 public: | 222 public: |
| 239 // |callback| must not be null. | 223 // |callback| must not be null. |
| 240 CopyHostedDocumentRequest( | 224 CopyHostedDocumentRequest(RequestSender* sender, |
| 241 RequestSender* runner, | 225 const GDataWapiUrlGenerator& url_generator, |
| 242 net::URLRequestContextGetter* url_request_context_getter, | 226 const GetDataCallback& callback, |
| 243 const GDataWapiUrlGenerator& url_generator, | 227 const std::string& resource_id, |
| 244 const GetDataCallback& callback, | 228 const std::string& new_name); |
| 245 const std::string& resource_id, | |
| 246 const std::string& new_name); | |
| 247 virtual ~CopyHostedDocumentRequest(); | 229 virtual ~CopyHostedDocumentRequest(); |
| 248 | 230 |
| 249 protected: | 231 protected: |
| 250 // UrlFetchRequestBase overrides. | 232 // UrlFetchRequestBase overrides. |
| 251 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 233 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 252 virtual GURL GetURL() const OVERRIDE; | 234 virtual GURL GetURL() const OVERRIDE; |
| 253 virtual bool GetContentData(std::string* upload_content_type, | 235 virtual bool GetContentData(std::string* upload_content_type, |
| 254 std::string* upload_content) OVERRIDE; | 236 std::string* upload_content) OVERRIDE; |
| 255 | 237 |
| 256 private: | 238 private: |
| 257 const GDataWapiUrlGenerator url_generator_; | 239 const GDataWapiUrlGenerator url_generator_; |
| 258 const std::string resource_id_; | 240 const std::string resource_id_; |
| 259 const std::string new_name_; | 241 const std::string new_name_; |
| 260 | 242 |
| 261 DISALLOW_COPY_AND_ASSIGN(CopyHostedDocumentRequest); | 243 DISALLOW_COPY_AND_ASSIGN(CopyHostedDocumentRequest); |
| 262 }; | 244 }; |
| 263 | 245 |
| 264 //=========================== RenameResourceRequest ========================== | 246 //=========================== RenameResourceRequest ========================== |
| 265 | 247 |
| 266 // This class performs the request for renaming a document/file/directory. | 248 // This class performs the request for renaming a document/file/directory. |
| 267 class RenameResourceRequest : public EntryActionRequest { | 249 class RenameResourceRequest : public EntryActionRequest { |
| 268 public: | 250 public: |
| 269 // |callback| must not be null. | 251 // |callback| must not be null. |
| 270 RenameResourceRequest( | 252 RenameResourceRequest(RequestSender* sender, |
| 271 RequestSender* runner, | 253 const GDataWapiUrlGenerator& url_generator, |
| 272 net::URLRequestContextGetter* url_request_context_getter, | 254 const EntryActionCallback& callback, |
| 273 const GDataWapiUrlGenerator& url_generator, | 255 const std::string& resource_id, |
| 274 const EntryActionCallback& callback, | 256 const std::string& new_name); |
| 275 const std::string& resource_id, | |
| 276 const std::string& new_name); | |
| 277 virtual ~RenameResourceRequest(); | 257 virtual ~RenameResourceRequest(); |
| 278 | 258 |
| 279 protected: | 259 protected: |
| 280 // UrlFetchRequestBase overrides. | 260 // UrlFetchRequestBase overrides. |
| 281 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 261 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 282 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 262 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 283 virtual GURL GetURL() const OVERRIDE; | 263 virtual GURL GetURL() const OVERRIDE; |
| 284 virtual bool GetContentData(std::string* upload_content_type, | 264 virtual bool GetContentData(std::string* upload_content_type, |
| 285 std::string* upload_content) OVERRIDE; | 265 std::string* upload_content) OVERRIDE; |
| 286 | 266 |
| 287 private: | 267 private: |
| 288 const GDataWapiUrlGenerator url_generator_; | 268 const GDataWapiUrlGenerator url_generator_; |
| 289 const std::string resource_id_; | 269 const std::string resource_id_; |
| 290 const std::string new_name_; | 270 const std::string new_name_; |
| 291 | 271 |
| 292 DISALLOW_COPY_AND_ASSIGN(RenameResourceRequest); | 272 DISALLOW_COPY_AND_ASSIGN(RenameResourceRequest); |
| 293 }; | 273 }; |
| 294 | 274 |
| 295 //=========================== AuthorizeAppRequest ========================== | 275 //=========================== AuthorizeAppRequest ========================== |
| 296 | 276 |
| 297 // This class performs the request for authorizing an application specified | 277 // This class performs the request for authorizing an application specified |
| 298 // by |app_id| to access a document specified by |resource_id|. | 278 // by |app_id| to access a document specified by |resource_id|. |
| 299 class AuthorizeAppRequest : public GetDataRequest { | 279 class AuthorizeAppRequest : public GetDataRequest { |
| 300 public: | 280 public: |
| 301 // |callback| must not be null. | 281 // |callback| must not be null. |
| 302 AuthorizeAppRequest( | 282 AuthorizeAppRequest(RequestSender* sender, |
| 303 RequestSender* runner, | 283 const GDataWapiUrlGenerator& url_generator, |
| 304 net::URLRequestContextGetter* url_request_context_getter, | 284 const AuthorizeAppCallback& callback, |
| 305 const GDataWapiUrlGenerator& url_generator, | 285 const std::string& resource_id, |
| 306 const AuthorizeAppCallback& callback, | 286 const std::string& app_id); |
| 307 const std::string& resource_id, | |
| 308 const std::string& app_id); | |
| 309 virtual ~AuthorizeAppRequest(); | 287 virtual ~AuthorizeAppRequest(); |
| 310 | 288 |
| 311 protected: | 289 protected: |
| 312 // UrlFetchRequestBase overrides. | 290 // UrlFetchRequestBase overrides. |
| 313 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 291 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 314 virtual bool GetContentData(std::string* upload_content_type, | 292 virtual bool GetContentData(std::string* upload_content_type, |
| 315 std::string* upload_content) OVERRIDE; | 293 std::string* upload_content) OVERRIDE; |
| 316 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 294 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 317 virtual GURL GetURL() const OVERRIDE; | 295 virtual GURL GetURL() const OVERRIDE; |
| 318 | 296 |
| 319 private: | 297 private: |
| 320 const GDataWapiUrlGenerator url_generator_; | 298 const GDataWapiUrlGenerator url_generator_; |
| 321 const std::string resource_id_; | 299 const std::string resource_id_; |
| 322 const std::string app_id_; | 300 const std::string app_id_; |
| 323 | 301 |
| 324 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppRequest); | 302 DISALLOW_COPY_AND_ASSIGN(AuthorizeAppRequest); |
| 325 }; | 303 }; |
| 326 | 304 |
| 327 //======================= AddResourceToDirectoryRequest ====================== | 305 //======================= AddResourceToDirectoryRequest ====================== |
| 328 | 306 |
| 329 // This class performs the request for adding a document/file/directory | 307 // This class performs the request for adding a document/file/directory |
| 330 // to a directory. | 308 // to a directory. |
| 331 class AddResourceToDirectoryRequest : public EntryActionRequest { | 309 class AddResourceToDirectoryRequest : public EntryActionRequest { |
| 332 public: | 310 public: |
| 333 // |callback| must not be null. | 311 // |callback| must not be null. |
| 334 AddResourceToDirectoryRequest( | 312 AddResourceToDirectoryRequest(RequestSender* sender, |
| 335 RequestSender* runner, | 313 const GDataWapiUrlGenerator& url_generator, |
| 336 net::URLRequestContextGetter* url_request_context_getter, | 314 const EntryActionCallback& callback, |
| 337 const GDataWapiUrlGenerator& url_generator, | 315 const std::string& parent_resource_id, |
| 338 const EntryActionCallback& callback, | 316 const std::string& resource_id); |
| 339 const std::string& parent_resource_id, | |
| 340 const std::string& resource_id); | |
| 341 virtual ~AddResourceToDirectoryRequest(); | 317 virtual ~AddResourceToDirectoryRequest(); |
| 342 | 318 |
| 343 protected: | 319 protected: |
| 344 // UrlFetchRequestBase overrides. | 320 // UrlFetchRequestBase overrides. |
| 345 virtual GURL GetURL() const OVERRIDE; | 321 virtual GURL GetURL() const OVERRIDE; |
| 346 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 322 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 347 virtual bool GetContentData(std::string* upload_content_type, | 323 virtual bool GetContentData(std::string* upload_content_type, |
| 348 std::string* upload_content) OVERRIDE; | 324 std::string* upload_content) OVERRIDE; |
| 349 | 325 |
| 350 private: | 326 private: |
| 351 const GDataWapiUrlGenerator url_generator_; | 327 const GDataWapiUrlGenerator url_generator_; |
| 352 const std::string parent_resource_id_; | 328 const std::string parent_resource_id_; |
| 353 const std::string resource_id_; | 329 const std::string resource_id_; |
| 354 | 330 |
| 355 DISALLOW_COPY_AND_ASSIGN(AddResourceToDirectoryRequest); | 331 DISALLOW_COPY_AND_ASSIGN(AddResourceToDirectoryRequest); |
| 356 }; | 332 }; |
| 357 | 333 |
| 358 //==================== RemoveResourceFromDirectoryRequest ==================== | 334 //==================== RemoveResourceFromDirectoryRequest ==================== |
| 359 | 335 |
| 360 // This class performs the request for removing a document/file/directory | 336 // This class performs the request for removing a document/file/directory |
| 361 // from a directory. | 337 // from a directory. |
| 362 class RemoveResourceFromDirectoryRequest : public EntryActionRequest { | 338 class RemoveResourceFromDirectoryRequest : public EntryActionRequest { |
| 363 public: | 339 public: |
| 364 // |callback| must not be null. | 340 // |callback| must not be null. |
| 365 RemoveResourceFromDirectoryRequest( | 341 RemoveResourceFromDirectoryRequest(RequestSender* sender, |
| 366 RequestSender* runner, | 342 const GDataWapiUrlGenerator& url_generator, |
| 367 net::URLRequestContextGetter* url_request_context_getter, | 343 const EntryActionCallback& callback, |
| 368 const GDataWapiUrlGenerator& url_generator, | 344 const std::string& parent_resource_id, |
| 369 const EntryActionCallback& callback, | 345 const std::string& resource_id); |
| 370 const std::string& parent_resource_id, | |
| 371 const std::string& resource_id); | |
| 372 virtual ~RemoveResourceFromDirectoryRequest(); | 346 virtual ~RemoveResourceFromDirectoryRequest(); |
| 373 | 347 |
| 374 protected: | 348 protected: |
| 375 // UrlFetchRequestBase overrides. | 349 // UrlFetchRequestBase overrides. |
| 376 virtual GURL GetURL() const OVERRIDE; | 350 virtual GURL GetURL() const OVERRIDE; |
| 377 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 351 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 378 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 352 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 379 | 353 |
| 380 private: | 354 private: |
| 381 const GDataWapiUrlGenerator url_generator_; | 355 const GDataWapiUrlGenerator url_generator_; |
| 382 const std::string resource_id_; | 356 const std::string resource_id_; |
| 383 const std::string parent_resource_id_; | 357 const std::string parent_resource_id_; |
| 384 | 358 |
| 385 DISALLOW_COPY_AND_ASSIGN(RemoveResourceFromDirectoryRequest); | 359 DISALLOW_COPY_AND_ASSIGN(RemoveResourceFromDirectoryRequest); |
| 386 }; | 360 }; |
| 387 | 361 |
| 388 //======================= InitiateUploadNewFileRequest ======================= | 362 //======================= InitiateUploadNewFileRequest ======================= |
| 389 | 363 |
| 390 // This class performs the request for initiating the upload of a new file. | 364 // This class performs the request for initiating the upload of a new file. |
| 391 class InitiateUploadNewFileRequest : public InitiateUploadRequestBase { | 365 class InitiateUploadNewFileRequest : public InitiateUploadRequestBase { |
| 392 public: | 366 public: |
| 393 // |title| should be set. | 367 // |title| should be set. |
| 394 // |parent_upload_url| should be the upload_url() of the parent directory. | 368 // |parent_upload_url| should be the upload_url() of the parent directory. |
| 395 // (resumable-create-media URL) | 369 // (resumable-create-media URL) |
| 396 // See also the comments of InitiateUploadRequestBase for more details | 370 // See also the comments of InitiateUploadRequestBase for more details |
| 397 // about the other parameters. | 371 // about the other parameters. |
| 398 InitiateUploadNewFileRequest( | 372 InitiateUploadNewFileRequest(RequestSender* sender, |
| 399 RequestSender* runner, | 373 const GDataWapiUrlGenerator& url_generator, |
| 400 net::URLRequestContextGetter* url_request_context_getter, | 374 const InitiateUploadCallback& callback, |
| 401 const GDataWapiUrlGenerator& url_generator, | 375 const std::string& content_type, |
| 402 const InitiateUploadCallback& callback, | 376 int64 content_length, |
| 403 const std::string& content_type, | 377 const std::string& parent_resource_id, |
| 404 int64 content_length, | 378 const std::string& title); |
| 405 const std::string& parent_resource_id, | |
| 406 const std::string& title); | |
| 407 virtual ~InitiateUploadNewFileRequest(); | 379 virtual ~InitiateUploadNewFileRequest(); |
| 408 | 380 |
| 409 protected: | 381 protected: |
| 410 // UrlFetchRequestBase overrides. | 382 // UrlFetchRequestBase overrides. |
| 411 virtual GURL GetURL() const OVERRIDE; | 383 virtual GURL GetURL() const OVERRIDE; |
| 412 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 384 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 413 virtual bool GetContentData(std::string* upload_content_type, | 385 virtual bool GetContentData(std::string* upload_content_type, |
| 414 std::string* upload_content) OVERRIDE; | 386 std::string* upload_content) OVERRIDE; |
| 415 | 387 |
| 416 private: | 388 private: |
| 417 const GDataWapiUrlGenerator url_generator_; | 389 const GDataWapiUrlGenerator url_generator_; |
| 418 const std::string parent_resource_id_; | 390 const std::string parent_resource_id_; |
| 419 const std::string title_; | 391 const std::string title_; |
| 420 | 392 |
| 421 DISALLOW_COPY_AND_ASSIGN(InitiateUploadNewFileRequest); | 393 DISALLOW_COPY_AND_ASSIGN(InitiateUploadNewFileRequest); |
| 422 }; | 394 }; |
| 423 | 395 |
| 424 //==================== InitiateUploadExistingFileRequest ===================== | 396 //==================== InitiateUploadExistingFileRequest ===================== |
| 425 | 397 |
| 426 // This class performs the request for initiating the upload of an existing | 398 // This class performs the request for initiating the upload of an existing |
| 427 // file. | 399 // file. |
| 428 class InitiateUploadExistingFileRequest | 400 class InitiateUploadExistingFileRequest |
| 429 : public InitiateUploadRequestBase { | 401 : public InitiateUploadRequestBase { |
| 430 public: | 402 public: |
| 431 // |upload_url| should be the upload_url() of the file | 403 // |upload_url| should be the upload_url() of the file |
| 432 // (resumable-create-media URL) | 404 // (resumable-create-media URL) |
| 433 // |etag| should be set if it is available to detect the upload confliction. | 405 // |etag| should be set if it is available to detect the upload confliction. |
| 434 // See also the comments of InitiateUploadRequestBase for more details | 406 // See also the comments of InitiateUploadRequestBase for more details |
| 435 // about the other parameters. | 407 // about the other parameters. |
| 436 InitiateUploadExistingFileRequest( | 408 InitiateUploadExistingFileRequest(RequestSender* sender, |
| 437 RequestSender* runner, | 409 const GDataWapiUrlGenerator& url_generator, |
| 438 net::URLRequestContextGetter* url_request_context_getter, | 410 const InitiateUploadCallback& callback, |
| 439 const GDataWapiUrlGenerator& url_generator, | 411 const std::string& content_type, |
| 440 const InitiateUploadCallback& callback, | 412 int64 content_length, |
| 441 const std::string& content_type, | 413 const std::string& resource_id, |
| 442 int64 content_length, | 414 const std::string& etag); |
| 443 const std::string& resource_id, | |
| 444 const std::string& etag); | |
| 445 virtual ~InitiateUploadExistingFileRequest(); | 415 virtual ~InitiateUploadExistingFileRequest(); |
| 446 | 416 |
| 447 protected: | 417 protected: |
| 448 // UrlFetchRequestBase overrides. | 418 // UrlFetchRequestBase overrides. |
| 449 virtual GURL GetURL() const OVERRIDE; | 419 virtual GURL GetURL() const OVERRIDE; |
| 450 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; | 420 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 451 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; | 421 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 452 virtual bool GetContentData(std::string* upload_content_type, | 422 virtual bool GetContentData(std::string* upload_content_type, |
| 453 std::string* upload_content) OVERRIDE; | 423 std::string* upload_content) OVERRIDE; |
| 454 | 424 |
| 455 private: | 425 private: |
| 456 const GDataWapiUrlGenerator url_generator_; | 426 const GDataWapiUrlGenerator url_generator_; |
| 457 const std::string resource_id_; | 427 const std::string resource_id_; |
| 458 const std::string etag_; | 428 const std::string etag_; |
| 459 | 429 |
| 460 DISALLOW_COPY_AND_ASSIGN(InitiateUploadExistingFileRequest); | 430 DISALLOW_COPY_AND_ASSIGN(InitiateUploadExistingFileRequest); |
| 461 }; | 431 }; |
| 462 | 432 |
| 463 //============================ ResumeUploadRequest =========================== | 433 //============================ ResumeUploadRequest =========================== |
| 464 | 434 |
| 465 // Performs the request for resuming the upload of a file. | 435 // Performs the request for resuming the upload of a file. |
| 466 class ResumeUploadRequest : public ResumeUploadRequestBase { | 436 class ResumeUploadRequest : public ResumeUploadRequestBase { |
| 467 public: | 437 public: |
| 468 // See also ResumeUploadRequestBase's comment for parameters meaining. | 438 // See also ResumeUploadRequestBase's comment for parameters meaning. |
| 469 // |callback| must not be null. | 439 // |callback| must not be null. |
| 470 ResumeUploadRequest( | 440 ResumeUploadRequest(RequestSender* sender, |
| 471 RequestSender* runner, | 441 const UploadRangeCallback& callback, |
| 472 net::URLRequestContextGetter* url_request_context_getter, | 442 const ProgressCallback& progress_callback, |
| 473 const UploadRangeCallback& callback, | 443 const GURL& upload_location, |
| 474 const ProgressCallback& progress_callback, | 444 int64 start_position, |
| 475 const GURL& upload_location, | 445 int64 end_position, |
| 476 int64 start_position, | 446 int64 content_length, |
| 477 int64 end_position, | 447 const std::string& content_type, |
| 478 int64 content_length, | 448 const base::FilePath& local_file_path); |
| 479 const std::string& content_type, | |
| 480 const base::FilePath& local_file_path); | |
| 481 virtual ~ResumeUploadRequest(); | 449 virtual ~ResumeUploadRequest(); |
| 482 | 450 |
| 483 protected: | 451 protected: |
| 484 // UploadRangeRequestBase overrides. | 452 // UploadRangeRequestBase overrides. |
| 485 virtual void OnRangeRequestComplete( | 453 virtual void OnRangeRequestComplete( |
| 486 const UploadRangeResponse& response, | 454 const UploadRangeResponse& response, |
| 487 scoped_ptr<base::Value> value) OVERRIDE; | 455 scoped_ptr<base::Value> value) OVERRIDE; |
| 488 // content::UrlFetcherDelegate overrides. | 456 // content::UrlFetcherDelegate overrides. |
| 489 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, | 457 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, |
| 490 int64 current, int64 total) OVERRIDE; | 458 int64 current, int64 total) OVERRIDE; |
| 491 | 459 |
| 492 private: | 460 private: |
| 493 const UploadRangeCallback callback_; | 461 const UploadRangeCallback callback_; |
| 494 const ProgressCallback progress_callback_; | 462 const ProgressCallback progress_callback_; |
| 495 | 463 |
| 496 DISALLOW_COPY_AND_ASSIGN(ResumeUploadRequest); | 464 DISALLOW_COPY_AND_ASSIGN(ResumeUploadRequest); |
| 497 }; | 465 }; |
| 498 | 466 |
| 499 //========================== GetUploadStatusRequest ========================== | 467 //========================== GetUploadStatusRequest ========================== |
| 500 | 468 |
| 501 // Performs the request to request the current upload status of a file. | 469 // Performs the request to request the current upload status of a file. |
| 502 class GetUploadStatusRequest : public GetUploadStatusRequestBase { | 470 class GetUploadStatusRequest : public GetUploadStatusRequestBase { |
| 503 public: | 471 public: |
| 504 // See also GetUploadStatusRequestBase's comment for parameters meaning. | 472 // See also GetUploadStatusRequestBase's comment for parameters meaning. |
| 505 // |callback| must not be null. | 473 // |callback| must not be null. |
| 506 GetUploadStatusRequest( | 474 GetUploadStatusRequest(RequestSender* sender, |
| 507 RequestSender* runner, | 475 const UploadRangeCallback& callback, |
| 508 net::URLRequestContextGetter* url_request_context_getter, | 476 const GURL& upload_url, |
| 509 const UploadRangeCallback& callback, | 477 int64 content_length); |
| 510 const GURL& upload_url, | |
| 511 int64 content_length); | |
| 512 virtual ~GetUploadStatusRequest(); | 478 virtual ~GetUploadStatusRequest(); |
| 513 | 479 |
| 514 protected: | 480 protected: |
| 515 // UploadRangeRequestBase overrides. | 481 // UploadRangeRequestBase overrides. |
| 516 virtual void OnRangeRequestComplete( | 482 virtual void OnRangeRequestComplete( |
| 517 const UploadRangeResponse& response, | 483 const UploadRangeResponse& response, |
| 518 scoped_ptr<base::Value> value) OVERRIDE; | 484 scoped_ptr<base::Value> value) OVERRIDE; |
| 519 | 485 |
| 520 private: | 486 private: |
| 521 const UploadRangeCallback callback_; | 487 const UploadRangeCallback callback_; |
| 522 | 488 |
| 523 DISALLOW_COPY_AND_ASSIGN(GetUploadStatusRequest); | 489 DISALLOW_COPY_AND_ASSIGN(GetUploadStatusRequest); |
| 524 }; | 490 }; |
| 525 | 491 |
| 526 } // namespace google_apis | 492 } // namespace google_apis |
| 527 | 493 |
| 528 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_REQUESTS_H_ | 494 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_REQUESTS_H_ |
| OLD | NEW |