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

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

Issue 305913002: drive: Replace GetResourceListCallback in DriveServiceInterface with FileListCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "chrome/browser/chromeos/drive/drive.pb.h" 13 #include "chrome/browser/chromeos/drive/drive.pb.h"
14 #include "chrome/browser/chromeos/drive/file_errors.h" 14 #include "chrome/browser/chromeos/drive/file_errors.h"
15 #include "chrome/browser/chromeos/drive/file_system_util.h" 15 #include "chrome/browser/chromeos/drive/file_system_util.h"
16 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" 16 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h"
17 #include "chrome/browser/drive/drive_api_util.h"
17 #include "chrome/browser/drive/drive_service_interface.h" 18 #include "chrome/browser/drive/drive_service_interface.h"
18 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
19 #include "google_apis/drive/drive_api_parser.h" 20 #include "google_apis/drive/drive_api_parser.h"
20 #include "google_apis/drive/gdata_wapi_parser.h" 21 #include "google_apis/drive/gdata_wapi_parser.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 namespace drive { 24 namespace drive {
24 namespace test_util { 25 namespace test_util {
25 26
26 using content::BrowserThread; 27 using content::BrowserThread;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 FileError error, 343 FileError error,
343 scoped_ptr<ResourceEntry> parent_entry) { 344 scoped_ptr<ResourceEntry> parent_entry) {
344 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 345 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
345 346
346 if (error != FILE_ERROR_OK) { 347 if (error != FILE_ERROR_OK) {
347 callback.Run(error, scoped_ptr<ResourceEntry>()); 348 callback.Run(error, scoped_ptr<ResourceEntry>());
348 return; 349 return;
349 } 350 }
350 351
351 DCHECK(parent_entry); 352 DCHECK(parent_entry);
352 drive_service_->GetResourceListInDirectory( 353 drive_service_->GetFileListInDirectory(
353 parent_entry->resource_id(), 354 parent_entry->resource_id(),
354 base::Bind( 355 base::Bind(
355 &FakeFileSystem::GetResourceEntryAfterGetResourceList, 356 &FakeFileSystem::GetResourceEntryAfterGetFileList,
356 weak_ptr_factory_.GetWeakPtr(), base_name, callback)); 357 weak_ptr_factory_.GetWeakPtr(), base_name, callback));
357 } 358 }
358 359
359 void FakeFileSystem::GetResourceEntryAfterGetResourceList( 360 void FakeFileSystem::GetResourceEntryAfterGetFileList(
360 const base::FilePath& base_name, 361 const base::FilePath& base_name,
361 const GetResourceEntryCallback& callback, 362 const GetResourceEntryCallback& callback,
362 google_apis::GDataErrorCode gdata_error, 363 google_apis::GDataErrorCode gdata_error,
363 scoped_ptr<google_apis::ResourceList> resource_list) { 364 scoped_ptr<google_apis::FileList> file_list) {
364 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
365 366
366 FileError error = GDataToFileError(gdata_error); 367 FileError error = GDataToFileError(gdata_error);
367 if (error != FILE_ERROR_OK) { 368 if (error != FILE_ERROR_OK) {
368 callback.Run(error, scoped_ptr<ResourceEntry>()); 369 callback.Run(error, scoped_ptr<ResourceEntry>());
369 return; 370 return;
370 } 371 }
371 372
372 DCHECK(resource_list); 373 DCHECK(file_list);
373 const ScopedVector<google_apis::ResourceEntry>& entries = 374 const ScopedVector<google_apis::FileResource>& entries = file_list->items();
374 resource_list->entries();
375 for (size_t i = 0; i < entries.size(); ++i) { 375 for (size_t i = 0; i < entries.size(); ++i) {
376 scoped_ptr<ResourceEntry> entry(new ResourceEntry); 376 scoped_ptr<ResourceEntry> entry(new ResourceEntry);
377 std::string parent_resource_id; 377 std::string parent_resource_id;
378 bool converted = 378 bool converted = ConvertToResourceEntry(
379 ConvertToResourceEntry(*entries[i], entry.get(), &parent_resource_id); 379 *util::ConvertFileResourceToResourceEntry(*entries[i]), entry.get(),
380 &parent_resource_id);
380 DCHECK(converted); 381 DCHECK(converted);
381 entry->set_parent_local_id(parent_resource_id); 382 entry->set_parent_local_id(parent_resource_id);
382 383
383 if (entry->base_name() == base_name.AsUTF8Unsafe()) { 384 if (entry->base_name() == base_name.AsUTF8Unsafe()) {
384 // Found the target entry. 385 // Found the target entry.
385 callback.Run(FILE_ERROR_OK, entry.Pass()); 386 callback.Run(FILE_ERROR_OK, entry.Pass());
386 return; 387 return;
387 } 388 }
388 } 389 }
389 390
390 callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>()); 391 callback.Run(FILE_ERROR_NOT_FOUND, scoped_ptr<ResourceEntry>());
391 } 392 }
392 393
393 } // namespace test_util 394 } // namespace test_util
394 } // namespace drive 395 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/fake_file_system.h ('k') | chrome/browser/chromeos/drive/file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698