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

Unified Diff: chrome/browser/google_apis/fake_drive_service.cc

Issue 11824020: google_apis: Implement DownloadFile in FakeDriveService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add DownloadFile_NonexistingFile test Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/google_apis/fake_drive_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/fake_drive_service.cc
diff --git a/chrome/browser/google_apis/fake_drive_service.cc b/chrome/browser/google_apis/fake_drive_service.cc
index 28925512a544976d3bea563ab2194c963a74b424..168d02f8ec591c07a9ca78d97b621fe4043ee19a 100644
--- a/chrome/browser/google_apis/fake_drive_service.cc
+++ b/chrome/browser/google_apis/fake_drive_service.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/google_apis/fake_drive_service.h"
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/stringprintf.h"
@@ -224,6 +225,29 @@ void FakeDriveService::DownloadFile(
const GetContentCallback& get_content_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!download_action_callback.is_null());
+
+ base::DictionaryValue* entry = FindEntryByContentUrl(content_url);
+ if (!entry) {
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(download_action_callback, HTTP_NOT_FOUND, FilePath()));
+ return;
+ }
+
+ // Write the content URL as the content of the file.
+ if (static_cast<int>(content_url.spec().size()) !=
+ file_util::WriteFile(local_cache_path,
+ content_url.spec().data(),
+ content_url.spec().size())) {
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(download_action_callback, GDATA_FILE_ERROR, FilePath()));
+ return;
+ }
+
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(download_action_callback, HTTP_SUCCESS, local_cache_path));
}
void FakeDriveService::CopyHostedDocument(
« no previous file with comments | « no previous file | chrome/browser/google_apis/fake_drive_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698