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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_operations.cc

Issue 10383248: gdata: Add ability to fetch documents in a particular directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/chromeos/gdata/gdata_operations.h" 5 #include "chrome/browser/chromeos/gdata/gdata_operations.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 23 matching lines...) Expand all
34 // Template for optional OAuth2 authorization HTTP header. 34 // Template for optional OAuth2 authorization HTTP header.
35 const char kAuthorizationHeaderFormat[] = "Authorization: Bearer %s"; 35 const char kAuthorizationHeaderFormat[] = "Authorization: Bearer %s";
36 // Template for GData API version HTTP header. 36 // Template for GData API version HTTP header.
37 const char kGDataVersionHeader[] = "GData-Version: 3.0"; 37 const char kGDataVersionHeader[] = "GData-Version: 3.0";
38 38
39 // etag matching header. 39 // etag matching header.
40 const char kIfMatchAllHeader[] = "If-Match: *"; 40 const char kIfMatchAllHeader[] = "If-Match: *";
41 const char kIfMatchHeaderFormat[] = "If-Match: %s"; 41 const char kIfMatchHeaderFormat[] = "If-Match: %s";
42 42
43 // URL requesting documents list that belong to the authenticated user only 43 // URL requesting documents list that belong to the authenticated user only
44 // (handled with '-/mine' part). 44 // (handled with '/mine' part).
45 const char kGetDocumentListURL[] = 45 const char kGetDocumentListURLForAllDocuments[] =
46 "https://docs.google.com/feeds/default/private/full/-/mine"; 46 "https://docs.google.com/feeds/default/private/full/-/mine";
47 // URL requesting documents list in a particular directory specified by "%s"
48 // that belong to the authenticated user only (handled with '/mine' part).
49 const char kGetDocumentListURLForDirectoryFormat[] =
50 "https://docs.google.com/feeds/default/private/full/%s/contents/mine";
47 51
48 // URL requesting documents list of changes to documents collections. 52 // URL requesting documents list of changes to documents collections.
49 const char kGetChangesListURL[] = 53 const char kGetChangesListURL[] =
50 "https://docs.google.com/feeds/default/private/changes"; 54 "https://docs.google.com/feeds/default/private/changes";
51 55
52 // Root document list url. 56 // Root document list url.
53 const char kDocumentListRootURL[] = 57 const char kDocumentListRootURL[] =
54 "https://docs.google.com/feeds/default/private/full"; 58 "https://docs.google.com/feeds/default/private/full";
55 59
56 // Metadata feed with things like user quota. 60 // Metadata feed with things like user quota.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 base::StringPrintf("%d", changestamp)); 134 base::StringPrintf("%d", changestamp));
131 } 135 }
132 136
133 if (!search_string.empty()) { 137 if (!search_string.empty()) {
134 result = chrome_common_net::AppendOrReplaceQueryParameter( 138 result = chrome_common_net::AppendOrReplaceQueryParameter(
135 result, "q", search_string); 139 result, "q", search_string);
136 } 140 }
137 return result; 141 return result;
138 } 142 }
139 143
144 // Formats a URL for getting document list. If |directory_resource_id| is
145 // empty, returns a URL for fetching all documents. If it's given, returns a
146 // URL for fetching documents in a particular directory.
147 GURL FormatDocumentListURL(const std::string& directory_resource_id) {
148 if (resource_id.empty())
tbarzic 2012/05/18 19:59:03 s/resource_is/directory_resource_id/ but, you've
149 return GURL(kGetDocumentListURLForAllDocuments);
150
151 return GURL(base::StringPrintf(kGetDocumentListURLForDirectoryFormat,
152 net::EscapePath(
153 directory_resource_id).c_str()));
154 }
155
140 } // namespace 156 } // namespace
141 157
142 namespace gdata { 158 namespace gdata {
143 159
144 //================================ AuthOperation =============================== 160 //================================ AuthOperation ===============================
145 161
146 AuthOperation::AuthOperation(GDataOperationRegistry* registry, 162 AuthOperation::AuthOperation(GDataOperationRegistry* registry,
147 Profile* profile, 163 Profile* profile,
148 const AuthStatusCallback& callback, 164 const AuthStatusCallback& callback,
149 const std::string& refresh_token) 165 const std::string& refresh_token)
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 << error_code 475 << error_code
460 << ", data:\n" 476 << ", data:\n"
461 << data; 477 << data;
462 return NULL; 478 return NULL;
463 } 479 }
464 return root_value.release(); 480 return root_value.release();
465 } 481 }
466 482
467 //============================ GetDocumentsOperation =========================== 483 //============================ GetDocumentsOperation ===========================
468 484
469 GetDocumentsOperation::GetDocumentsOperation(GDataOperationRegistry* registry, 485 GetDocumentsOperation::GetDocumentsOperation(
470 Profile* profile, 486 GDataOperationRegistry* registry,
471 int start_changestamp, 487 Profile* profile,
472 const std::string& search_string, 488 int start_changestamp,
473 const GetDataCallback& callback) 489 const std::string& search_string,
490 const std::string& directory_resource_id,
491
492 const GetDataCallback& callback)
474 : GetDataOperation(registry, profile, callback), 493 : GetDataOperation(registry, profile, callback),
475 start_changestamp_(start_changestamp), 494 start_changestamp_(start_changestamp),
476 search_string_(search_string) { 495 search_string_(search_string),
496 directory_resource_id_(directory_resource_id) {
477 } 497 }
478 498
479 GetDocumentsOperation::~GetDocumentsOperation() {} 499 GetDocumentsOperation::~GetDocumentsOperation() {}
480 500
481 void GetDocumentsOperation::SetUrl(const GURL& url) { 501 void GetDocumentsOperation::SetUrl(const GURL& url) {
482 override_url_ = url; 502 override_url_ = url;
483 } 503 }
484 504
485 GURL GetDocumentsOperation::GetURL() const { 505 GURL GetDocumentsOperation::GetURL() const {
486 if (!override_url_.is_empty()) 506 if (!override_url_.is_empty())
487 return AddFeedUrlParams(override_url_, 507 return AddFeedUrlParams(override_url_,
488 kMaxDocumentsPerFeed, 508 kMaxDocumentsPerFeed,
489 0, 509 0,
490 std::string()); 510 std::string());
491 511
492 if (start_changestamp_ == 0) { 512 if (start_changestamp_ == 0) {
493 return AddFeedUrlParams(GURL(kGetDocumentListURL), 513 return AddFeedUrlParams(FormatDocumentListURL(directory_resource_id_),
494 kMaxDocumentsPerFeed, 514 kMaxDocumentsPerFeed,
495 0, 515 0,
496 search_string_); 516 search_string_);
497 } 517 }
498 518
499 return AddFeedUrlParams(GURL(kGetChangesListURL), 519 return AddFeedUrlParams(GURL(kGetChangesListURL),
500 kMaxDocumentsPerFeed, 520 kMaxDocumentsPerFeed,
501 start_changestamp_, 521 start_changestamp_,
502 std::string()); 522 std::string());
503 } 523 }
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 return true; 1070 return true;
1051 } 1071 }
1052 1072
1053 void ResumeUploadOperation::OnURLFetchUploadProgress( 1073 void ResumeUploadOperation::OnURLFetchUploadProgress(
1054 const net::URLFetcher* source, int64 current, int64 total) { 1074 const net::URLFetcher* source, int64 current, int64 total) {
1055 // Adjust the progress values according to the range currently uploaded. 1075 // Adjust the progress values according to the range currently uploaded.
1056 NotifyProgress(params_.start_range + current, params_.content_length); 1076 NotifyProgress(params_.start_range + current, params_.content_length);
1057 } 1077 }
1058 1078
1059 } // namespace gdata 1079 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_operations.h ('k') | chrome/browser/chromeos/gdata/mock_gdata_documents_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698