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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc

Issue 10538071: gdata: Convert FindEntryByResourceIdSync() to asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase svn:trunk/src@141679 and resolve conflicts. Created 8 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) 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 <errno.h> 5 #include <errno.h>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 320 }
321 321
322 FilePath GetCachePathForFile(GDataFile* file) { 322 FilePath GetCachePathForFile(GDataFile* file) {
323 return cache_->GetCacheFilePath(file->resource_id(), 323 return cache_->GetCacheFilePath(file->resource_id(),
324 file->file_md5(), 324 file->file_md5(),
325 GDataCache::CACHE_TYPE_TMP, 325 GDataCache::CACHE_TYPE_TMP,
326 GDataCache::CACHED_FILE_FROM_SERVER); 326 GDataCache::CACHED_FILE_FROM_SERVER);
327 } 327 }
328 328
329 GDataEntry* FindEntry(const FilePath& file_path) { 329 GDataEntry* FindEntry(const FilePath& file_path) {
330 GDataEntry* entry = NULL; 330 base::AutoLock lock(file_system_->lock_);
331 file_system_->root_->FindEntryByPath( 331 return file_system_->GetGDataEntryByPath(file_path);
332 file_path, base::Bind(&ReadOnlyFindEntryCallback, &entry));
333 return entry;
334 } 332 }
335 333
336 void FindAndTestFilePath(const FilePath& file_path) { 334 void FindAndTestFilePath(const FilePath& file_path) {
337 GDataEntry* entry = FindEntry(file_path); 335 GDataEntry* entry = FindEntry(file_path);
338 ASSERT_TRUE(entry) << "Entry can't be found " << file_path.value(); 336 ASSERT_TRUE(entry) << "Entry can't be found " << file_path.value();
339 EXPECT_EQ(entry->GetFilePath(), file_path); 337 EXPECT_EQ(entry->GetFilePath(), file_path);
340 } 338 }
341 339
342 GDataEntry* FindEntryByResourceId(const std::string& resource_id) { 340 GDataEntry* FindEntryByResourceId(const std::string& resource_id) {
343 GDataEntry* entry = NULL; 341 GDataEntry* entry = file_system_->root_->GetEntryByResourceId(resource_id);
344 file_system_->FindEntryByResourceIdSync( 342 return entry ? entry->AsGDataFile() : NULL;
345 resource_id, base::Bind(&ReadOnlyFindEntryCallback, &entry));
346 return entry;
347 } 343 }
348 344
349 // Gets the entry info for |file_path| and compares the contents against 345 // Gets the entry info for |file_path| and compares the contents against
350 // |entry|. Returns true if the entry info matches |entry|. 346 // |entry|. Returns true if the entry info matches |entry|.
351 bool GetEntryInfoAndCompare(const FilePath& file_path, 347 bool GetEntryInfoAndCompare(const FilePath& file_path,
352 GDataEntry* entry) { 348 GDataEntry* entry) {
353 file_system_->GetEntryInfoByPathAsync( 349 file_system_->GetEntryInfoByPathAsync(
354 file_path, 350 file_path,
355 base::Bind(&CallbackHelper::GetEntryInfoCallback, 351 base::Bind(&CallbackHelper::GetEntryInfoCallback,
356 callback_helper_.get())); 352 callback_helper_.get()));
(...skipping 3469 matching lines...) Expand 10 before | Expand all | Expand 10 after
3826 // Verify that the file was properly closed. 3822 // Verify that the file was properly closed.
3827 EXPECT_EQ(base::PLATFORM_FILE_OK, callback_helper_->last_error_); 3823 EXPECT_EQ(base::PLATFORM_FILE_OK, callback_helper_->last_error_);
3828 3824
3829 // Verify that the cache state was changed as expected. 3825 // Verify that the cache state was changed as expected.
3830 VerifyCacheStateAfterCloseFile(callback_helper_->last_error_, 3826 VerifyCacheStateAfterCloseFile(callback_helper_->last_error_,
3831 file_resource_id, 3827 file_resource_id,
3832 file_md5); 3828 file_md5);
3833 } 3829 }
3834 3830
3835 } // namespace gdata 3831 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | chrome/browser/chromeos/gdata/gdata_files.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698