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

Unified Diff: chrome/browser/ui/app_list/search/history.cc

Issue 15875007: app_list: Search result launch history and boost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win7_aura unit_test Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/search/history.h ('k') | chrome/browser/ui/app_list/search/history_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/search/history.cc
diff --git a/chrome/browser/ui/app_list/search/history.cc b/chrome/browser/ui/app_list/search/history.cc
new file mode 100644
index 0000000000000000000000000000000000000000..66cf5d4fc9a87ebcb0779f728fbb7f9efec9f50f
--- /dev/null
+++ b/chrome/browser/ui/app_list/search/history.cc
@@ -0,0 +1,65 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/app_list/search/history.h"
+
+#include "base/files/file_path.h"
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/ui/app_list/search/history_data.h"
+#include "chrome/browser/ui/app_list/search/history_data_store.h"
+#include "chrome/browser/ui/app_list/search/tokenized_string.h"
+#include "content/public/browser/browser_context.h"
+
+namespace app_list {
+
+namespace {
+
+// Normalize the given string by joining all its tokens with a space.
+std::string NormalizeString(const std::string& utf8) {
+ TokenizedString tokenized(UTF8ToUTF16(utf8));
+ return UTF16ToUTF8(JoinString(tokenized.tokens(), ' '));
+}
+
+} // namespace
+
+History::History(content::BrowserContext* context)
+ : browser_context_(context),
+ data_loaded_(false) {
+ const char kStoreDataFileName[] = "App Launcher Search";
+ const size_t kMaxQueryEntries = 1000;
+ const size_t kMaxSecondaryQueries = 5;
+
+ const base::FilePath data_file =
+ browser_context_->GetPath().AppendASCII(kStoreDataFileName);
+ store_ = new HistoryDataStore(data_file);
+ data_.reset(new HistoryData(store_, kMaxQueryEntries, kMaxSecondaryQueries));
+ data_->AddObserver(this);
+}
+
+History::~History() {
+ data_->RemoveObserver(this);
+}
+
+bool History::IsReady() const {
+ return data_loaded_;
+}
+
+void History::AddLaunchEvent(const std::string& query,
+ const std::string& result_id) {
+ DCHECK(IsReady());
+ data_->Add(NormalizeString(query), result_id);
+}
+
+scoped_ptr<KnownResults> History::GetKnownResults(
+ const std::string& query) const {
+ DCHECK(IsReady());
+ return data_->GetKnownResults(NormalizeString(query)).Pass();
+}
+
+void History::OnHistoryDataLoadedFromStore() {
+ data_loaded_ = true;
+}
+
+} // namespace app_list
« no previous file with comments | « chrome/browser/ui/app_list/search/history.h ('k') | chrome/browser/ui/app_list/search/history_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698