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

Side by Side Diff: chrome/browser/chromeos/drive/fake_file_system.cc

Issue 214363002: drive: Return cancel closure from FileSystem::GetFileContent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/drive/fake_file_system.h" 5 #include "chrome/browser/chromeos/drive/fake_file_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void FakeFileSystem::GetFile(const base::FilePath& file_path, 120 void FakeFileSystem::GetFile(const base::FilePath& file_path,
121 const GetFileCallback& callback) { 121 const GetFileCallback& callback) {
122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 122 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
123 } 123 }
124 124
125 void FakeFileSystem::GetFileForSaving(const base::FilePath& file_path, 125 void FakeFileSystem::GetFileForSaving(const base::FilePath& file_path,
126 const GetFileCallback& callback) { 126 const GetFileCallback& callback) {
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
128 } 128 }
129 129
130 void FakeFileSystem::GetFileContent( 130 base::Closure FakeFileSystem::GetFileContent(
131 const base::FilePath& file_path, 131 const base::FilePath& file_path,
132 const GetFileContentInitializedCallback& initialized_callback, 132 const GetFileContentInitializedCallback& initialized_callback,
133 const google_apis::GetContentCallback& get_content_callback, 133 const google_apis::GetContentCallback& get_content_callback,
134 const FileOperationCallback& completion_callback) { 134 const FileOperationCallback& completion_callback) {
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
136 136
137 GetResourceEntry( 137 GetResourceEntry(
138 file_path, 138 file_path,
139 base::Bind(&FakeFileSystem::GetFileContentAfterGetResourceEntry, 139 base::Bind(&FakeFileSystem::GetFileContentAfterGetResourceEntry,
140 weak_ptr_factory_.GetWeakPtr(), 140 weak_ptr_factory_.GetWeakPtr(),
141 initialized_callback, get_content_callback, 141 initialized_callback, get_content_callback,
142 completion_callback)); 142 completion_callback));
143 return base::Bind(&base::DoNothing);
143 } 144 }
144 145
145 void FakeFileSystem::GetResourceEntry( 146 void FakeFileSystem::GetResourceEntry(
146 const base::FilePath& file_path, 147 const base::FilePath& file_path,
147 const GetResourceEntryCallback& callback) { 148 const GetResourceEntryCallback& callback) {
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
149 150
150 // Now, we only support files under my drive. 151 // Now, we only support files under my drive.
151 DCHECK(!util::IsUnderDriveMountPoint(file_path)); 152 DCHECK(!util::IsUnderDriveMountPoint(file_path));
152 153
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 std::string parent_resource_id; 289 std::string parent_resource_id;
289 bool converted = 290 bool converted =
290 ConvertToResourceEntry(*gdata_entry, entry.get(), &parent_resource_id); 291 ConvertToResourceEntry(*gdata_entry, entry.get(), &parent_resource_id);
291 DCHECK(converted); 292 DCHECK(converted);
292 entry->set_parent_local_id(parent_resource_id); 293 entry->set_parent_local_id(parent_resource_id);
293 294
294 base::FilePath cache_path = 295 base::FilePath cache_path =
295 cache_dir_.path().AppendASCII(entry->resource_id()); 296 cache_dir_.path().AppendASCII(entry->resource_id());
296 if (base::PathExists(cache_path)) { 297 if (base::PathExists(cache_path)) {
297 // Cache file is found. 298 // Cache file is found.
298 initialized_callback.Run(FILE_ERROR_OK, entry.Pass(), cache_path, 299 initialized_callback.Run(FILE_ERROR_OK, cache_path, entry.Pass());
299 base::Closure());
300 completion_callback.Run(FILE_ERROR_OK); 300 completion_callback.Run(FILE_ERROR_OK);
301 return; 301 return;
302 } 302 }
303 303
304 initialized_callback.Run(FILE_ERROR_OK, entry.Pass(), base::FilePath(), 304 initialized_callback.Run(FILE_ERROR_OK, base::FilePath(), entry.Pass());
305 base::Bind(&base::DoNothing));
306 drive_service_->DownloadFile( 305 drive_service_->DownloadFile(
307 cache_path, 306 cache_path,
308 gdata_entry->resource_id(), 307 gdata_entry->resource_id(),
309 base::Bind(&FakeFileSystem::GetFileContentAfterDownloadFile, 308 base::Bind(&FakeFileSystem::GetFileContentAfterDownloadFile,
310 weak_ptr_factory_.GetWeakPtr(), 309 weak_ptr_factory_.GetWeakPtr(),
311 completion_callback), 310 completion_callback),
312 get_content_callback, 311 get_content_callback,
313 google_apis::ProgressCallback()); 312 google_apis::ProgressCallback());
314 } 313 }
315 314
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 callback.Run(FILE_ERROR_OK, entry.Pass()); 390 callback.Run(FILE_ERROR_OK, entry.Pass());
392 return; 391 return;
393 } 392 }
394 } 393 }
395 394
396 callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>()); 395 callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>());
397 } 396 }
398 397
399 } // namespace test_util 398 } // namespace test_util
400 } // namespace drive 399 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698