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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/chromeos/drive/drive.pb.h" | 16 #include "chrome/browser/chromeos/drive/drive.pb.h" |
17 #include "chrome/browser/chromeos/drive/drive_file_system.h" | 17 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
18 #include "chrome/browser/chromeos/drive/drive_scheduler.h" | |
19 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" | 18 #include "chrome/browser/chromeos/drive/drive_webapps_registry.h" |
20 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" | 19 #include "chrome/browser/chromeos/drive/fake_free_disk_space_getter.h" |
| 20 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
21 #include "chrome/browser/chromeos/drive/mock_directory_change_observer.h" | 21 #include "chrome/browser/chromeos/drive/mock_directory_change_observer.h" |
22 #include "chrome/browser/chromeos/drive/mock_drive_cache_observer.h" | 22 #include "chrome/browser/chromeos/drive/mock_drive_cache_observer.h" |
23 #include "chrome/browser/chromeos/drive/stale_cache_files_remover.h" | 23 #include "chrome/browser/chromeos/drive/stale_cache_files_remover.h" |
24 #include "chrome/browser/chromeos/drive/test_util.h" | 24 #include "chrome/browser/chromeos/drive/test_util.h" |
25 #include "chrome/browser/google_apis/drive_api_parser.h" | 25 #include "chrome/browser/google_apis/drive_api_parser.h" |
26 #include "chrome/browser/google_apis/fake_drive_service.h" | 26 #include "chrome/browser/google_apis/fake_drive_service.h" |
27 #include "chrome/browser/google_apis/test_util.h" | 27 #include "chrome/browser/google_apis/test_util.h" |
28 #include "chrome/browser/google_apis/time_util.h" | 28 #include "chrome/browser/google_apis/time_util.h" |
29 #include "chrome/test/base/testing_profile.h" | 29 #include "chrome/test/base/testing_profile.h" |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 fake_drive_service_.reset(new google_apis::FakeDriveService); | 63 fake_drive_service_.reset(new google_apis::FakeDriveService); |
64 fake_drive_service_->LoadResourceListForWapi( | 64 fake_drive_service_->LoadResourceListForWapi( |
65 "chromeos/gdata/root_feed.json"); | 65 "chromeos/gdata/root_feed.json"); |
66 fake_drive_service_->LoadAccountMetadataForWapi( | 66 fake_drive_service_->LoadAccountMetadataForWapi( |
67 "chromeos/gdata/account_metadata.json"); | 67 "chromeos/gdata/account_metadata.json"); |
68 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json"); | 68 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json"); |
69 | 69 |
70 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); | 70 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); |
71 | 71 |
72 scheduler_.reset(new DriveScheduler(profile_.get(), | 72 scheduler_.reset(new JobScheduler(profile_.get(), |
73 fake_drive_service_.get())); | 73 fake_drive_service_.get())); |
74 | 74 |
75 scoped_refptr<base::SequencedWorkerPool> pool = | 75 scoped_refptr<base::SequencedWorkerPool> pool = |
76 content::BrowserThread::GetBlockingPool(); | 76 content::BrowserThread::GetBlockingPool(); |
77 blocking_task_runner_ = | 77 blocking_task_runner_ = |
78 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); | 78 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); |
79 | 79 |
80 // Likewise, this will be owned by DriveFileSystem. | 80 // Likewise, this will be owned by DriveFileSystem. |
81 cache_.reset(new DriveCache(DriveCache::GetCacheRootPath(profile_.get()), | 81 cache_.reset(new DriveCache(DriveCache::GetCacheRootPath(profile_.get()), |
82 blocking_task_runner_, | 82 blocking_task_runner_, |
83 fake_free_disk_space_getter_.get())); | 83 fake_free_disk_space_getter_.get())); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 MessageLoopForUI message_loop_; | 131 MessageLoopForUI message_loop_; |
132 // The order of the test threads is important, do not change the order. | 132 // The order of the test threads is important, do not change the order. |
133 // See also content/browser/browser_thread_impl.cc. | 133 // See also content/browser/browser_thread_impl.cc. |
134 content::TestBrowserThread ui_thread_; | 134 content::TestBrowserThread ui_thread_; |
135 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 135 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
136 scoped_ptr<TestingProfile> profile_; | 136 scoped_ptr<TestingProfile> profile_; |
137 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_; | 137 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_; |
138 DriveFileSystem* file_system_; | 138 DriveFileSystem* file_system_; |
139 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; | 139 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; |
140 scoped_ptr<DriveScheduler> scheduler_; | 140 scoped_ptr<JobScheduler> scheduler_; |
141 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_; | 141 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_; |
142 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> | 142 scoped_ptr<DriveResourceMetadata, test_util::DestroyHelperForTests> |
143 resource_metadata_; | 143 resource_metadata_; |
144 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; | 144 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; |
145 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; | 145 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; |
146 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; | 146 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; |
147 scoped_ptr<StaleCacheFilesRemover> stale_cache_files_remover_; | 147 scoped_ptr<StaleCacheFilesRemover> stale_cache_files_remover_; |
148 | 148 |
149 int root_feed_changestamp_; | 149 int root_feed_changestamp_; |
150 }; | 150 }; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 // Verify that the cache entry is deleted. | 192 // Verify that the cache entry is deleted. |
193 cache_->GetCacheEntry(resource_id, md5, | 193 cache_->GetCacheEntry(resource_id, md5, |
194 google_apis::test_util::CreateCopyResultCallback( | 194 google_apis::test_util::CreateCopyResultCallback( |
195 &success, &cache_entry)); | 195 &success, &cache_entry)); |
196 google_apis::test_util::RunBlockingPoolTask(); | 196 google_apis::test_util::RunBlockingPoolTask(); |
197 EXPECT_FALSE(success); | 197 EXPECT_FALSE(success); |
198 } | 198 } |
199 | 199 |
200 } // namespace drive | 200 } // namespace drive |
OLD | NEW |