| 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 #include "chrome/browser/google_apis/gdata_wapi_operations.h" | 5 #include "chrome/browser/google_apis/gdata_wapi_operations.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 10 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
| 11 #include "chrome/browser/google_apis/gdata_wapi_url_util.h" | 11 #include "chrome/browser/google_apis/gdata_wapi_url_generator.h" |
| 12 #include "chrome/browser/google_apis/time_util.h" | 12 #include "chrome/browser/google_apis/time_util.h" |
| 13 #include "chrome/common/net/url_util.h" | 13 #include "chrome/common/net/url_util.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
| 16 #include "net/http/http_response_headers.h" | 16 #include "net/http/http_response_headers.h" |
| 17 #include "net/http/http_util.h" | 17 #include "net/http/http_util.h" |
| 18 #include "third_party/libxml/chromium/libxml_utils.h" | 18 #include "third_party/libxml/chromium/libxml_utils.h" |
| 19 | 19 |
| 20 using net::URLFetcher; | 20 using net::URLFetcher; |
| 21 | 21 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 DeleteDocumentOperation::DeleteDocumentOperation( | 229 DeleteDocumentOperation::DeleteDocumentOperation( |
| 230 OperationRegistry* registry, | 230 OperationRegistry* registry, |
| 231 const EntryActionCallback& callback, | 231 const EntryActionCallback& callback, |
| 232 const GURL& document_url) | 232 const GURL& document_url) |
| 233 : EntryActionOperation(registry, callback, document_url) { | 233 : EntryActionOperation(registry, callback, document_url) { |
| 234 } | 234 } |
| 235 | 235 |
| 236 DeleteDocumentOperation::~DeleteDocumentOperation() {} | 236 DeleteDocumentOperation::~DeleteDocumentOperation() {} |
| 237 | 237 |
| 238 GURL DeleteDocumentOperation::GetURL() const { | 238 GURL DeleteDocumentOperation::GetURL() const { |
| 239 return gdata_wapi_url_util::AddStandardUrlParams(document_url()); | 239 return GDataWapiUrlGenerator::AddStandardUrlParams(document_url()); |
| 240 } | 240 } |
| 241 | 241 |
| 242 URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { | 242 URLFetcher::RequestType DeleteDocumentOperation::GetRequestType() const { |
| 243 return URLFetcher::DELETE_REQUEST; | 243 return URLFetcher::DELETE_REQUEST; |
| 244 } | 244 } |
| 245 | 245 |
| 246 std::vector<std::string> | 246 std::vector<std::string> |
| 247 DeleteDocumentOperation::GetExtraRequestHeaders() const { | 247 DeleteDocumentOperation::GetExtraRequestHeaders() const { |
| 248 std::vector<std::string> headers; | 248 std::vector<std::string> headers; |
| 249 headers.push_back(kIfMatchAllHeader); | 249 headers.push_back(kIfMatchAllHeader); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 261 : GetDataOperation(registry, callback), | 261 : GetDataOperation(registry, callback), |
| 262 url_generator_(url_generator), | 262 url_generator_(url_generator), |
| 263 parent_content_url_(parent_content_url), | 263 parent_content_url_(parent_content_url), |
| 264 directory_name_(directory_name) { | 264 directory_name_(directory_name) { |
| 265 } | 265 } |
| 266 | 266 |
| 267 CreateDirectoryOperation::~CreateDirectoryOperation() {} | 267 CreateDirectoryOperation::~CreateDirectoryOperation() {} |
| 268 | 268 |
| 269 GURL CreateDirectoryOperation::GetURL() const { | 269 GURL CreateDirectoryOperation::GetURL() const { |
| 270 if (!parent_content_url_.is_empty()) | 270 if (!parent_content_url_.is_empty()) |
| 271 return gdata_wapi_url_util::AddStandardUrlParams(parent_content_url_); | 271 return GDataWapiUrlGenerator::AddStandardUrlParams(parent_content_url_); |
| 272 | 272 |
| 273 return url_generator_.GenerateDocumentListRootUrl(); | 273 return url_generator_.GenerateDocumentListRootUrl(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 URLFetcher::RequestType | 276 URLFetcher::RequestType |
| 277 CreateDirectoryOperation::GetRequestType() const { | 277 CreateDirectoryOperation::GetRequestType() const { |
| 278 return URLFetcher::POST; | 278 return URLFetcher::POST; |
| 279 } | 279 } |
| 280 | 280 |
| 281 bool CreateDirectoryOperation::GetContentData(std::string* upload_content_type, | 281 bool CreateDirectoryOperation::GetContentData(std::string* upload_content_type, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 } | 364 } |
| 365 | 365 |
| 366 std::vector<std::string> | 366 std::vector<std::string> |
| 367 RenameResourceOperation::GetExtraRequestHeaders() const { | 367 RenameResourceOperation::GetExtraRequestHeaders() const { |
| 368 std::vector<std::string> headers; | 368 std::vector<std::string> headers; |
| 369 headers.push_back(kIfMatchAllHeader); | 369 headers.push_back(kIfMatchAllHeader); |
| 370 return headers; | 370 return headers; |
| 371 } | 371 } |
| 372 | 372 |
| 373 GURL RenameResourceOperation::GetURL() const { | 373 GURL RenameResourceOperation::GetURL() const { |
| 374 return gdata_wapi_url_util::AddStandardUrlParams(document_url()); | 374 return GDataWapiUrlGenerator::AddStandardUrlParams(document_url()); |
| 375 } | 375 } |
| 376 | 376 |
| 377 bool RenameResourceOperation::GetContentData(std::string* upload_content_type, | 377 bool RenameResourceOperation::GetContentData(std::string* upload_content_type, |
| 378 std::string* upload_content) { | 378 std::string* upload_content) { |
| 379 upload_content_type->assign("application/atom+xml"); | 379 upload_content_type->assign("application/atom+xml"); |
| 380 XmlWriter xml_writer; | 380 XmlWriter xml_writer; |
| 381 xml_writer.StartWriting(); | 381 xml_writer.StartWriting(); |
| 382 xml_writer.StartElement("entry"); | 382 xml_writer.StartElement("entry"); |
| 383 xml_writer.AddAttribute("xmlns", "http://www.w3.org/2005/Atom"); | 383 xml_writer.AddAttribute("xmlns", "http://www.w3.org/2005/Atom"); |
| 384 | 384 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 const GURL& document_url) | 491 const GURL& document_url) |
| 492 : EntryActionOperation(registry, callback, document_url), | 492 : EntryActionOperation(registry, callback, document_url), |
| 493 url_generator_(url_generator), | 493 url_generator_(url_generator), |
| 494 parent_content_url_(parent_content_url) { | 494 parent_content_url_(parent_content_url) { |
| 495 } | 495 } |
| 496 | 496 |
| 497 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} | 497 AddResourceToDirectoryOperation::~AddResourceToDirectoryOperation() {} |
| 498 | 498 |
| 499 GURL AddResourceToDirectoryOperation::GetURL() const { | 499 GURL AddResourceToDirectoryOperation::GetURL() const { |
| 500 if (!parent_content_url_.is_empty()) | 500 if (!parent_content_url_.is_empty()) |
| 501 return gdata_wapi_url_util::AddStandardUrlParams(parent_content_url_); | 501 return GDataWapiUrlGenerator::AddStandardUrlParams(parent_content_url_); |
| 502 | 502 |
| 503 return url_generator_.GenerateDocumentListRootUrl(); | 503 return url_generator_.GenerateDocumentListRootUrl(); |
| 504 } | 504 } |
| 505 | 505 |
| 506 URLFetcher::RequestType | 506 URLFetcher::RequestType |
| 507 AddResourceToDirectoryOperation::GetRequestType() const { | 507 AddResourceToDirectoryOperation::GetRequestType() const { |
| 508 return URLFetcher::POST; | 508 return URLFetcher::POST; |
| 509 } | 509 } |
| 510 | 510 |
| 511 bool AddResourceToDirectoryOperation::GetContentData( | 511 bool AddResourceToDirectoryOperation::GetContentData( |
| (...skipping 28 matching lines...) Expand all Loading... |
| 540 } | 540 } |
| 541 | 541 |
| 542 RemoveResourceFromDirectoryOperation::~RemoveResourceFromDirectoryOperation() { | 542 RemoveResourceFromDirectoryOperation::~RemoveResourceFromDirectoryOperation() { |
| 543 } | 543 } |
| 544 | 544 |
| 545 GURL RemoveResourceFromDirectoryOperation::GetURL() const { | 545 GURL RemoveResourceFromDirectoryOperation::GetURL() const { |
| 546 std::string escaped_resource_id = net::EscapePath(resource_id_); | 546 std::string escaped_resource_id = net::EscapePath(resource_id_); |
| 547 GURL edit_url(base::StringPrintf("%s/%s", | 547 GURL edit_url(base::StringPrintf("%s/%s", |
| 548 parent_content_url_.spec().c_str(), | 548 parent_content_url_.spec().c_str(), |
| 549 escaped_resource_id.c_str())); | 549 escaped_resource_id.c_str())); |
| 550 return gdata_wapi_url_util::AddStandardUrlParams(edit_url); | 550 return GDataWapiUrlGenerator::AddStandardUrlParams(edit_url); |
| 551 } | 551 } |
| 552 | 552 |
| 553 URLFetcher::RequestType | 553 URLFetcher::RequestType |
| 554 RemoveResourceFromDirectoryOperation::GetRequestType() const { | 554 RemoveResourceFromDirectoryOperation::GetRequestType() const { |
| 555 return URLFetcher::DELETE_REQUEST; | 555 return URLFetcher::DELETE_REQUEST; |
| 556 } | 556 } |
| 557 | 557 |
| 558 std::vector<std::string> | 558 std::vector<std::string> |
| 559 RemoveResourceFromDirectoryOperation::GetExtraRequestHeaders() const { | 559 RemoveResourceFromDirectoryOperation::GetExtraRequestHeaders() const { |
| 560 std::vector<std::string> headers; | 560 std::vector<std::string> headers; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 return true; | 808 return true; |
| 809 } | 809 } |
| 810 | 810 |
| 811 void ResumeUploadOperation::OnURLFetchUploadProgress( | 811 void ResumeUploadOperation::OnURLFetchUploadProgress( |
| 812 const URLFetcher* source, int64 current, int64 total) { | 812 const URLFetcher* source, int64 current, int64 total) { |
| 813 // Adjust the progress values according to the range currently uploaded. | 813 // Adjust the progress values according to the range currently uploaded. |
| 814 NotifyProgress(params_.start_range + current, params_.content_length); | 814 NotifyProgress(params_.start_range + current, params_.content_length); |
| 815 } | 815 } |
| 816 | 816 |
| 817 } // namespace google_apis | 817 } // namespace google_apis |
| OLD | NEW |