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

Side by Side Diff: chrome/browser/history/in_memory_url_index_unittest.cc

Issue 352913002: Port HistoryService::ScheduleDBTask to CancelableTaskTracker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 <algorithm> 5 #include <algorithm>
6 #include <fstream> 6 #include <fstream>
7 7
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // Validates that the given |term| is contained in |cache| and that it is 96 // Validates that the given |term| is contained in |cache| and that it is
97 // marked as in-use. 97 // marked as in-use.
98 void CheckTerm(const URLIndexPrivateData::SearchTermCacheMap& cache, 98 void CheckTerm(const URLIndexPrivateData::SearchTermCacheMap& cache,
99 base::string16 term) const; 99 base::string16 term) const;
100 100
101 // Pass-through function to simplify our friendship with HistoryService. 101 // Pass-through function to simplify our friendship with HistoryService.
102 sql::Connection& GetDB(); 102 sql::Connection& GetDB();
103 103
104 // Pass-through functions to simplify our friendship with InMemoryURLIndex. 104 // Pass-through functions to simplify our friendship with InMemoryURLIndex.
105 URLIndexPrivateData* GetPrivateData() const; 105 URLIndexPrivateData* GetPrivateData() const;
106 base::CancelableTaskTracker* GetPrivateDataTracker() const;
106 void ClearPrivateData(); 107 void ClearPrivateData();
107 void set_history_dir(const base::FilePath& dir_path); 108 void set_history_dir(const base::FilePath& dir_path);
108 bool GetCacheFilePath(base::FilePath* file_path) const; 109 bool GetCacheFilePath(base::FilePath* file_path) const;
109 void PostRestoreFromCacheFileTask(); 110 void PostRestoreFromCacheFileTask();
110 void PostSaveToCacheFileTask(); 111 void PostSaveToCacheFileTask();
111 void Observe(int notification_type, 112 void Observe(int notification_type,
112 const content::NotificationSource& source, 113 const content::NotificationSource& source,
113 const content::NotificationDetails& details); 114 const content::NotificationDetails& details);
114 const std::set<std::string>& scheme_whitelist(); 115 const std::set<std::string>& scheme_whitelist();
115 116
(...skipping 25 matching lines...) Expand all
141 142
142 sql::Connection& InMemoryURLIndexTest::GetDB() { 143 sql::Connection& InMemoryURLIndexTest::GetDB() {
143 return history_database_->GetDB(); 144 return history_database_->GetDB();
144 } 145 }
145 146
146 URLIndexPrivateData* InMemoryURLIndexTest::GetPrivateData() const { 147 URLIndexPrivateData* InMemoryURLIndexTest::GetPrivateData() const {
147 DCHECK(url_index_->private_data()); 148 DCHECK(url_index_->private_data());
148 return url_index_->private_data(); 149 return url_index_->private_data();
149 } 150 }
150 151
152 base::CancelableTaskTracker* InMemoryURLIndexTest::GetPrivateDataTracker() const {
153 DCHECK(url_index_->private_data_tracker());
154 return url_index_->private_data_tracker();
155 }
156
151 void InMemoryURLIndexTest::ClearPrivateData() { 157 void InMemoryURLIndexTest::ClearPrivateData() {
152 return url_index_->ClearPrivateData(); 158 return url_index_->ClearPrivateData();
153 } 159 }
154 160
155 void InMemoryURLIndexTest::set_history_dir(const base::FilePath& dir_path) { 161 void InMemoryURLIndexTest::set_history_dir(const base::FilePath& dir_path) {
156 return url_index_->set_history_dir(dir_path); 162 return url_index_->set_history_dir(dir_path);
157 } 163 }
158 164
159 bool InMemoryURLIndexTest::GetCacheFilePath(base::FilePath* file_path) const { 165 bool InMemoryURLIndexTest::GetCacheFilePath(base::FilePath* file_path) const {
160 DCHECK(file_path); 166 DCHECK(file_path);
(...skipping 13 matching lines...) Expand all
174 const content::NotificationSource& source, 180 const content::NotificationSource& source,
175 const content::NotificationDetails& details) { 181 const content::NotificationDetails& details) {
176 url_index_->Observe(notification_type, source, details); 182 url_index_->Observe(notification_type, source, details);
177 } 183 }
178 184
179 const std::set<std::string>& InMemoryURLIndexTest::scheme_whitelist() { 185 const std::set<std::string>& InMemoryURLIndexTest::scheme_whitelist() {
180 return url_index_->scheme_whitelist(); 186 return url_index_->scheme_whitelist();
181 } 187 }
182 188
183 bool InMemoryURLIndexTest::UpdateURL(const URLRow& row) { 189 bool InMemoryURLIndexTest::UpdateURL(const URLRow& row) {
184 return GetPrivateData()->UpdateURL( 190 return GetPrivateData()->UpdateURL(history_service_,
185 history_service_, row, url_index_->languages_, 191 row,
186 url_index_->scheme_whitelist_); 192 url_index_->languages_,
193 url_index_->scheme_whitelist_,
194 GetPrivateDataTracker());
187 } 195 }
188 196
189 bool InMemoryURLIndexTest::DeleteURL(const GURL& url) { 197 bool InMemoryURLIndexTest::DeleteURL(const GURL& url) {
190 return GetPrivateData()->DeleteURL(url); 198 return GetPrivateData()->DeleteURL(url);
191 } 199 }
192 200
193 void InMemoryURLIndexTest::SetUp() { 201 void InMemoryURLIndexTest::SetUp() {
194 // We cannot access the database until the backend has been loaded. 202 // We cannot access the database until the backend has been loaded.
195 ASSERT_TRUE(profile_.CreateHistoryService(true, false)); 203 ASSERT_TRUE(profile_.CreateHistoryService(true, false));
196 profile_.CreateBookmarkModel(true); 204 profile_.CreateBookmarkModel(true);
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 full_file_path.GetComponents(&actual_parts); 1208 full_file_path.GetComponents(&actual_parts);
1201 ASSERT_EQ(expected_parts.size(), actual_parts.size()); 1209 ASSERT_EQ(expected_parts.size(), actual_parts.size());
1202 size_t count = expected_parts.size(); 1210 size_t count = expected_parts.size();
1203 for (size_t i = 0; i < count; ++i) 1211 for (size_t i = 0; i < count; ++i)
1204 EXPECT_EQ(expected_parts[i], actual_parts[i]); 1212 EXPECT_EQ(expected_parts[i], actual_parts[i]);
1205 // Must clear the history_dir_ to satisfy the dtor's DCHECK. 1213 // Must clear the history_dir_ to satisfy the dtor's DCHECK.
1206 set_history_dir(base::FilePath()); 1214 set_history_dir(base::FilePath());
1207 } 1215 }
1208 1216
1209 } // namespace history 1217 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698