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

Unified Diff: chrome/browser/ui/app_list/search/common/webservice_search_provider.h

Issue 23874015: Implement people search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
Index: chrome/browser/ui/app_list/search/common/webservice_search_provider.h
diff --git a/chrome/browser/ui/app_list/search/common/webservice_search_provider.h b/chrome/browser/ui/app_list/search/common/webservice_search_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..05bfd6751ad1806f1b9a1dd3e24a3a702511064a
--- /dev/null
+++ b/chrome/browser/ui/app_list/search/common/webservice_search_provider.h
@@ -0,0 +1,52 @@
+// 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.
+
+#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H_
+#define CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H_
+
+#include "base/callback_forward.h"
+#include "base/strings/string16.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "chrome/browser/ui/app_list/search/search_provider.h"
+
+class Profile;
+
+namespace app_list {
+
+// Helper class for webservice based searches.
+class WebserviceSearchProvider : public SearchProvider {
+ public:
+ explicit WebserviceSearchProvider(Profile* profile);
+ virtual ~WebserviceSearchProvider();
+
+ // Validate the query for privacy and size.
+ bool IsValidQuery(const string16& query);
+
+ // Start a query with throttling enabled.
+ void StartThrottledQuery(const base::Closure& start_query);
+
+ void set_use_throttling(bool use) { use_throttling_ = use; }
+
+ protected:
+ Profile* profile_;
+
+ private:
+ bool IsSensitiveInput(const string16& query);
+
+ // The timestamp when the last key event happened.
+ base::Time last_keytyped_;
+
+ // The timer to throttle QPS.
+ base::OneShotTimer<WebserviceSearchProvider> query_throttler_;
+
+ // The flag for tests. It prevents the throttling If set to false.
+ bool use_throttling_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebserviceSearchProvider);
+};
+
+} // namespace app_list
+
+#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_COMMON_WEBSERVICE_SEARCH_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698