summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/app_list/search/common/dictionary_data_store.cc16
-rw-r--r--chrome/browser/ui/app_list/search/common/dictionary_data_store.h6
-rw-r--r--chrome/browser/ui/app_list/search/common/webservice_cache.cc4
-rw-r--r--chrome/browser/ui/app_list/search/history_data_store_unittest.cc10
-rw-r--r--chrome/browser/ui/app_list/search/history_factory.cc4
-rw-r--r--chrome/browser/ui/app_list/search/history_unittest.cc17
6 files changed, 31 insertions, 26 deletions
diff --git a/chrome/browser/ui/app_list/search/common/dictionary_data_store.cc b/chrome/browser/ui/app_list/search/common/dictionary_data_store.cc
index fd50e8d..23244dd 100644
--- a/chrome/browser/ui/app_list/search/common/dictionary_data_store.cc
+++ b/chrome/browser/ui/app_list/search/common/dictionary_data_store.cc
@@ -8,26 +8,24 @@
#include "base/json/json_file_value_serializer.h"
#include "base/json/json_string_value_serializer.h"
#include "base/logging.h"
+#include "base/sequenced_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/task_runner_util.h"
#include "base/threading/sequenced_worker_pool.h"
#include "base/values.h"
-#include "content/public/browser/browser_thread.h"
-
-using content::BrowserThread;
namespace app_list {
-DictionaryDataStore::DictionaryDataStore(const base::FilePath& data_file)
- : data_file_(data_file) {
+DictionaryDataStore::DictionaryDataStore(const base::FilePath& data_file,
+ base::SequencedWorkerPool* worker_pool)
+ : data_file_(data_file), worker_pool_(worker_pool) {
std::string token("app-launcher-data-store");
token.append(data_file.AsUTF8Unsafe());
// Uses a SKIP_ON_SHUTDOWN file task runner because losing a couple
// associations is better than blocking shutdown.
- base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();
- file_task_runner_ = pool->GetSequencedTaskRunnerWithShutdownBehavior(
- pool->GetNamedSequenceToken(token),
+ file_task_runner_ = worker_pool->GetSequencedTaskRunnerWithShutdownBehavior(
+ worker_pool->GetNamedSequenceToken(token),
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
writer_.reset(
new base::ImportantFileWriter(data_file, file_task_runner_.get()));
@@ -64,7 +62,7 @@ void DictionaryDataStore::ScheduleWrite() {
}
scoped_ptr<base::DictionaryValue> DictionaryDataStore::LoadOnBlockingPool() {
- DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ DCHECK(worker_pool_->RunsTasksOnCurrentThread());
int error_code = JSONFileValueSerializer::JSON_NO_ERROR;
std::string error_message;
diff --git a/chrome/browser/ui/app_list/search/common/dictionary_data_store.h b/chrome/browser/ui/app_list/search/common/dictionary_data_store.h
index f731900..caedba1 100644
--- a/chrome/browser/ui/app_list/search/common/dictionary_data_store.h
+++ b/chrome/browser/ui/app_list/search/common/dictionary_data_store.h
@@ -18,6 +18,7 @@
namespace base {
class DictionaryValue;
class SequencedTaskRunner;
+class SequencedWorkerPool;
}
namespace app_list {
@@ -31,7 +32,8 @@ class DictionaryDataStore
scoped_ptr<base::DictionaryValue>)> OnLoadedCallback;
typedef base::Closure OnFlushedCallback;
- explicit DictionaryDataStore(const base::FilePath& data_file);
+ DictionaryDataStore(const base::FilePath& data_file,
+ base::SequencedWorkerPool* worker_pool);
// Flushes pending writes.
void Flush(const OnFlushedCallback& on_flushed);
@@ -66,6 +68,8 @@ class DictionaryDataStore
// Cached JSON dictionary to serve read and incremental change calls.
scoped_ptr<base::DictionaryValue> cached_dict_;
+ base::SequencedWorkerPool* worker_pool_;
+
DISALLOW_COPY_AND_ASSIGN(DictionaryDataStore);
};
diff --git a/chrome/browser/ui/app_list/search/common/webservice_cache.cc b/chrome/browser/ui/app_list/search/common/webservice_cache.cc
index 7835301..0925943 100644
--- a/chrome/browser/ui/app_list/search/common/webservice_cache.cc
+++ b/chrome/browser/ui/app_list/search/common/webservice_cache.cc
@@ -7,6 +7,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
namespace app_list {
namespace {
@@ -32,7 +33,8 @@ WebserviceCache::WebserviceCache(content::BrowserContext* context)
const char kStoreDataFileName[] = "Webservice Search Cache";
const base::FilePath data_file =
context->GetPath().AppendASCII(kStoreDataFileName);
- data_store_ = new DictionaryDataStore(data_file);
+ data_store_ = new DictionaryDataStore(
+ data_file, content::BrowserThread::GetBlockingPool());
data_store_->Load(base::Bind(&WebserviceCache::OnCacheLoaded, AsWeakPtr()));
}
diff --git a/chrome/browser/ui/app_list/search/history_data_store_unittest.cc b/chrome/browser/ui/app_list/search/history_data_store_unittest.cc
index a508652..95ef78b 100644
--- a/chrome/browser/ui/app_list/search/history_data_store_unittest.cc
+++ b/chrome/browser/ui/app_list/search/history_data_store_unittest.cc
@@ -9,10 +9,10 @@
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/ui/app_list/search/common/dictionary_data_store.h"
#include "chrome/browser/ui/app_list/search/history_data.h"
#include "chrome/browser/ui/app_list/search/history_data_store.h"
-#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace app_list {
@@ -40,12 +40,12 @@ std::string GetDataContent(const HistoryData::Data& data) {
class HistoryDataStoreTest : public testing::Test {
public:
- HistoryDataStoreTest()
- : ui_thread_(content::BrowserThread::UI, &message_loop_) {}
+ HistoryDataStoreTest() {}
virtual ~HistoryDataStoreTest() {}
// testing::Test overrides:
virtual void SetUp() override {
+ worker_pool_ = new base::SequencedWorkerPool(1, "AppLauncherTest");
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
}
virtual void TearDown() override {
@@ -56,7 +56,7 @@ class HistoryDataStoreTest : public testing::Test {
void OpenStore(const std::string& file_name) {
data_file_ = temp_dir_.path().AppendASCII(file_name);
store_ = new HistoryDataStore(scoped_refptr<DictionaryDataStore>(
- new DictionaryDataStore(data_file_)));
+ new DictionaryDataStore(data_file_, worker_pool_.get())));
Load();
}
@@ -94,10 +94,10 @@ class HistoryDataStoreTest : public testing::Test {
}
base::MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
base::ScopedTempDir temp_dir_;
base::FilePath data_file_;
scoped_ptr<base::RunLoop> run_loop_;
+ scoped_refptr<base::SequencedWorkerPool> worker_pool_;
scoped_refptr<HistoryDataStore> store_;
HistoryData::Associations associations_;
diff --git a/chrome/browser/ui/app_list/search/history_factory.cc b/chrome/browser/ui/app_list/search/history_factory.cc
index 08d90ce..6fe07da 100644
--- a/chrome/browser/ui/app_list/search/history_factory.cc
+++ b/chrome/browser/ui/app_list/search/history_factory.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/ui/app_list/search/history_data_store.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
namespace app_list {
@@ -39,7 +40,8 @@ KeyedService* HistoryFactory::BuildServiceInstanceFor(
const base::FilePath data_file =
context->GetPath().AppendASCII(kStoreDataFileName);
scoped_refptr<DictionaryDataStore> dictionary_data_store(
- new DictionaryDataStore(data_file));
+ new DictionaryDataStore(data_file,
+ content::BrowserThread::GetBlockingPool()));
scoped_refptr<HistoryDataStore> history_data_store(
new HistoryDataStore(dictionary_data_store));
return new History(history_data_store);
diff --git a/chrome/browser/ui/app_list/search/history_unittest.cc b/chrome/browser/ui/app_list/search/history_unittest.cc
index f200fee..505ff8f 100644
--- a/chrome/browser/ui/app_list/search/history_unittest.cc
+++ b/chrome/browser/ui/app_list/search/history_unittest.cc
@@ -4,6 +4,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
+#include "base/files/scoped_temp_dir.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
@@ -15,8 +16,6 @@
#include "chrome/browser/ui/app_list/search/history_data_observer.h"
#include "chrome/browser/ui/app_list/search/history_data_store.h"
#include "chrome/browser/ui/app_list/search/history_factory.h"
-#include "chrome/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace app_list {
@@ -89,13 +88,13 @@ class StoreFlushWaiter {
class SearchHistoryTest : public testing::Test {
public:
- SearchHistoryTest()
- : ui_thread_(content::BrowserThread::UI, &message_loop_) {}
+ SearchHistoryTest() {}
virtual ~SearchHistoryTest() {}
// testing::Test overrides:
virtual void SetUp() override {
- profile_.reset(new TestingProfile);
+ worker_pool_ = new base::SequencedWorkerPool(1, "AppLauncherTest");
+ ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
CreateHistory();
}
virtual void TearDown() override {
@@ -105,9 +104,9 @@ class SearchHistoryTest : public testing::Test {
void CreateHistory() {
const char kStoreDataFileName[] = "app-launcher-test";
const base::FilePath data_file =
- profile_->GetPath().AppendASCII(kStoreDataFileName);
+ temp_dir_.path().AppendASCII(kStoreDataFileName);
scoped_refptr<DictionaryDataStore> dictionary_data_store(
- new DictionaryDataStore(data_file));
+ new DictionaryDataStore(data_file, worker_pool_.get()));
history_.reset(new History(scoped_refptr<HistoryDataStore>(
new HistoryDataStore(dictionary_data_store))));
@@ -143,8 +142,8 @@ class SearchHistoryTest : public testing::Test {
private:
base::MessageLoopForUI message_loop_;
- content::TestBrowserThread ui_thread_;
- scoped_ptr<TestingProfile> profile_;
+ base::ScopedTempDir temp_dir_;
+ scoped_refptr<base::SequencedWorkerPool> worker_pool_;
scoped_ptr<History> history_;
scoped_ptr<KnownResults> known_results_;