| 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 } | 544 } |
| 545 } | 545 } |
| 546 | 546 |
| 547 base::MessageLoop::current()->PostTask( | 547 base::MessageLoop::current()->PostTask( |
| 548 FROM_HERE, base::Bind(callback, HTTP_NOT_FOUND)); | 548 FROM_HERE, base::Bind(callback, HTTP_NOT_FOUND)); |
| 549 return CancelCallback(); | 549 return CancelCallback(); |
| 550 } | 550 } |
| 551 | 551 |
| 552 CancelCallback FakeDriveService::DownloadFile( | 552 CancelCallback FakeDriveService::DownloadFile( |
| 553 const base::FilePath& local_cache_path, | 553 const base::FilePath& local_cache_path, |
| 554 const GURL& download_url, | 554 const std::string& resource_id, |
| 555 const DownloadActionCallback& download_action_callback, | 555 const DownloadActionCallback& download_action_callback, |
| 556 const GetContentCallback& get_content_callback, | 556 const GetContentCallback& get_content_callback, |
| 557 const ProgressCallback& progress_callback) { | 557 const ProgressCallback& progress_callback) { |
| 558 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 558 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 559 DCHECK(!download_action_callback.is_null()); | 559 DCHECK(!download_action_callback.is_null()); |
| 560 | 560 |
| 561 if (offline_) { | 561 if (offline_) { |
| 562 base::MessageLoop::current()->PostTask( | 562 base::MessageLoop::current()->PostTask( |
| 563 FROM_HERE, | 563 FROM_HERE, |
| 564 base::Bind(download_action_callback, | 564 base::Bind(download_action_callback, |
| 565 GDATA_NO_CONNECTION, | 565 GDATA_NO_CONNECTION, |
| 566 base::FilePath())); | 566 base::FilePath())); |
| 567 return CancelCallback(); | 567 return CancelCallback(); |
| 568 } | 568 } |
| 569 | 569 |
| 570 // The field content.src is the URL to download the file. | 570 // The field content.src is the URL to download the file. |
| 571 base::DictionaryValue* entry = FindEntryByContentUrl(download_url); | 571 base::DictionaryValue* entry = FindEntryByResourceId(resource_id); |
| 572 if (!entry) { | 572 if (!entry) { |
| 573 base::MessageLoopProxy::current()->PostTask( | 573 base::MessageLoopProxy::current()->PostTask( |
| 574 FROM_HERE, | 574 FROM_HERE, |
| 575 base::Bind(download_action_callback, HTTP_NOT_FOUND, base::FilePath())); | 575 base::Bind(download_action_callback, HTTP_NOT_FOUND, base::FilePath())); |
| 576 return CancelCallback(); | 576 return CancelCallback(); |
| 577 } | 577 } |
| 578 | 578 |
| 579 // Write "x"s of the file size specified in the entry. | 579 // Write "x"s of the file size specified in the entry. |
| 580 std::string file_size_string; | 580 std::string file_size_string; |
| 581 entry->GetString("docs$size.$t", &file_size_string); | 581 entry->GetString("docs$size.$t", &file_size_string); |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 HTTP_SUCCESS, | 1480 HTTP_SUCCESS, |
| 1481 base::Passed(&resource_list))); | 1481 base::Passed(&resource_list))); |
| 1482 } | 1482 } |
| 1483 | 1483 |
| 1484 GURL FakeDriveService::GetNewUploadSessionUrl() { | 1484 GURL FakeDriveService::GetNewUploadSessionUrl() { |
| 1485 return GURL("https://upload_session_url/" + | 1485 return GURL("https://upload_session_url/" + |
| 1486 base::Int64ToString(next_upload_sequence_number_++)); | 1486 base::Int64ToString(next_upload_sequence_number_++)); |
| 1487 } | 1487 } |
| 1488 | 1488 |
| 1489 } // namespace drive | 1489 } // namespace drive |
| OLD | NEW |