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 #include "chrome/browser/chromeos/gdata/gdata_operations.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_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/chromeos/gdata/gdata_wapi_parser.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 | 50 |
| 51 const char kUploadContentRange[] = "Content-Range: bytes "; | 51 const char kUploadContentRange[] = "Content-Range: bytes "; |
| 52 const char kUploadContentType[] = "X-Upload-Content-Type: "; | 52 const char kUploadContentType[] = "X-Upload-Content-Type: "; |
| 53 const char kUploadContentLength[] = "X-Upload-Content-Length: "; | 53 const char kUploadContentLength[] = "X-Upload-Content-Length: "; |
| 54 | 54 |
| 55 #ifndef NDEBUG | 55 #ifndef NDEBUG |
| 56 // Use smaller 'page' size while debugging to ensure we hit feed reload | 56 // Use smaller 'page' size while debugging to ensure we hit feed reload |
| 57 // almost always. Be careful not to use something too small on account that | 57 // almost always. Be careful not to use something too small on account that |
| 58 // have many items because server side 503 error might kick in. | 58 // have many items because server side 503 error might kick in. |
| 59 const int kMaxDocumentsPerFeed = 1000; | 59 const int kMaxDocumentsPerFeed = 1000; |
| 60 const int kMaxDocumentsPerSearchFeed = 100; | |
|
satorux1
2012/07/20 17:13:04
why 100? I think most users only see the first 10
tbarzic
2012/07/20 17:51:43
I'd like to reduce number of server requests; 10 w
satorux1
2012/07/20 17:55:56
oh i see, then 100 is fine.
| |
| 60 #else | 61 #else |
| 61 const int kMaxDocumentsPerFeed = 1000; | 62 const int kMaxDocumentsPerFeed = 1000; |
| 63 const int kMaxDocumentsPerSearchFeed = 100; | |
| 62 #endif | 64 #endif |
| 63 | 65 |
| 64 const char kFeedField[] = "feed"; | 66 const char kFeedField[] = "feed"; |
| 65 | 67 |
| 66 // Templates for file uploading. | 68 // Templates for file uploading. |
| 67 const char kUploadParamConvertKey[] = "convert"; | 69 const char kUploadParamConvertKey[] = "convert"; |
| 68 const char kUploadParamConvertValue[] = "false"; | 70 const char kUploadParamConvertValue[] = "false"; |
| 69 const char kUploadResponseLocation[] = "location"; | 71 const char kUploadResponseLocation[] = "location"; |
| 70 const char kUploadResponseRange[] = "range"; | 72 const char kUploadResponseRange[] = "range"; |
| 71 | 73 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 directory_resource_id_(directory_resource_id) { | 154 directory_resource_id_(directory_resource_id) { |
| 153 } | 155 } |
| 154 | 156 |
| 155 GetDocumentsOperation::~GetDocumentsOperation() {} | 157 GetDocumentsOperation::~GetDocumentsOperation() {} |
| 156 | 158 |
| 157 void GetDocumentsOperation::SetUrl(const GURL& url) { | 159 void GetDocumentsOperation::SetUrl(const GURL& url) { |
| 158 override_url_ = url; | 160 override_url_ = url; |
| 159 } | 161 } |
| 160 | 162 |
| 161 GURL GetDocumentsOperation::GetURL() const { | 163 GURL GetDocumentsOperation::GetURL() const { |
| 164 int max_docs = search_string_.empty() ? kMaxDocumentsPerFeed : | |
| 165 kMaxDocumentsPerSearchFeed; | |
| 166 | |
| 162 if (!override_url_.is_empty()) | 167 if (!override_url_.is_empty()) |
| 163 return AddFeedUrlParams(override_url_, | 168 return AddFeedUrlParams(override_url_, |
| 164 kMaxDocumentsPerFeed, | 169 max_docs, |
| 165 0, | 170 0, |
| 166 std::string()); | 171 search_string_); |
| 167 | 172 |
| 168 if (start_changestamp_ == 0) { | 173 if (start_changestamp_ == 0) { |
| 169 return AddFeedUrlParams(FormatDocumentListURL(directory_resource_id_), | 174 return AddFeedUrlParams(FormatDocumentListURL(directory_resource_id_), |
| 170 kMaxDocumentsPerFeed, | 175 max_docs, |
| 171 0, | 176 0, |
| 172 search_string_); | 177 search_string_); |
| 173 } | 178 } |
| 174 | 179 |
| 175 return AddFeedUrlParams(GURL(kGetChangesListURL), | 180 return AddFeedUrlParams(GURL(kGetChangesListURL), |
| 176 kMaxDocumentsPerFeed, | 181 kMaxDocumentsPerFeed, |
| 177 start_changestamp_, | 182 start_changestamp_, |
| 178 std::string()); | 183 std::string()); |
| 179 } | 184 } |
| 180 | 185 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 return true; | 874 return true; |
| 870 } | 875 } |
| 871 | 876 |
| 872 void ResumeUploadOperation::OnURLFetchUploadProgress( | 877 void ResumeUploadOperation::OnURLFetchUploadProgress( |
| 873 const URLFetcher* source, int64 current, int64 total) { | 878 const URLFetcher* source, int64 current, int64 total) { |
| 874 // Adjust the progress values according to the range currently uploaded. | 879 // Adjust the progress values according to the range currently uploaded. |
| 875 NotifyProgress(params_.start_range + current, params_.content_length); | 880 NotifyProgress(params_.start_range + current, params_.content_length); |
| 876 } | 881 } |
| 877 | 882 |
| 878 } // namespace gdata | 883 } // namespace gdata |
| OLD | NEW |