| 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/drive/fake_drive_service.h" | 5 #include "chrome/browser/drive/fake_drive_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 using google_apis::AppList; | 31 using google_apis::AppList; |
| 32 using google_apis::AppListCallback; | 32 using google_apis::AppListCallback; |
| 33 using google_apis::AuthStatusCallback; | 33 using google_apis::AuthStatusCallback; |
| 34 using google_apis::AuthorizeAppCallback; | 34 using google_apis::AuthorizeAppCallback; |
| 35 using google_apis::CancelCallback; | 35 using google_apis::CancelCallback; |
| 36 using google_apis::ChangeList; | 36 using google_apis::ChangeList; |
| 37 using google_apis::ChangeListCallback; | 37 using google_apis::ChangeListCallback; |
| 38 using google_apis::ChangeResource; | 38 using google_apis::ChangeResource; |
| 39 using google_apis::DownloadActionCallback; | 39 using google_apis::DownloadActionCallback; |
| 40 using google_apis::EntryActionCallback; | 40 using google_apis::EntryActionCallback; |
| 41 using google_apis::FileList; |
| 42 using google_apis::FileListCallback; |
| 41 using google_apis::FileResource; | 43 using google_apis::FileResource; |
| 42 using google_apis::GDATA_FILE_ERROR; | 44 using google_apis::GDATA_FILE_ERROR; |
| 43 using google_apis::GDATA_NO_CONNECTION; | 45 using google_apis::GDATA_NO_CONNECTION; |
| 44 using google_apis::GDATA_OTHER_ERROR; | 46 using google_apis::GDATA_OTHER_ERROR; |
| 45 using google_apis::GDataErrorCode; | 47 using google_apis::GDataErrorCode; |
| 46 using google_apis::GetContentCallback; | 48 using google_apis::GetContentCallback; |
| 47 using google_apis::GetResourceEntryCallback; | 49 using google_apis::GetResourceEntryCallback; |
| 48 using google_apis::GetResourceListCallback; | |
| 49 using google_apis::GetShareUrlCallback; | 50 using google_apis::GetShareUrlCallback; |
| 50 using google_apis::HTTP_BAD_REQUEST; | 51 using google_apis::HTTP_BAD_REQUEST; |
| 51 using google_apis::HTTP_CREATED; | 52 using google_apis::HTTP_CREATED; |
| 52 using google_apis::HTTP_NOT_FOUND; | 53 using google_apis::HTTP_NOT_FOUND; |
| 53 using google_apis::HTTP_NO_CONTENT; | 54 using google_apis::HTTP_NO_CONTENT; |
| 54 using google_apis::HTTP_PRECONDITION; | 55 using google_apis::HTTP_PRECONDITION; |
| 55 using google_apis::HTTP_RESUME_INCOMPLETE; | 56 using google_apis::HTTP_RESUME_INCOMPLETE; |
| 56 using google_apis::HTTP_SUCCESS; | 57 using google_apis::HTTP_SUCCESS; |
| 57 using google_apis::InitiateUploadCallback; | 58 using google_apis::InitiateUploadCallback; |
| 58 using google_apis::Link; | 59 using google_apis::Link; |
| 59 using google_apis::ParentReference; | 60 using google_apis::ParentReference; |
| 60 using google_apis::ProgressCallback; | 61 using google_apis::ProgressCallback; |
| 61 using google_apis::ResourceEntry; | 62 using google_apis::ResourceEntry; |
| 62 using google_apis::ResourceList; | |
| 63 using google_apis::UploadRangeCallback; | 63 using google_apis::UploadRangeCallback; |
| 64 using google_apis::UploadRangeResponse; | 64 using google_apis::UploadRangeResponse; |
| 65 namespace test_util = google_apis::test_util; | 65 namespace test_util = google_apis::test_util; |
| 66 | 66 |
| 67 namespace drive { | 67 namespace drive { |
| 68 namespace { | 68 namespace { |
| 69 | 69 |
| 70 // Returns true if a resource entry matches with the search query. | 70 // Returns true if a resource entry matches with the search query. |
| 71 // Supports queries consist of following format. | 71 // Supports queries consist of following format. |
| 72 // - Phrases quoted by double/single quotes | 72 // - Phrases quoted by double/single quotes |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 end_position), | 116 end_position), |
| 117 base::Passed(&entry))); | 117 base::Passed(&entry))); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void EntryActionCallbackAdapter( | 120 void EntryActionCallbackAdapter( |
| 121 const EntryActionCallback& callback, | 121 const EntryActionCallback& callback, |
| 122 GDataErrorCode error, scoped_ptr<ResourceEntry> resource_entry) { | 122 GDataErrorCode error, scoped_ptr<ResourceEntry> resource_entry) { |
| 123 callback.Run(error); | 123 callback.Run(error); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void GetResourceListCallbackAdapter(const GetResourceListCallback& callback, | 126 void FileListCallbackAdapter(const FileListCallback& callback, |
| 127 GDataErrorCode error, | 127 GDataErrorCode error, |
| 128 scoped_ptr<ChangeList> change_list) { | 128 scoped_ptr<ChangeList> change_list) { |
| 129 callback.Run(error, change_list ? | 129 scoped_ptr<FileList> file_list; |
| 130 util::ConvertChangeListToResourceList(*change_list) : | 130 if (change_list) { |
| 131 scoped_ptr<ResourceList>()); | 131 file_list.reset(new FileList); |
| 132 file_list->set_next_link(change_list->next_link()); |
| 133 for (size_t i = 0; i < change_list->items().size(); ++i) { |
| 134 const ChangeResource& entry = *change_list->items()[i]; |
| 135 if (entry.file()) |
| 136 file_list->mutable_items()->push_back(new FileResource(*entry.file())); |
| 137 } |
| 138 } |
| 139 callback.Run(error, file_list.Pass()); |
| 132 } | 140 } |
| 133 | 141 |
| 134 } // namespace | 142 } // namespace |
| 135 | 143 |
| 136 struct FakeDriveService::EntryInfo { | 144 struct FakeDriveService::EntryInfo { |
| 137 google_apis::ChangeResource change_resource; | 145 google_apis::ChangeResource change_resource; |
| 138 GURL share_url; | 146 GURL share_url; |
| 139 std::string content_data; | 147 std::string content_data; |
| 140 }; | 148 }; |
| 141 | 149 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 169 uploaded_size(0) { | 177 uploaded_size(0) { |
| 170 } | 178 } |
| 171 }; | 179 }; |
| 172 | 180 |
| 173 FakeDriveService::FakeDriveService() | 181 FakeDriveService::FakeDriveService() |
| 174 : about_resource_(new AboutResource), | 182 : about_resource_(new AboutResource), |
| 175 published_date_seq_(0), | 183 published_date_seq_(0), |
| 176 next_upload_sequence_number_(0), | 184 next_upload_sequence_number_(0), |
| 177 default_max_results_(0), | 185 default_max_results_(0), |
| 178 resource_id_count_(0), | 186 resource_id_count_(0), |
| 179 resource_list_load_count_(0), | 187 file_list_load_count_(0), |
| 180 change_list_load_count_(0), | 188 change_list_load_count_(0), |
| 181 directory_load_count_(0), | 189 directory_load_count_(0), |
| 182 about_resource_load_count_(0), | 190 about_resource_load_count_(0), |
| 183 app_list_load_count_(0), | 191 app_list_load_count_(0), |
| 184 blocked_resource_list_load_count_(0), | 192 blocked_file_list_load_count_(0), |
| 185 offline_(false), | 193 offline_(false), |
| 186 never_return_all_resource_list_(false), | 194 never_return_all_file_list_(false), |
| 187 share_url_base_("https://share_url/") { | 195 share_url_base_("https://share_url/") { |
| 188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 189 | 197 |
| 190 about_resource_->set_largest_change_id(654321); | 198 about_resource_->set_largest_change_id(654321); |
| 191 about_resource_->set_quota_bytes_total(9876543210); | 199 about_resource_->set_quota_bytes_total(9876543210); |
| 192 about_resource_->set_quota_bytes_used(6789012345); | 200 about_resource_->set_quota_bytes_used(6789012345); |
| 193 about_resource_->set_root_folder_id(GetRootResourceId()); | 201 about_resource_->set_root_folder_id(GetRootResourceId()); |
| 194 } | 202 } |
| 195 | 203 |
| 196 FakeDriveService::~FakeDriveService() { | 204 FakeDriveService::~FakeDriveService() { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 271 } |
| 264 | 272 |
| 265 void FakeDriveService::ClearRefreshToken() { | 273 void FakeDriveService::ClearRefreshToken() { |
| 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 267 } | 275 } |
| 268 | 276 |
| 269 std::string FakeDriveService::GetRootResourceId() const { | 277 std::string FakeDriveService::GetRootResourceId() const { |
| 270 return "fake_root"; | 278 return "fake_root"; |
| 271 } | 279 } |
| 272 | 280 |
| 273 CancelCallback FakeDriveService::GetAllResourceList( | 281 CancelCallback FakeDriveService::GetAllFileList( |
| 274 const GetResourceListCallback& callback) { | 282 const FileListCallback& callback) { |
| 275 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 283 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 276 DCHECK(!callback.is_null()); | 284 DCHECK(!callback.is_null()); |
| 277 | 285 |
| 278 if (never_return_all_resource_list_) { | 286 if (never_return_all_file_list_) { |
| 279 ++blocked_resource_list_load_count_; | 287 ++blocked_file_list_load_count_; |
| 280 return CancelCallback(); | 288 return CancelCallback(); |
| 281 } | 289 } |
| 282 | 290 |
| 283 GetResourceListInternal(0, // start changestamp | 291 GetChangeListInternal(0, // start changestamp |
| 284 std::string(), // empty search query | 292 std::string(), // empty search query |
| 285 std::string(), // no directory resource id, | 293 std::string(), // no directory resource id, |
| 286 0, // start offset | 294 0, // start offset |
| 287 default_max_results_, | 295 default_max_results_, |
| 288 &resource_list_load_count_, | 296 &file_list_load_count_, |
| 289 base::Bind(&GetResourceListCallbackAdapter, | 297 base::Bind(&FileListCallbackAdapter, callback)); |
| 290 callback)); | |
| 291 return CancelCallback(); | 298 return CancelCallback(); |
| 292 } | 299 } |
| 293 | 300 |
| 294 CancelCallback FakeDriveService::GetResourceListInDirectory( | 301 CancelCallback FakeDriveService::GetFileListInDirectory( |
| 295 const std::string& directory_resource_id, | 302 const std::string& directory_resource_id, |
| 296 const GetResourceListCallback& callback) { | 303 const FileListCallback& callback) { |
| 297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 304 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 298 DCHECK(!directory_resource_id.empty()); | 305 DCHECK(!directory_resource_id.empty()); |
| 299 DCHECK(!callback.is_null()); | 306 DCHECK(!callback.is_null()); |
| 300 | 307 |
| 301 GetResourceListInternal(0, // start changestamp | 308 GetChangeListInternal(0, // start changestamp |
| 302 std::string(), // empty search query | 309 std::string(), // empty search query |
| 303 directory_resource_id, | 310 directory_resource_id, |
| 304 0, // start offset | 311 0, // start offset |
| 305 default_max_results_, | 312 default_max_results_, |
| 306 &directory_load_count_, | 313 &directory_load_count_, |
| 307 base::Bind(&GetResourceListCallbackAdapter, | 314 base::Bind(&FileListCallbackAdapter, callback)); |
| 308 callback)); | |
| 309 return CancelCallback(); | 315 return CancelCallback(); |
| 310 } | 316 } |
| 311 | 317 |
| 312 CancelCallback FakeDriveService::Search( | 318 CancelCallback FakeDriveService::Search( |
| 313 const std::string& search_query, | 319 const std::string& search_query, |
| 314 const GetResourceListCallback& callback) { | 320 const FileListCallback& callback) { |
| 315 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 316 DCHECK(!search_query.empty()); | 322 DCHECK(!search_query.empty()); |
| 317 DCHECK(!callback.is_null()); | 323 DCHECK(!callback.is_null()); |
| 318 | 324 |
| 319 GetResourceListInternal(0, // start changestamp | 325 GetChangeListInternal(0, // start changestamp |
| 320 search_query, | 326 search_query, |
| 321 std::string(), // no directory resource id, | 327 std::string(), // no directory resource id, |
| 322 0, // start offset | 328 0, // start offset |
| 323 default_max_results_, | 329 default_max_results_, |
| 324 NULL, | 330 NULL, |
| 325 base::Bind(&GetResourceListCallbackAdapter, | 331 base::Bind(&FileListCallbackAdapter, callback)); |
| 326 callback)); | |
| 327 return CancelCallback(); | 332 return CancelCallback(); |
| 328 } | 333 } |
| 329 | 334 |
| 330 CancelCallback FakeDriveService::SearchByTitle( | 335 CancelCallback FakeDriveService::SearchByTitle( |
| 331 const std::string& title, | 336 const std::string& title, |
| 332 const std::string& directory_resource_id, | 337 const std::string& directory_resource_id, |
| 333 const GetResourceListCallback& callback) { | 338 const FileListCallback& callback) { |
| 334 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 335 DCHECK(!title.empty()); | 340 DCHECK(!title.empty()); |
| 336 DCHECK(!callback.is_null()); | 341 DCHECK(!callback.is_null()); |
| 337 | 342 |
| 338 // Note: the search implementation here doesn't support quotation unescape, | 343 // Note: the search implementation here doesn't support quotation unescape, |
| 339 // so don't escape here. | 344 // so don't escape here. |
| 340 GetResourceListInternal(0, // start changestamp | 345 GetChangeListInternal(0, // start changestamp |
| 341 base::StringPrintf("title:'%s'", title.c_str()), | 346 base::StringPrintf("title:'%s'", title.c_str()), |
| 342 directory_resource_id, | 347 directory_resource_id, |
| 343 0, // start offset | 348 0, // start offset |
| 344 default_max_results_, | 349 default_max_results_, |
| 345 NULL, | 350 NULL, |
| 346 base::Bind(&GetResourceListCallbackAdapter, | 351 base::Bind(&FileListCallbackAdapter, callback)); |
| 347 callback)); | |
| 348 return CancelCallback(); | 352 return CancelCallback(); |
| 349 } | 353 } |
| 350 | 354 |
| 351 CancelCallback FakeDriveService::GetChangeList( | 355 CancelCallback FakeDriveService::GetChangeList( |
| 352 int64 start_changestamp, | 356 int64 start_changestamp, |
| 353 const ChangeListCallback& callback) { | 357 const ChangeListCallback& callback) { |
| 354 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 355 DCHECK(!callback.is_null()); | 359 DCHECK(!callback.is_null()); |
| 356 | 360 |
| 357 GetResourceListInternal(start_changestamp, | 361 GetChangeListInternal(start_changestamp, |
| 358 std::string(), // empty search query | 362 std::string(), // empty search query |
| 359 std::string(), // no directory resource id, | 363 std::string(), // no directory resource id, |
| 360 0, // start offset | 364 0, // start offset |
| 361 default_max_results_, | 365 default_max_results_, |
| 362 &change_list_load_count_, | 366 &change_list_load_count_, |
| 363 callback); | 367 callback); |
| 364 return CancelCallback(); | 368 return CancelCallback(); |
| 365 } | 369 } |
| 366 | 370 |
| 367 CancelCallback FakeDriveService::GetRemainingChangeList( | 371 CancelCallback FakeDriveService::GetRemainingChangeList( |
| 368 const GURL& next_link, | 372 const GURL& next_link, |
| 369 const ChangeListCallback& callback) { | 373 const ChangeListCallback& callback) { |
| 370 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 374 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 371 DCHECK(!next_link.is_empty()); | 375 DCHECK(!next_link.is_empty()); |
| 372 DCHECK(!callback.is_null()); | 376 DCHECK(!callback.is_null()); |
| 373 | 377 |
| 374 // "changestamp", "q", "parent" and "start-offset" are parameters to | 378 // "changestamp", "q", "parent" and "start-offset" are parameters to |
| 375 // implement "paging" of the result on FakeDriveService. | 379 // implement "paging" of the result on FakeDriveService. |
| 376 // The URL should be the one filled in GetResourceListInternal of the | 380 // The URL should be the one filled in GetChangeListInternal of the |
| 377 // previous method invocation, so it should start with "http://localhost/?". | 381 // previous method invocation, so it should start with "http://localhost/?". |
| 378 // See also GetResourceListInternal. | 382 // See also GetChangeListInternal. |
| 379 DCHECK_EQ(next_link.host(), "localhost"); | 383 DCHECK_EQ(next_link.host(), "localhost"); |
| 380 DCHECK_EQ(next_link.path(), "/"); | 384 DCHECK_EQ(next_link.path(), "/"); |
| 381 | 385 |
| 382 int64 start_changestamp = 0; | 386 int64 start_changestamp = 0; |
| 383 std::string search_query; | 387 std::string search_query; |
| 384 std::string directory_resource_id; | 388 std::string directory_resource_id; |
| 385 int start_offset = 0; | 389 int start_offset = 0; |
| 386 int max_results = default_max_results_; | 390 int max_results = default_max_results_; |
| 387 std::vector<std::pair<std::string, std::string> > parameters; | 391 std::vector<std::pair<std::string, std::string> > parameters; |
| 388 if (base::SplitStringIntoKeyValuePairs( | 392 if (base::SplitStringIntoKeyValuePairs( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 399 net::UnescapeURLComponent(parameters[i].second, | 403 net::UnescapeURLComponent(parameters[i].second, |
| 400 net::UnescapeRule::URL_SPECIAL_CHARS); | 404 net::UnescapeRule::URL_SPECIAL_CHARS); |
| 401 } else if (parameters[i].first == "start-offset") { | 405 } else if (parameters[i].first == "start-offset") { |
| 402 base::StringToInt(parameters[i].second, &start_offset); | 406 base::StringToInt(parameters[i].second, &start_offset); |
| 403 } else if (parameters[i].first == "max-results") { | 407 } else if (parameters[i].first == "max-results") { |
| 404 base::StringToInt(parameters[i].second, &max_results); | 408 base::StringToInt(parameters[i].second, &max_results); |
| 405 } | 409 } |
| 406 } | 410 } |
| 407 } | 411 } |
| 408 | 412 |
| 409 GetResourceListInternal( | 413 GetChangeListInternal(start_changestamp, search_query, directory_resource_id, |
| 410 start_changestamp, search_query, directory_resource_id, | 414 start_offset, max_results, NULL, callback); |
| 411 start_offset, max_results, NULL, callback); | |
| 412 return CancelCallback(); | 415 return CancelCallback(); |
| 413 } | 416 } |
| 414 | 417 |
| 415 CancelCallback FakeDriveService::GetRemainingFileList( | 418 CancelCallback FakeDriveService::GetRemainingFileList( |
| 416 const GURL& next_link, | 419 const GURL& next_link, |
| 417 const GetResourceListCallback& callback) { | 420 const FileListCallback& callback) { |
| 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 421 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 419 DCHECK(!next_link.is_empty()); | 422 DCHECK(!next_link.is_empty()); |
| 420 DCHECK(!callback.is_null()); | 423 DCHECK(!callback.is_null()); |
| 421 | 424 |
| 422 return GetRemainingChangeList( | 425 return GetRemainingChangeList( |
| 423 next_link, base::Bind(&GetResourceListCallbackAdapter, callback)); | 426 next_link, base::Bind(&FileListCallbackAdapter, callback)); |
| 424 } | 427 } |
| 425 | 428 |
| 426 CancelCallback FakeDriveService::GetResourceEntry( | 429 CancelCallback FakeDriveService::GetResourceEntry( |
| 427 const std::string& resource_id, | 430 const std::string& resource_id, |
| 428 const GetResourceEntryCallback& callback) { | 431 const GetResourceEntryCallback& callback) { |
| 429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 432 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 430 DCHECK(!callback.is_null()); | 433 DCHECK(!callback.is_null()); |
| 431 | 434 |
| 432 if (offline_) { | 435 if (offline_) { |
| 433 scoped_ptr<ResourceEntry> null; | 436 scoped_ptr<ResourceEntry> null; |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1378 | 1381 |
| 1379 base::Time published_date = | 1382 base::Time published_date = |
| 1380 base::Time() + base::TimeDelta::FromMilliseconds(++published_date_seq_); | 1383 base::Time() + base::TimeDelta::FromMilliseconds(++published_date_seq_); |
| 1381 new_file->set_created_date(published_date); | 1384 new_file->set_created_date(published_date); |
| 1382 | 1385 |
| 1383 EntryInfo* raw_new_entry = new_entry.release(); | 1386 EntryInfo* raw_new_entry = new_entry.release(); |
| 1384 entries_[resource_id] = raw_new_entry; | 1387 entries_[resource_id] = raw_new_entry; |
| 1385 return raw_new_entry; | 1388 return raw_new_entry; |
| 1386 } | 1389 } |
| 1387 | 1390 |
| 1388 void FakeDriveService::GetResourceListInternal( | 1391 void FakeDriveService::GetChangeListInternal( |
| 1389 int64 start_changestamp, | 1392 int64 start_changestamp, |
| 1390 const std::string& search_query, | 1393 const std::string& search_query, |
| 1391 const std::string& directory_resource_id, | 1394 const std::string& directory_resource_id, |
| 1392 int start_offset, | 1395 int start_offset, |
| 1393 int max_results, | 1396 int max_results, |
| 1394 int* load_counter, | 1397 int* load_counter, |
| 1395 const ChangeListCallback& callback) { | 1398 const ChangeListCallback& callback) { |
| 1396 if (offline_) { | 1399 if (offline_) { |
| 1397 base::MessageLoop::current()->PostTask( | 1400 base::MessageLoop::current()->PostTask( |
| 1398 FROM_HERE, | 1401 FROM_HERE, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1472 if (start_changestamp > 0 && start_offset == 0) { | 1475 if (start_changestamp > 0 && start_offset == 0) { |
| 1473 change_list->set_largest_change_id(about_resource_->largest_change_id()); | 1476 change_list->set_largest_change_id(about_resource_->largest_change_id()); |
| 1474 } | 1477 } |
| 1475 | 1478 |
| 1476 // If |max_results| is set, trim the entries if the number exceeded the max | 1479 // If |max_results| is set, trim the entries if the number exceeded the max |
| 1477 // results. | 1480 // results. |
| 1478 if (max_results > 0 && entries.size() > static_cast<size_t>(max_results)) { | 1481 if (max_results > 0 && entries.size() > static_cast<size_t>(max_results)) { |
| 1479 entries.erase(entries.begin() + max_results, entries.end()); | 1482 entries.erase(entries.begin() + max_results, entries.end()); |
| 1480 // Adds the next URL. | 1483 // Adds the next URL. |
| 1481 // Here, we embed information which is needed for continuing the | 1484 // Here, we embed information which is needed for continuing the |
| 1482 // GetResourceList request in the next invocation into url query | 1485 // GetChangeList request in the next invocation into url query |
| 1483 // parameters. | 1486 // parameters. |
| 1484 GURL next_url(base::StringPrintf( | 1487 GURL next_url(base::StringPrintf( |
| 1485 "http://localhost/?start-offset=%d&max-results=%d", | 1488 "http://localhost/?start-offset=%d&max-results=%d", |
| 1486 start_offset + max_results, | 1489 start_offset + max_results, |
| 1487 max_results)); | 1490 max_results)); |
| 1488 if (start_changestamp > 0) { | 1491 if (start_changestamp > 0) { |
| 1489 next_url = net::AppendOrReplaceQueryParameter( | 1492 next_url = net::AppendOrReplaceQueryParameter( |
| 1490 next_url, "changestamp", | 1493 next_url, "changestamp", |
| 1491 base::Int64ToString(start_changestamp).c_str()); | 1494 base::Int64ToString(start_changestamp).c_str()); |
| 1492 } | 1495 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1521 google_apis::drive::PermissionRole role, | 1524 google_apis::drive::PermissionRole role, |
| 1522 const google_apis::EntryActionCallback& callback) { | 1525 const google_apis::EntryActionCallback& callback) { |
| 1523 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 1526 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 1524 DCHECK(!callback.is_null()); | 1527 DCHECK(!callback.is_null()); |
| 1525 | 1528 |
| 1526 NOTREACHED(); | 1529 NOTREACHED(); |
| 1527 return CancelCallback(); | 1530 return CancelCallback(); |
| 1528 } | 1531 } |
| 1529 | 1532 |
| 1530 } // namespace drive | 1533 } // namespace drive |
| OLD | NEW |