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/sync_client.h" | 5 #include "chrome/browser/chromeos/drive/sync_client.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 profile_.reset(new TestingProfile); | 88 profile_.reset(new TestingProfile); |
89 | 89 |
90 fake_network_change_notifier_.reset( | 90 fake_network_change_notifier_.reset( |
91 new test_util::FakeNetworkChangeNotifier); | 91 new test_util::FakeNetworkChangeNotifier); |
92 | 92 |
93 drive_service_.reset(new SyncClientTestDriveService); | 93 drive_service_.reset(new SyncClientTestDriveService); |
94 drive_service_->LoadResourceListForWapi("gdata/empty_feed.json"); | 94 drive_service_->LoadResourceListForWapi("gdata/empty_feed.json"); |
95 drive_service_->LoadAccountMetadataForWapi( | 95 drive_service_->LoadAccountMetadataForWapi( |
96 "gdata/account_metadata.json"); | 96 "gdata/account_metadata.json"); |
97 | 97 |
98 scheduler_.reset(new JobScheduler(profile_.get(), drive_service_.get(), | 98 scheduler_.reset(new JobScheduler(profile_.get(), |
99 base::MessageLoopProxy::current())); | 99 drive_service_.get(), |
| 100 base::MessageLoopProxy::current().get())); |
100 | 101 |
101 metadata_storage_.reset(new ResourceMetadataStorage( | 102 metadata_storage_.reset(new ResourceMetadataStorage( |
102 temp_dir_.path(), base::MessageLoopProxy::current())); | 103 temp_dir_.path(), base::MessageLoopProxy::current().get())); |
103 ASSERT_TRUE(metadata_storage_->Initialize()); | 104 ASSERT_TRUE(metadata_storage_->Initialize()); |
104 | 105 |
105 metadata_.reset(new internal::ResourceMetadata( | 106 metadata_.reset(new internal::ResourceMetadata( |
106 metadata_storage_.get(), base::MessageLoopProxy::current())); | 107 metadata_storage_.get(), base::MessageLoopProxy::current())); |
107 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); | 108 ASSERT_EQ(FILE_ERROR_OK, metadata_->Initialize()); |
108 | 109 |
109 cache_.reset(new FileCache(metadata_storage_.get(), | 110 cache_.reset(new FileCache(metadata_storage_.get(), |
110 temp_dir_.path(), | 111 temp_dir_.path(), |
111 base::MessageLoopProxy::current(), | 112 base::MessageLoopProxy::current().get(), |
112 NULL /* free_disk_space_getter */)); | 113 NULL /* free_disk_space_getter */)); |
113 ASSERT_TRUE(cache_->Initialize()); | 114 ASSERT_TRUE(cache_->Initialize()); |
114 | 115 |
115 ASSERT_NO_FATAL_FAILURE(SetUpTestData()); | 116 ASSERT_NO_FATAL_FAILURE(SetUpTestData()); |
116 | 117 |
117 sync_client_.reset(new SyncClient(base::MessageLoopProxy::current(), | 118 sync_client_.reset(new SyncClient(base::MessageLoopProxy::current().get(), |
118 &observer_, | 119 &observer_, |
119 scheduler_.get(), | 120 scheduler_.get(), |
120 metadata_.get(), | 121 metadata_.get(), |
121 cache_.get(), | 122 cache_.get(), |
122 temp_dir_.path())); | 123 temp_dir_.path())); |
123 | 124 |
124 // Disable delaying so that DoSyncLoop() starts immediately. | 125 // Disable delaying so that DoSyncLoop() starts immediately. |
125 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); | 126 sync_client_->set_delay_for_testing(base::TimeDelta::FromSeconds(0)); |
126 } | 127 } |
127 | 128 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 EXPECT_EQ(FILE_ERROR_OK, | 176 EXPECT_EQ(FILE_ERROR_OK, |
176 cache_->Store(resource_ids_["dirty"], md5_dirty, | 177 cache_->Store(resource_ids_["dirty"], md5_dirty, |
177 temp_file, FileCache::FILE_OPERATION_COPY)); | 178 temp_file, FileCache::FILE_OPERATION_COPY)); |
178 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(resource_ids_["dirty"])); | 179 EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(resource_ids_["dirty"])); |
179 EXPECT_EQ(FILE_ERROR_OK, | 180 EXPECT_EQ(FILE_ERROR_OK, |
180 cache_->MarkDirty(resource_ids_["dirty"], md5_dirty)); | 181 cache_->MarkDirty(resource_ids_["dirty"], md5_dirty)); |
181 | 182 |
182 // Load data from the service to the metadata. | 183 // Load data from the service to the metadata. |
183 FileError error = FILE_ERROR_FAILED; | 184 FileError error = FILE_ERROR_FAILED; |
184 internal::ChangeListLoader change_list_loader( | 185 internal::ChangeListLoader change_list_loader( |
185 base::MessageLoopProxy::current(), metadata_.get(), scheduler_.get()); | 186 base::MessageLoopProxy::current().get(), |
| 187 metadata_.get(), |
| 188 scheduler_.get()); |
186 change_list_loader.LoadIfNeeded( | 189 change_list_loader.LoadIfNeeded( |
187 DirectoryFetchInfo(), | 190 DirectoryFetchInfo(), |
188 google_apis::test_util::CreateCopyResultCallback(&error)); | 191 google_apis::test_util::CreateCopyResultCallback(&error)); |
189 base::RunLoop().RunUntilIdle(); | 192 base::RunLoop().RunUntilIdle(); |
190 EXPECT_EQ(FILE_ERROR_OK, error); | 193 EXPECT_EQ(FILE_ERROR_OK, error); |
191 } | 194 } |
192 | 195 |
193 protected: | 196 protected: |
194 content::TestBrowserThreadBundle thread_bundle_; | 197 content::TestBrowserThreadBundle thread_bundle_; |
195 base::ScopedTempDir temp_dir_; | 198 base::ScopedTempDir temp_dir_; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 EXPECT_TRUE(cache_->GetCacheEntry(resource_ids_["foo"], std::string(), | 342 EXPECT_TRUE(cache_->GetCacheEntry(resource_ids_["foo"], std::string(), |
340 &cache_entry)); | 343 &cache_entry)); |
341 EXPECT_TRUE(cache_entry.is_present()); | 344 EXPECT_TRUE(cache_entry.is_present()); |
342 EXPECT_TRUE(cache_->GetCacheEntry(resource_ids_["dirty"], std::string(), | 345 EXPECT_TRUE(cache_->GetCacheEntry(resource_ids_["dirty"], std::string(), |
343 &cache_entry)); | 346 &cache_entry)); |
344 EXPECT_FALSE(cache_entry.is_dirty()); | 347 EXPECT_FALSE(cache_entry.is_dirty()); |
345 } | 348 } |
346 | 349 |
347 } // namespace internal | 350 } // namespace internal |
348 } // namespace drive | 351 } // namespace drive |
OLD | NEW |