| 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/chromeos/drive/file_system.h" | 5 #include "chrome/browser/chromeos/drive/file_system.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 fake_drive_service_.reset(new FakeDriveService); | 86 fake_drive_service_.reset(new FakeDriveService); |
| 87 fake_drive_service_->LoadResourceListForWapi( | 87 fake_drive_service_->LoadResourceListForWapi( |
| 88 "gdata/root_feed.json"); | 88 "gdata/root_feed.json"); |
| 89 fake_drive_service_->LoadAccountMetadataForWapi( | 89 fake_drive_service_->LoadAccountMetadataForWapi( |
| 90 "gdata/account_metadata.json"); | 90 "gdata/account_metadata.json"); |
| 91 | 91 |
| 92 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); | 92 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); |
| 93 | 93 |
| 94 scheduler_.reset(new JobScheduler(profile_.get(), | 94 scheduler_.reset(new JobScheduler(profile_.get(), |
| 95 fake_drive_service_.get(), | 95 fake_drive_service_.get(), |
| 96 base::MessageLoopProxy::current())); | 96 base::MessageLoopProxy::current().get())); |
| 97 | 97 |
| 98 ASSERT_TRUE(file_util::CreateDirectory(util::GetCacheRootPath( | 98 ASSERT_TRUE(file_util::CreateDirectory(util::GetCacheRootPath( |
| 99 profile_.get()).Append(util::kMetadataDirectory))); | 99 profile_.get()).Append(util::kMetadataDirectory))); |
| 100 ASSERT_TRUE(file_util::CreateDirectory(util::GetCacheRootPath( | 100 ASSERT_TRUE(file_util::CreateDirectory(util::GetCacheRootPath( |
| 101 profile_.get()).Append(util::kCacheFileDirectory))); | 101 profile_.get()).Append(util::kCacheFileDirectory))); |
| 102 ASSERT_TRUE(file_util::CreateDirectory(util::GetCacheRootPath( | 102 ASSERT_TRUE(file_util::CreateDirectory(util::GetCacheRootPath( |
| 103 profile_.get()).Append(util::kTemporaryFileDirectory))); | 103 profile_.get()).Append(util::kTemporaryFileDirectory))); |
| 104 | 104 |
| 105 mock_directory_observer_.reset(new MockDirectoryChangeObserver); | 105 mock_directory_observer_.reset(new MockDirectoryChangeObserver); |
| 106 | 106 |
| 107 SetUpResourceMetadataAndFileSystem(); | 107 SetUpResourceMetadataAndFileSystem(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void SetUpResourceMetadataAndFileSystem() { | 110 void SetUpResourceMetadataAndFileSystem() { |
| 111 metadata_storage_.reset(new internal::ResourceMetadataStorage( | 111 metadata_storage_.reset(new internal::ResourceMetadataStorage( |
| 112 util::GetCacheRootPath(profile_.get()).Append(util::kMetadataDirectory), | 112 util::GetCacheRootPath(profile_.get()).Append(util::kMetadataDirectory), |
| 113 base::MessageLoopProxy::current())); | 113 base::MessageLoopProxy::current().get())); |
| 114 ASSERT_TRUE(metadata_storage_->Initialize()); | 114 ASSERT_TRUE(metadata_storage_->Initialize()); |
| 115 | 115 |
| 116 cache_.reset(new internal::FileCache( | 116 cache_.reset(new internal::FileCache( |
| 117 metadata_storage_.get(), | 117 metadata_storage_.get(), |
| 118 util::GetCacheRootPath(profile_.get()).Append( | 118 util::GetCacheRootPath(profile_.get()).Append( |
| 119 util::kCacheFileDirectory), | 119 util::kCacheFileDirectory), |
| 120 base::MessageLoopProxy::current(), | 120 base::MessageLoopProxy::current().get(), |
| 121 fake_free_disk_space_getter_.get())); | 121 fake_free_disk_space_getter_.get())); |
| 122 ASSERT_TRUE(cache_->Initialize()); | 122 ASSERT_TRUE(cache_->Initialize()); |
| 123 | 123 |
| 124 resource_metadata_.reset(new internal::ResourceMetadata( | 124 resource_metadata_.reset(new internal::ResourceMetadata( |
| 125 metadata_storage_.get(), base::MessageLoopProxy::current())); | 125 metadata_storage_.get(), base::MessageLoopProxy::current())); |
| 126 | 126 |
| 127 file_system_.reset(new FileSystem( | 127 file_system_.reset(new FileSystem( |
| 128 profile_.get(), | 128 profile_.get(), |
| 129 cache_.get(), | 129 cache_.get(), |
| 130 fake_drive_service_.get(), | 130 fake_drive_service_.get(), |
| 131 scheduler_.get(), | 131 scheduler_.get(), |
| 132 resource_metadata_.get(), | 132 resource_metadata_.get(), |
| 133 base::MessageLoopProxy::current(), | 133 base::MessageLoopProxy::current().get(), |
| 134 util::GetCacheRootPath(profile_.get()).Append( | 134 util::GetCacheRootPath(profile_.get()).Append( |
| 135 util::kTemporaryFileDirectory))); | 135 util::kTemporaryFileDirectory))); |
| 136 file_system_->AddObserver(mock_directory_observer_.get()); | 136 file_system_->AddObserver(mock_directory_observer_.get()); |
| 137 file_system_->Initialize(); | 137 file_system_->Initialize(); |
| 138 | 138 |
| 139 // Disable delaying so that the sync starts immediately. | 139 // Disable delaying so that the sync starts immediately. |
| 140 file_system_->sync_client_for_testing()->set_delay_for_testing( | 140 file_system_->sync_client_for_testing()->set_delay_for_testing( |
| 141 base::TimeDelta::FromSeconds(0)); | 141 base::TimeDelta::FromSeconds(0)); |
| 142 | 142 |
| 143 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize()); | 143 ASSERT_EQ(FILE_ERROR_OK, resource_metadata_->Initialize()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // the changestamp to 654321, equal to that of "account_metadata.json" test | 207 // the changestamp to 654321, equal to that of "account_metadata.json" test |
| 208 // data, indicating the cache is holding the latest file system info. | 208 // data, indicating the cache is holding the latest file system info. |
| 209 bool SetUpTestFileSystem(SetUpTestFileSystemParam param) { | 209 bool SetUpTestFileSystem(SetUpTestFileSystemParam param) { |
| 210 // Destroy the existing resource metadata to close DB. | 210 // Destroy the existing resource metadata to close DB. |
| 211 resource_metadata_.reset(); | 211 resource_metadata_.reset(); |
| 212 | 212 |
| 213 base::FilePath metadata_directory = | 213 base::FilePath metadata_directory = |
| 214 util::GetCacheRootPath(profile_.get()).Append(util::kMetadataDirectory); | 214 util::GetCacheRootPath(profile_.get()).Append(util::kMetadataDirectory); |
| 215 scoped_ptr<internal::ResourceMetadataStorage, | 215 scoped_ptr<internal::ResourceMetadataStorage, |
| 216 test_util::DestroyHelperForTests> metadata_storage( | 216 test_util::DestroyHelperForTests> metadata_storage( |
| 217 new internal::ResourceMetadataStorage( | 217 new internal::ResourceMetadataStorage( |
| 218 metadata_directory, base::MessageLoopProxy::current())); | 218 metadata_directory, base::MessageLoopProxy::current().get())); |
| 219 | 219 |
| 220 scoped_ptr<internal::ResourceMetadata, test_util::DestroyHelperForTests> | 220 scoped_ptr<internal::ResourceMetadata, test_util::DestroyHelperForTests> |
| 221 resource_metadata(new internal::ResourceMetadata( | 221 resource_metadata(new internal::ResourceMetadata( |
| 222 metadata_storage_.get(), base::MessageLoopProxy::current())); | 222 metadata_storage_.get(), base::MessageLoopProxy::current())); |
| 223 | 223 |
| 224 if (resource_metadata->Initialize() != FILE_ERROR_OK) | 224 if (resource_metadata->Initialize() != FILE_ERROR_OK) |
| 225 return false; | 225 return false; |
| 226 | 226 |
| 227 const int64 changestamp = param == USE_SERVER_TIMESTAMP ? 654321 : 1; | 227 const int64 changestamp = param == USE_SERVER_TIMESTAMP ? 654321 : 1; |
| 228 if (resource_metadata->SetLargestChangestamp(changestamp) != FILE_ERROR_OK) | 228 if (resource_metadata->SetLargestChangestamp(changestamp) != FILE_ERROR_OK) |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 file_path, | 868 file_path, |
| 869 google_apis::test_util::CreateCopyResultCallback(&error)); | 869 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 870 google_apis::test_util::RunBlockingPoolTask(); | 870 google_apis::test_util::RunBlockingPoolTask(); |
| 871 EXPECT_EQ(FILE_ERROR_OK, error); | 871 EXPECT_EQ(FILE_ERROR_OK, error); |
| 872 | 872 |
| 873 // Now able to remove the cache entry. | 873 // Now able to remove the cache entry. |
| 874 EXPECT_EQ(FILE_ERROR_OK, cache_->Remove(entry->resource_id())); | 874 EXPECT_EQ(FILE_ERROR_OK, cache_->Remove(entry->resource_id())); |
| 875 } | 875 } |
| 876 | 876 |
| 877 } // namespace drive | 877 } // namespace drive |
| OLD | NEW |