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

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

Issue 12706012: chromeos: Destruct DriveResourceMetadata on the blocking pool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add note Created 7 years, 9 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
« no previous file with comments | « chrome/browser/chromeos/drive/search_metadata_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json"); 66 fake_drive_service_->LoadAppListForDriveApi("chromeos/drive/applist.json");
67 67
68 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); 68 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter);
69 69
70 scoped_refptr<base::SequencedWorkerPool> pool = 70 scoped_refptr<base::SequencedWorkerPool> pool =
71 content::BrowserThread::GetBlockingPool(); 71 content::BrowserThread::GetBlockingPool();
72 blocking_task_runner_ = 72 blocking_task_runner_ =
73 pool->GetSequencedTaskRunner(pool->GetSequenceToken()); 73 pool->GetSequencedTaskRunner(pool->GetSequenceToken());
74 74
75 // Likewise, this will be owned by DriveFileSystem. 75 // Likewise, this will be owned by DriveFileSystem.
76 cache_ = new DriveCache( 76 cache_.reset(new DriveCache(DriveCache::GetCacheRootPath(profile_.get()),
77 DriveCache::GetCacheRootPath(profile_.get()), 77 blocking_task_runner_,
78 blocking_task_runner_, 78 fake_free_disk_space_getter_.get()));
79 fake_free_disk_space_getter_.get());
80 79
81 drive_webapps_registry_.reset(new DriveWebAppsRegistry); 80 drive_webapps_registry_.reset(new DriveWebAppsRegistry);
82 81
83 ASSERT_FALSE(file_system_); 82 ASSERT_FALSE(file_system_);
84 file_system_ = new DriveFileSystem(profile_.get(), 83 file_system_ = new DriveFileSystem(profile_.get(),
85 cache_, 84 cache_.get(),
86 fake_drive_service_.get(), 85 fake_drive_service_.get(),
87 NULL, // drive_uploader 86 NULL, // drive_uploader
88 drive_webapps_registry_.get(), 87 drive_webapps_registry_.get(),
89 blocking_task_runner_); 88 blocking_task_runner_);
90 89
91 mock_cache_observer_.reset(new StrictMock<MockDriveCacheObserver>); 90 mock_cache_observer_.reset(new StrictMock<MockDriveCacheObserver>);
92 cache_->AddObserver(mock_cache_observer_.get()); 91 cache_->AddObserver(mock_cache_observer_.get());
93 92
94 mock_directory_observer_.reset(new StrictMock<MockDirectoryChangeObserver>); 93 mock_directory_observer_.reset(new StrictMock<MockDirectoryChangeObserver>);
95 file_system_->AddObserver(mock_directory_observer_.get()); 94 file_system_->AddObserver(mock_directory_observer_.get());
96 95
97 file_system_->Initialize(); 96 file_system_->Initialize();
98 cache_->RequestInitializeForTesting(); 97 cache_->RequestInitializeForTesting();
99 98
100 stale_cache_files_remover_.reset(new StaleCacheFilesRemover(file_system_, 99 stale_cache_files_remover_.reset(new StaleCacheFilesRemover(file_system_,
101 cache_)); 100 cache_.get()));
102 101
103 google_apis::test_util::RunBlockingPoolTask(); 102 google_apis::test_util::RunBlockingPoolTask();
104 } 103 }
105 104
106 virtual void TearDown() OVERRIDE { 105 virtual void TearDown() OVERRIDE {
107 ASSERT_TRUE(file_system_); 106 ASSERT_TRUE(file_system_);
108 stale_cache_files_remover_.reset(); 107 stale_cache_files_remover_.reset();
109 delete file_system_; 108 delete file_system_;
110 file_system_ = NULL; 109 file_system_ = NULL;
111 test_util::DeleteDriveCache(cache_); 110 cache_.reset();
112 profile_.reset(NULL); 111 profile_.reset(NULL);
113 } 112 }
114 113
115 MessageLoopForUI message_loop_; 114 MessageLoopForUI message_loop_;
116 // The order of the test threads is important, do not change the order. 115 // The order of the test threads is important, do not change the order.
117 // See also content/browser/browser_thread_impl.cc. 116 // See also content/browser/browser_thread_impl.cc.
118 content::TestBrowserThread ui_thread_; 117 content::TestBrowserThread ui_thread_;
119 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 118 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
120 scoped_ptr<TestingProfile> profile_; 119 scoped_ptr<TestingProfile> profile_;
121 DriveCache* cache_; 120 scoped_ptr<DriveCache, test_util::DestroyHelperForTests> cache_;
122 DriveFileSystem* file_system_; 121 DriveFileSystem* file_system_;
123 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_; 122 scoped_ptr<google_apis::FakeDriveService> fake_drive_service_;
124 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_; 123 scoped_ptr<DriveWebAppsRegistry> drive_webapps_registry_;
125 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_; 124 scoped_ptr<FakeFreeDiskSpaceGetter> fake_free_disk_space_getter_;
126 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_; 125 scoped_ptr<StrictMock<MockDriveCacheObserver> > mock_cache_observer_;
127 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_; 126 scoped_ptr<StrictMock<MockDirectoryChangeObserver> > mock_directory_observer_;
128 scoped_ptr<StaleCacheFilesRemover> stale_cache_files_remover_; 127 scoped_ptr<StaleCacheFilesRemover> stale_cache_files_remover_;
129 128
130 int root_feed_changestamp_; 129 int root_feed_changestamp_;
131 }; 130 };
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 cache_->GetCacheEntry( 178 cache_->GetCacheEntry(
180 resource_id, md5, 179 resource_id, md5,
181 base::Bind(&test_util::CopyResultsFromGetCacheEntryCallback, 180 base::Bind(&test_util::CopyResultsFromGetCacheEntryCallback,
182 &success, 181 &success,
183 &cache_entry)); 182 &cache_entry));
184 google_apis::test_util::RunBlockingPoolTask(); 183 google_apis::test_util::RunBlockingPoolTask();
185 EXPECT_FALSE(success); 184 EXPECT_FALSE(success);
186 } 185 }
187 186
188 } // namespace drive 187 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/search_metadata_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698