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

Unified Diff: components/enhanced_bookmarks/bookmark_server_search_service.h

Issue 538903003: Bring up of the server side full text search. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/SigninManager/SigninManagerBase for ChromeOS. Created 6 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: components/enhanced_bookmarks/bookmark_server_search_service.h
diff --git a/components/enhanced_bookmarks/bookmark_server_search_service.h b/components/enhanced_bookmarks/bookmark_server_search_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..4b68d59c2b4171098753a53d0fb8711eb04fafd3
--- /dev/null
+++ b/components/enhanced_bookmarks/bookmark_server_search_service.h
@@ -0,0 +1,63 @@
+// Copyright 2014 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 COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_
+#define COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_
+
+#include <string>
+#include <vector>
+
+#include "components/enhanced_bookmarks/bookmark_server_service.h"
+#include "net/url_request/url_fetcher.h"
+
+class BookmarkModel;
+
+namespace enhanced_bookmarks {
+
+// Sends requests to the bookmark server to search for bookmarks relevant to a
+// given query. Will handle one outgoing request at a time.
+class BookmarkServerSearchService : public BookmarkServerService {
+ public:
+ BookmarkServerSearchService(
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter,
+ ProfileOAuth2TokenService* token_service,
+ SigninManagerBase* signin_manager,
+ BookmarkModel* bookmark_model);
+ virtual ~BookmarkServerSearchService();
+
+ // Triggers a search. The query must not be empty. A call to this method
+ // cancels any previous searches. OnChange() is garanteed to be called once
+ // per query.
+ void Search(const std::string& query);
+
+ // Returns the search results. The results are only available after the
+ // OnChange() observer methods has been sent. This method will return an empty
+ // result otherwise. query should be a string passed to Search() previously.
+ std::vector<const BookmarkNode*> ResultForQuery(const std::string& query);
+
+ protected:
+
+ virtual net::URLFetcher* CreateFetcherWithToken(
+ const std::string& access_token) OVERRIDE;
+
+ virtual bool ProcessResponse(const std::string& response,
+ bool* should_notify) OVERRIDE;
+
+ virtual void CleanAfterFailure() OVERRIDE;
+
+ // BookmarkModelObserver methods.
+ virtual void BookmarkNodeAdded(BookmarkModel* model,
+ const BookmarkNode* parent,
+ int index) OVERRIDE;
+ virtual void BookmarkMetaInfoChanged(BookmarkModel* model,
+ const BookmarkNode* node) OVERRIDE;
+
+ private:
+ // The search data, a map from query to a vector of starsid.
Yaron 2014/09/05 04:37:52 stars.id
noyau (Ping after 24h) 2014/09/08 09:46:48 Done.
+ std::map<std::string, std::vector<std::string> > searches_;
+ std::string current_query_;
+ DISALLOW_COPY_AND_ASSIGN(BookmarkServerSearchService);
+};
+} // namespace enhanced_bookmarks
+
+#endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698